Welcome to DFRobot: www.DFRobot.com.cn 40 / 49
void loop() {
// put your main code here, to run repeatedly:
Serial.println(hallRead());
delay(100);
}
Please click verify/compile to review and please upload it after the confirmation.
Once you click Upload, IDE will send codes to FireBeetle Board-ESP32.
Once the upload finishes, open the built-in serial monitor of Arduino IDE, print message shown as
below.
Caution: Change the distance of the magnet to FireBeetle Board-ESP32, you can see the variety of
the printed numbers.
Code analysis
The hall sensor used in this project is integrated by FireBeetle Board-ESP32. The bottom uses IO36
and IO39 to read the voltage of the hall sensor (Please refer to source if you are interested in the
bottom). We only need to call the function hallRead.
hallRead()
The return type of digital signal value got from the hall sensor is int.
You can try modifying the code to do your own project.