Easy Basics: Project 076g ESP32 Development board - Built in hall effect sensor

of Acoptex.com in ESP8266 ESP-32

Basics: Project 076g

Project name: ESP32 Development board - Built in hall effect sensor

Tags: ESP32 Dev Module, ESP32 development board, ESP32 Development board with WiFi and Bluetooth, ESP32-DevKitC V4 development board, ESP-WROOM-32 module with ESP32‑D0WDQ6 chip, Espressif Systems, ESP32-based development board, ESP32 modules, ESP32-WROOM-32, ESP32-WROOM-32U, ESP32-WROOM-32D, ESP32-SOLO-1, USB-UART bridge, IOT, ESP-WROOM-32 Dev Module, ESP32 DEVKITV1, built in hall effect sensor, MicroPython

Attachments: sketch1, sketch2

In this project, you need these parts :

1. ESP32 development board with WiFi and Bluetooth and USB A / micro USB B cable 1 pc

2. Arduino IDE (you can download it here)

3. uPyCraft IDE (you can download and read more about ithere)


We will learn about built in hall effect sensor on the ESP32 development board. We will show you how to use the ESP32 hall effect sensor with Arduino IDE and with MicroPython.

There are a lot of different ESP32 development boards made. You can find more information about them here

Understanding the hall effect sensors

All ESP32 chips have built-in hall effect sensor. Whatever type of ESP32 development board you use, it must have ESP32 chip with built-in hall effect sensor. Hall effect sensors are used to measure the magnetic field. Hall effect sensors detect the magnetic field of lines in their surroundings and produce a voltage at the output pins of the sensor. Similarly, ESP32 has built-in hall sensor inside its chip which can be used to measure the magnetic field. We can measure the output of this hall sensor at one of the GPIO pins of the ESP32 development board. Hall effect sensors are used to measure magnetic field strength and also used for current measurement. 

Where the hall effect sensor located in ESP32 chip?

For all ESP32 chips, it is located under this metal cover of the ESP32 board. When you bring a magnet near to this metal cover, it detects the variations in the magnetic field and produces an output voltage according to the strength of the magnetic field. The greater the magnetic field, the greater the sensor’s output voltage.

ESP32 development board does not provide any pin for the output measurement of the hall sensor. Because we only want to read the value of voltage according to magnetic field strength in the surroundings of ESP32 board. Therefore output its built-in hall effect sensor saves in a register of ESP32 board, and we can easily read it with Arduino IDE built-in function.

The hall effect sensor can be combined with a threshold detection to act as a switch, for example. Hall effect sensors are mainly used to:

  • Detect proximity;
  • Calculate positioning;
  • Count the number of revolutions of a wheel;
  • Detect a door closing;
  • And so on.

Understanding the ESP32 Development board with WiFi and Bluetooth

You can read more about it here.

Signals and connections of the ESP32 Development board with WiFi and Bluetooth

You can find more information (datasheets, schematics, pins descriptions, functional desgn descriptions) about each board (made by Espresiff Systems) by pressing Getting started link close to each board here.

Let's check our development board - ESP32 DEVKITV1with ESP-WROOM-32 module from Espressif Systems:

Pinout diagram for the ESP Wroom 32 breakout:

ESP32-WROOM-32 - ESP32-WROOM-32 module soldered to the development board. Optionally ESP32-WROOM-32D, ESP32-WROOM-32U or ESP32-SOLO-1 module may be soldered instead of the ESP32-WROOM-32.

USB-UART Bridge - A single chip USB-UART bridge provides up to 3 Mbps transfers rates.

BOOT button - Download button: holding down the Bootbutton and pressing the EN button initiates the firmware download mode. Then user can download firmware through the serial port.

EN button - Reset button: pressing this button resets the system.

Micro USB Port - USB interface. It functions as the power supply for the board and the communication interface between PC and the ESP module.

TX0, TX2 - transmit pin. GPIO pin

RX0, RX2  - receive pin.  GPIO pin

3V3 (or 3V or 3.3V) - power supply pin (3-3.6V). 

GND - ground pin.

EN - Chip enable. Keep it on high (3.3V) for normal operation.

Vin - External power supply 5VDC.

Step by Step instruction

The ESP32 is currently being integrated with the Arduino IDE like it was done for the ESP8266. There’s an add-on for the Arduino IDE that allows you to program the ESP32 using the Arduino IDE and its programming language.

