Programming "Hall Effect Sensor" on an ESP32 board using the Ardiono IDE

Hello there!

This time, I'm going to show you how to use the Hall Effect Sensor in the ESP32 Development Kit to sense magnetic field variations. It is a very simple program that mainly only uses the hallRead() function.

STEP 1: Required Hardware


All you will need is:
  • 1 Laptop/PC
  • 1 ESP32 Development Board
  • Magnets

STEP 2: Required Software

1. Install Arduino IDE, you can easily get it under this link: https://www.arduino.cc/en/main/software



2. Install the correct Board you are using in the Arduino Software in the Tools Menu Bar by copying this url into the Additional Boards Manager URLs bar in Preferences first: https://dl.espressif.com/dl/package_esp32_index.jsonif you are using a Arduino Board this is unnecessary.




3. Find Boards Manager under Tools > Boards and choose the Board you are using. In my case, using the ESP32 I go to Boards Manager and install the esp32 module


Afterward, I will be able to choose the board I use.



4. Install a USB to UART Port Driver, this is the one I am using

https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers



After installing this driver, I can choose the USB to UART Port under Tools > Port:, if you are using a Desktop PC then it might come out under the name COM(Number) like so:




STEP 3: Code and Compile

Under the Menu Bar, click on File > Examples > ESP > HallSensor. The following code would then appear on a new Arduino Window.





Click on the checklist icon to compile the code.


STEP 4: Connect and Upload

Use your USB cable to connect the ESP32 to your laptop. A red LED should light up signing your Board is powered and ready to use.

By clicking the arrow pointing rights upload the program to your Development Board using the USB to UART port in the Tools Menu Bar.

Open the Serial Monitor under Tools to view measurements recorded by the sensor.

If you are having trouble uploading the Code, try to press the Boot button when the Software shows a "Connecting" message.

STEP 5: Observe and Explore

After Arduino IDE is done uploading your program, the Hall Effect Sensor which is located behind the silver lid on the ESP32 is activated and will immediately record its measurements. 


Negative numbers stand for negative magnetic fields and positive numbers for positive magnetic fields.





And that's it!

Comments

Popular posts from this blog

Plotting Real Time Sensor Readings on Web Servers using ESP32 and Arduino IDE

Inserting Data from an ESP32 to a MySQL database using PHP and Arduino IDE

Receiving Data on ESP32 from a HTML form of its Web Server using Arduino IDE