PROJECT #6 - Trying Out Serial Communication (I2C) On ESP32 Dev Board Using The Arduino IDE
Hello again! This time, I'm going to try using serial communication, especially I2C (Inter-Integrated Circuit), on ESP32 Dev Board. In the project, I'm going to get sensor readings from BMP280 Sensor and display the results on an OLED Display. Now, without any more delay, let's get to the project!
STEP 1: Prepare The Required Software and Hardware
For hardware, you'll need these components:
- ESP32 Dev Board
- Breadboard
- Jumper Wire Male-to-Male
- OLED Display (I'm using OLED 0.96 inch 128x64 Display Module)
- BMP280 Barometric Pressure Module
For software, you'll need to set up the Arduino IDE. If you haven't set it up yet, you can click here to see the installation process from my first project in the first step from the first part.
Be sure to install the correct library too for both the OLED Display and the BMP280 Module.
STEP 2: Set Up The Hardware
Firstly, put the ESP32 Dev Board, the OLED Display, and the BMP280 on the breadboard. After that, connect a jumper wire from the ESP32 pins to the BMP280 and the OLED Display. For the details, see below :
- 3V3 pin (dev board) to VCC pin (both sensor and OLED)
- GND pin (dev board) to GND pin (both sensor and OLED)
- GPIO 22 pin (dev board) to SCL pin (both sensor and OLED)
- GPIO 21 pin (dev board) to SDA pin (both sensor and OLED)
To help connect both devices to the same GPIO pins, you can use the breadboard. You can refer to the image below for reference.
Hardware Setup |
STEP 3: Program The Dev Board
The code I'm using is based on a project from the randomnerdtutorials website. You can see the base source code from here. Look below for my project's code.
I2C Two Device Source Code (1) |
I2C Two Device Source Code (2) |
After preparing the code, upload it to the ESP32 Dev Board.
STEP 4: Check The Result and Debug If Necessary
After resetting the Dev Board, the sensor reading's result from the BMP280 should be displayed in the OLED Display. Look below for my project's result.
And that's it for this project! Thank you for reading and happy experimenting!
- Ryu / 18220025
Comments
Post a Comment