1. Installing ESP32 add-on in Arduino IDE (Windows 10 OS)

  1. Download and install the latest Arduino IDE Windows Installer from arduino.cc
  2. Download and install Git and Git GUI from git-scm.com
  3. Search for Git GUI, right-click the icon and select “Run as administrator
  4. Select the Clone Existing Repository option.
  5. Select source and destination. Source Location: https://github.com/espressif/arduino-esp32.git
  6. Target Directory:C:/Users/[YOUR_USER_NAME]/Documents/Arduino/hardware/espressif/esp32
  7. Do not create the espressif/esp32 folders, because they will be created automatically.
  8. Click Clone to start cloning the repository.Wait a few seconds while the repository is being cloned.
  9. Open the folder: C:/Users/[YOUR_USER_NAME]/Documents/Arduino/hardware/espressif/esp32/tools
  10. Right-click the get.exe file and select “Run as administrator“.
  11. You will see that necessary files will be downloaded and upzipped. It will take some time.
  12. When get.exe finishes, you should see the following files in the directory.

2. Uploading sketch to ESP32 development board

  1. Do wiring.
  2. Plug the ESP32 development board to your PC and wait for the drivers to install (or install manually any that might be required).
  3. Open Arduino IDE.
  4. Open Boards manager. Go to Tools -> Board -> Boards Manager… (in our case it’s the DOIT ESP32 DEVKIT V1)
  5. Select COM port that the board is attached to (if you don’t see the COM Port in your Arduino IDE, you need to install the ESP32 CP210x USB to UART Bridge VCP Drivers)
  6. Open sketch1, compile and upload it to your ESP32 development board. If everything went as expected, you should see a “Done uploading” message. (You need to hold the ESP32 on-board Boot button while uploading).
  7. Press the ESP32 on-board EN button to reboot it. 
  8. Open the Serial Monitor at a baud rate of 9600.  Put the magnet on top of the ESP32 hall sensor and you will see that the values increasing or decreasing depending on the magnet pole that is facing the sensor. The closer the magnet is to the sensor, the greater the absolute values are.

3. Using MicroPython

  1. Install uPyCraft IDE on your PC;
  2. Plug the ESP32 development board to your PC and wait for the drivers to install (or install manually any that might be required).
  3. Upload MicroPython firmware to your ESP32 Development board .
  4. Open uPyCraft IDE. Double-click uPyCraft_V1.1.exe file. A new window opens with the uPyCraft IDE software.
  5. Go to Tools -> Board. If you are using ESP32 development board select esp32.
  6. Go to Tools -> Serial and select your ESP32 Development board COM port (in our case it’s COM8). If you don’t see the COM Port, you need to install the ESP32 CP210x USB to UART Bridge VCP Drivers , check your USB cable too (it should be data cable).
  7. You have established a serial communication with your board. The >>> should appear in the Shell window after a successful connection with your board.
  8. Go to File->Open. Open the sketch2.
  9. Press Download and Run button to upload the script to the ESP32 Development board.
  10. You should see a message download ok in the Shell window.
  11. Press the ESP32 development board on-board EN button to reboot it.


Sketch1. Reading the hall effect sensor measurements with the ESP32 using the Arduino IDE is as simple as using the hallRead() function which reads the value of the output of the hall sensor and returns the result in a declared variable. hallRead() function does not need any argument. It reads the value of hall sensor output which is stored in a register of ESP32.  We can simply save the output of hallRead() function in any variables. In this code, we have saved the output voltage of the hall sensor in a variable name hall_sensor_value. After that, we are sending these values to the serial monitor. The output of hallRead() function can be either positive or negative depending on the direction magnetic field.

Sketch2. To read the ESP32 hall effect sensor using MicroPython, you just need to use the following snippet of code: import esp32 esp32.hall_sensor() You need to import the esp32 module. Then, use the hall_sensor() method. If you want to print the readings on the shell, you just need to use the print() function: print(esp32.hall_sensor())


We have learnt about built in hall effect sensor on the ESP32 development board. We have seen how to use the ESP32 hall effect sensor with Arduino IDE and with MicroPython.


  • No libraries required for this project


  • None

Other projects of Acoptex.com
Easy Basics: Project 083d Sipeed Maixduino Kit for RISC-V AI and IoT of Acoptex.com in ESP8266 ESP-32 16-06-2019
Easy Basics: Project 076f ESP32 Development board - How to use GPIO pins of Acoptex.com in ESP8266 ESP-32 03-06-2019
Easy Basics: Project 082a Lithum battery charger TP4056 of Acoptex.com in UNO 01-06-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 04-06-2019
Viewed: 224 times