Index

What is a Hall Effect Sensor?
A Hall Effect sensor detects magnetic fields. When you bring a magnet close to it, the sensor outputs a voltage change — perfect for detecting proximity, speed, or rotation in motors.
But did you know your ESP32 has a built-in Hall sensor? That means you can detect magnets using just the board — no wires, no modules, just code.
Where is the Hall Sensor in ESP32?
The Hall sensor is located internally on the chip itself, near the GPIOs — but it’s not mapped to a specific pin. It detects magnetic fields around the chip’s surface.

It’s very sensitive to orientation and distance, so experiment by rotating your ESP32 near a magnet.
What You Need
- ESP32 Dev Board
- A small magnet (neodymium works best)
- USB cable
Arduino Code
Here’s a simple sketch to read the Hall sensor values:
void setup() {
Serial.begin(115200);
}
void loop() {
int hallValue = hallRead();
Serial.print("Hall Sensor Value: ");
Serial.println(hallValue);
delay(500);
}
hallRead()
is a built-in function for ESP32 (Arduino core). No extra libraries needed!
What to Expect
- With no magnet nearby, values will hover around 0 (±50).
- Bring a north pole of the magnet close to the chip → values increase.
- Bring a south pole → values decrease (or vice versa, depending on orientation).
- Try different distances and angles.
Use Cases
- Magnetic door sensors
- Rotation detection in motors
- DIY compass (basic)
- Presence detection
- Fun science demos!
Limitations
- The Hall sensor is not super accurate or calibrated.
- It’s affected by temperature and other nearby electronics.
- Can’t replace a full magnetic sensor module for precise tasks — but works great for basic detection.
Bonus Tip: Serial Plotter
Use the Arduino Serial Plotter (from Tools > Serial Plotter) to visualize the magnetic field in real-time! It’s super fun to see the waveform react as you move the magnet.
Conclusion
ESP32’s built-in Hall Effect sensor is an underrated feature — perfect for simple magnet detection without external hardware. Whether you’re a hobbyist or student, it’s a cool tool to explore the invisible world of magnetic fields.