Language: EN

esp32-sensor-hall-integrado

How to read the integrated Hall sensor in the ESP32

The ESP32 is equipped with a built-in Hall sensor that can be used to detect magnetic fields.

A Hall sensor is a device that exploits the Hall effect, a physical phenomenon in which an electric current in a conductor is deflected when placed in a perpendicular magnetic field.

Only the ESP32 (non-version) incorporates this sensor. It was removed in the ESP32-S2 models and later, due to precision issues in measurement.

In fact, even in the official documentation it has been removed since 27/12/2022, as stated in this note PCN20221202 Remove Hall Sensor from ESP32 Series Documentation.pdf

However, if you have an ESP32 that has a built-in Hall sensor, it is still possible to use it. This is useful for small projects, experiments, or training exercises.

Hall Sensor Setup

The software API provided by Espressif Systems, the manufacturer of ESP32, allows easy access to the Hall sensor data.

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  // read hall effect sensor value
  int val = hallRead();
  
  // print the results to the serial monitor
  Serial.println(val); 
  delay(1000);
}