ESP32 has a Hall Effect Sensor near pin 22, just below and middle of the inscription “ESP32-WROOM-32”, inside the metal cover. Hall effect sensors measure the magnitude of a magnetic field as output voltage. Hall effect sensors are used for proximity sensing, positioning, speed detection, and current sensing applications. Hall sensor when combined with threshold detectors act as a switch. That is used in industrial applications such as pneumatic cylinder, computer printers, computer keyboards, disk drives, speed of wheels and shafts, internal combustion engine ignition timing, tachometers and anti-lock braking systems, brushless DC motors.
In the presence of a magnetic field, the electrons in the metal strip of Hall Sensor are deflected toward one edge, producing a voltage gradient across the short side of the strip perpendicular to the feed current. The sensor operates as an analog transducer, directly returning a voltage. When the magnitude of the magnetic field is known, then its distance from the Hall plate can be determined.
The built-in Hall Sensor of ESP32 is completely unusable outside demonstration. It requires two analog inputs A0 and A3 to have initial config. With the standard gain -11dB and a pseudo 12 bit, the analog inputs are so noisy and non-linear. The Hall Sensor is only sensitive to magnetic field perpendicular to the ESP32 metal cover. Magnetic field parallel to the board has no effect, while perpendicular to it shows the maximum effect. Oddly, magnetic field direction upwards increases the reading values, while downwards decreases the values. So it can not have any usage (and it is not usage).
---
But, that Hall Sensor of ESP32 can disturb a circuit upon facing electric noise.
ESP32 Built-in Hall Sensor Code
Coding part very easy :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | void setup() { Serial.begin(115200); } void loop() { int measurement = 0; measurement = hallRead(); Serial.print("Hall sensor measurement: "); Serial.println(measurement); delay(1000); } |
A slightly difficult, “sensitive” version is :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | int i; long h; void setup() { Serial.begin(115200); } void loop() { h=0; for(i=0;i<1000;i++) { h += hallRead(); delayMicroseconds(100); } Serial.print("Hall sensor value: "); Serial.println((double)h/1000.); } |
Open the Serial Plotter in the Arduino IDE and check how funny it looks.
Tagged With esp32 hall sensor , hall sensor not working on esp32 , esp32 wroom hallsensor , esp32 inbuilt temperature sensor code , arduino hall effect built in , esp32 hall effect sensor code , esp32 hall distamce , esp32 hall , esp32 arduino double , interpreting the values of hall sensor output of esp32