Hidden Hall Sensor in ESP32

About: Do you like technology? Follow my channel on Youtube and my Blog. In them I put videos every week of microcontrollers, arduinos, networks, among other subjects. New tutorials on Tuesdays and Fridays.

Did you know that there is a sensor inside ESP32? This is the HALL SENSOR. It is located inside the metal part of the board in the Tensilica microcontroller chip. In today’s video, I’ll introduce the Hall sensor, and create a program using the ESP32 to measure the voltage variation when approaching a magnetic field.

Step 1: Introduction

The Hall-effect sensor is a transducer which,when applied under a magnetic field, responds with a change in its output voltage.

The Hall Effect is what happens when a current in a conductor has its path deviated by the action of a magnetic field. With an appropriate format, this deviation causes the Hall Voltage to be generated, and this can be harnessed by an external circuit, and that is what Hall sensors do. Hall voltage can be measured by an external circuit or used for sensing purposes, as it is proportional to the intensity of the field it creates.

Step 2: Applications

• Pneumatic cylinders

• Printers

• Keyboards

• In the automotive industry (speed measurement of wheels and axles, calculation of ignition time of internal combustion engines, tachometers, ABS fair ...)

Step 3: Demonstration

Step 4: WiFi NodeMCU-32S ESP-WROOM-32

Step 5: Program

We will do a program in which the ESP32 will read the Hall sensor and, if it reaches a certain limit, the internal LED will light up, indicating the occurrence.

Variables and Setup

The internal LED was connected to pin 2, and we set the limit as "zero.” In Setup, we set the LED pin as output. Remember that this program is quite simple, and there’s no need to install any library.

//LED interno (pode variar o pino de placa para placa)
const int LED = 2; //limite para ativar o LED const int LIMIT = 0; void setup() { Serial.begin(115200); //configura o pino do LED como saída pinMode(LED, OUTPUT); }


In the Loop, we store the read value of the Hall sensor. We read the data and print the measurement. We then check if the read value is less than the defined limit. In this case, we turn on the LED. Otherwise, the LED is turned off.

void loop() {
//guarda o valor lido do sensor hall int measurement = 0; //faz a leitura do sensor hall measurement = hallRead(); Serial.print(“Imprime a medida: "); Serial.println(measurement); //verifica se o valor lido é menor que o limite definido if(measurement < LIMIT) { //liga o LED digitalWrite(LED, HIGH); } else { //desliga o LED digitalWrite(LED, LOW); } delay(100); }

Step 6: Files

Download the files:





    • Big and Small Contest

      Big and Small Contest
    • First Time Author

      First Time Author
    • Make it Glow Contest 2018

      Make it Glow Contest 2018



    Question 6 weeks ago


    you've made so much instructables about the ESP32. THANK YOU!
    I'm still learning a lot from these.
    Is there any part/sensor/... on the ESP you cannot reach?
    Can the RTC be used for a clock?
    Did you make an instructabel to get the data from the internal temp-sensor?

    This little chip is so powerfull. Sadly enough, most of the time i'm using them becaus of just one specific feature in my projects.
    Using an ESP32 just becaue of the touch-sensors seems to be overdoses - but it's easy and it works.