Introduction: Weather Monitoring Using ESP32_DHT11_OLED_Thingspeak
In this tutorial, you will build an weather monitor that monitors temperature and humidity, using an ESP32 and DHT11, It is displayed in to a OLED display. And it is uploaded to ThingSpeak.
The ESP32 is a powerful IOT tool. It is a low-cost system-on-chip (SoC) series created by Espressif Systems. It is an improvement on the popular ESP8266 that is widely used in IoT projects. The ESP32 has both Wi-Fi and Bluetooth capabilities, which make it an all-rounded chip for the development of IoT projects and embedded systems in general.
The DHT11 temperature and humidity sensor is a nice little module that provides digital temperature and humidity readings. It’s really easy to set up, and only requires one wire for the data signal. These sensors are popular for use in remote weather stations, soil monitors, and home automation systems.
ThingSpeak is an Open-Source IoT application and API to store and retrieve data from Hardware devices and Sensors. It uses HTTP Protocol over the Internet or LAN for its communication. The MATLAB analytics is included to analyze and visualize the data received from your Hardware or Sensor Devices.
We can create channels for each and every sensor data. These channels can be set as private channels or you can share the data publically through Public channels. The commercial features include additional features. But we will be using the free version as we doing it for educational purpose.
Step 1: Components Required
1. ESP32 :-The ESP-WROOM-32 is a powerful, generic WiFi-BT-BLE MCU module that targets a wide variety of applications ranging from low-power sensor networks to the most demanding tasks such as voice encoding, music streaming and MP3 decoding.
2. DHT11 Humidity/ Temperature Sensor :- This sensor features a calibrated digital signal output with the temperature and humidity sensor capability. It is integrated with a high-performance 8-bit microcontroller. This sensor includes a resistive element and a sensor for wet NTC temperature measuring devices. It has excellent quality, fast response, anti-interference ability and high performance.
3.OLED ;-This OLED display unit is based on SSD1306 can self-illuminate, with high resolution of 128 ∗ 64 and Viewing angle greater than 160 degree.
4. CP2102 :- CP2102 chip from SiLabs is a single chip USB to UART bridge IC. It requires minimal external components. CP2102 can be used to migrate legacy serial port based devices to USB. This module help all those who are comfortable with RS232/Serial Communication protocol, to build USB devices very easily.
Step 2: Connecting Components Together
Connecting the components as shown in the circuit diagram.
Step 3: Importing ESP32
The first step is to import ESP32 board to Arduino IDE. Here's how to configure the Arduino IDE so we can compile for ESP32: https://elementztechblog.wordpress.com/2017/03/29/flashing-firmware-in-esp-wroom-32-breakout-module/
Step 4: Installing Libraries
1. Installing DHT11 Library
On Arduino IDE >> Select Sketch >> Include Library >> Manage Library >> dht sensor library
2. Installing SSDI306 Library.
On Arduino IDE >> Select Sketch >> Include Library >> Manage Library >>ssd1306
3. Installing Adafruit GFX Library
On Arduino IDE >> Select Sketch >> Include Library >> Manage Library >> adafruit gfx
Step 5: ThingSpeak Setup
Step 1: Go to https://thingspeak.com/ and create your ThingSpeak Account if you don’t have. Login to Your Account.
Step 2: Create a Channel by clicking ’New Channel
Step 3: Enter the channel details.
Name: Any Name
Field 1: Temperature , Field 2: Humidity – This will be displayed on the analytics graph. If you need more than 2 Channels you can create for additional Data. Save this setting.
Step 4: Now you can see the channels. Click on the ‘API Keys’ tab. Here you will get the Channel ID and API Keys. Note this down.
Step 5: Open Arduino IDE and Install the ThingSpeak Library. To do this go to Sketch>Include Library>Manage Libraries. Search for ThingSpeak and install the library. ThingSpeak Communication Library for Arduino, ESP8266 and ESP32 https://thingspeak.com Step 6: Need to modify the code .In the below code you need to change your Network SSID, Password and your ThingSpeak Channel and API Keys.
Step 6: Source Code
Download the code attached here and upload it on your board.
NOTE: Before uploading the below code following lines(56,57) should be changed with your respective ThingSpeak Channel ID and API Key
unsigned long myChannelNumber = SECRET_CH_ID;
const char * myWriteAPIKey = SECRET_WRITE_APIKEY;
Step 7: Output
The output will be like above image in ThingSpeak. Hope this made it easier for you. Be sure to subscribe if you liked this article and found it useful, and if you have any questions or need help with anything, just leave a comment below.
Thanks to elementzonline.com