Introduction: 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.

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); }

Loop

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:

PDF

INO