Hall effect sensor in the ESP32 with Arduino ide

Learning about the esp32 again. When looking at the adc documentation at this interested me

It is also possible to read the internal hall effect sensor via ADC1.

Digging in the code for the arduino-esp32 we find that we can read it using hallRead() from arduino-esp32/cores/esp32/esp32-hal-adc.h

Might be useful to someone.

//Simple sketch to access the internal hall effect detector on the esp32.
//values can be quite low. 
//Brian Degger 

int val = 0;

void setup() {

void loop() {
  // put your main code here, to run repeatedly:
  val = hallRead();
  // print the results to the serial monitor:
  //Serial.print("sensor = ");
  Serial.println(val);//to graph

Strong magnets are needed to get a good response.

Leave a Reply

Your email address will not be published. Required fields are marked *