Last Updated on December 19, 2024
ESP32 Microcontroller loaded with lot of essential features. Internal Hall Effect Sensor is one among them. Here we are going to make experiment with Internal Hall Effect sensor of ESP32. Before starting with this, keep in mind that ESP32 (Classic), ESP32-WROOM-32 and similar modules only have built in Hall Sensor.
Not Suitable (NOT include a built in Hall Effect Sensor) Versions are, ESP32-S2, ESP32-S3, ESP32-C3, ESP32-H2 and pico.
What is Hall Effect Sensor?
A Sensor which detects and measures the strength of a magnetic field is called as Hall Effect Sensor. Operation principle of this sensor is based on the Hall Effect, When a Electric Conductor placed near magnetic field perpendicular to the flow of current there will be Voltage difference generated. This is known as Hall Voltage, by using this technique we can detect & measure magnetic pole and field strength. More flux results more output voltage.
You Just need Classic ESP32 Wroom or doit dev kit Version board and Arduino IDE. To test the internal hall sensor.
To measure the magnetic flux just connect ESP32 board with computer and upload the following code.
/* Code from theoryCIRCUIT.com ESP32 Internal Hall Effect Sensor This code reads the internal hall effect sensor of the ESP32 and prints the values to the Serial Monitor. Note: The internal hall sensor is not calibrated and is affected by temperature and power fluctuations. */ #include <Arduino.h> void setup() { Serial.begin(115200); // Initialize Serial communication delay(1000); // Allow time for setup to stabilize Serial.println("ESP32 Hall Effect Sensor Example"); } void loop() { // Read the hall sensor value int hallValue = hallRead(); // Print the value to the Serial Monitor Serial.print("Hall Sensor Value: "); Serial.println(hallValue); // Add a delay for readability delay(1000); }
Here the Internal Hall Effect sensor value is read by the hallRead() function, this returns the raw sensor data from the ESP32 Controller, Positive value indicates the North pole and the lower Negative value indicates the South pole. You can get higher value when you place strong magnet near to ESP32 board.
Limitations
- Due to its internal characteristics, sensitivity may vary.
- There will be noise from other components when you place strong magnet.
- Not suitable for sensitive projects.