The ESP32 is equipped with an integrated Hall sensor that can be used to detect magnetic fields.
A Hall sensor is a device that leverages the Hall effect, a physical phenomenon where an electric current in a conductor is deflected when placed in a perpendicular magnetic field.
Only the original ESP32 (non-S version) incorporates this sensor. It was removed in the ESP32-S2 models and onwards because it had accuracy issues in measurement.
In fact, even the official documentation has removed it as of 12/27/2022, as noted in this document PCN20221202 Remove Hall Sensor from ESP32 Series Documentation.pdf
However, if you have an ESP32 that does have an integrated Hall sensor, it is still possible to use it. This is useful for small projects, experiments, or for training exercises.
Hall Sensor Configuration
The software API provided by Espressif Systems, the manufacturer of the 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);
}

