OVERVIEW
We are building a Mini weather station to provide real-time environment information for a localized area, room or office. It continuously senses ambient temperature and humidity, providing immediate and accurate readings on an OLED display. Additionally, it has a precise real-time clock (RTC) that makes sure that time and date information is available even when the gadget loses power. It also has the potential to grow into an advanced smart home or IoT application in the future.
HARDWARE USED
- ESP8266 NodeMCU
- DHT22 Temperature and Humidity sensor
- DS3231 RTC module
- LCD I2C module
- OLED display
- Jumper Wires
- Breadboard
SOFTWARE USED
- Arduino IDE
APPLICATION DISCUSSION
ESP8266:
The NodeMCU V1.0 (ESP8266) is a small IoT development platform that includes a Wi-Fi-capable microcontroller, a USB interface both for power and programming, a voltage regulator, a few GPIO pins that can be used to connect sensors and devices, a single ADC for analog input, built-in flash memory, and an integrated antenna for wireless communication.
DHT22:
The DHT22 measures temperature and humidity with good accuracy and low power. It uses a single digital pin, making it easy to connect to a microcontroller like an Arduino or ESP8266. The DHT22 has three main parts: the humidity sensing component, the temperature sensing component, and a signal processing component that produces calibrated digital output. The DHT22 is often used in weather stations, smart homes, HVAC systems, and science/educational projects for monitoring the environment.
DS3231 RTC:
The DHT22 is a digital sensor that measures temperature and humidity with good accuracy and low power. It uses a single digital pin, making it easy to connect to a microcontroller like an Arduino or ESP8266. The DHT22 has three main parts: the humidity sensing component, the temperature sensing component, and a signal processing component that produces calibrated digital output. The DHT22 is often used in weather stations, smart homes, HVAC systems, and science/educational projects for monitoring the environment and is perfect for a multitude of temperature/humidity monitoring applications.
LCD:
A 20x4 LCD is a display module that can show 20 characters per line for a total of 4 lines, which makes it useful for applications that require more information to be displayed at once. It has a built-in HD44780-compatible controller, and uses a backlight which enhances visibility in low-light environments. It has included I2C interface module so only two data lines for communication (SDA and SCL) together with Power and Ground are needed which simplifies wiring connection.
OLED:
The 0.96 inch OLED is a small and low-power display that can be used to display text, graphic images, or sensory data. This display used organic light-emitting diode (OLED) technology. This means that each pixel emits its own light without needing a backlight. This also means they provide lots of contrast and rich colors, with low power, and a nice wide viewing angles. It uses the SSD1306 driver chip that controls the operation of each of the pixels. It uses either I2C or serial (SPI) to communicate with the microcontroller (NodeMCU or Arduino). I2C is typically what is used, as it requires less wiring.
HARDWARE SETUP
VERSION 1(OLED)
VERSION 2(LCD)
PIN CONNECTIONS Version 1 (OLED)
- ESP8266
- 3V3 --> DHT VCC
- GND --> DHT GND
- D4 --> DHT DATA FIN
- D2 (GPIO4)--> RTC SDA
- D1(GPIO5) --> RTC SCL
- 3V3 --> RTC VCC
- GND --> RTC GND
- D2 (GPIO4)--> OLED SDA
- D1(GPIO5) --> OLED SCL
- 3V3 --> OLED VCC
- GND --> OLED GND
- SUMMARY:
-
D1 (GPIO5): SCL for both OLED and RTC
-
D2 (GPIO4): SDA for both OLED and RTC
-
D4 (GPIO2): Data for DHT22 Sensor
-
3V3 (or Vin): Power supply for all modules
-
GND: Common ground for all modules
-
PIN CONNECTIONS Version 2 (LCD)
- ESP8266
- 3V3 --> DHT VCC
- GND --> DHT GND
- D4 --> DHT DATA FIN
- D2 (GPIO4)--> RTC SDA
- D1(GPIO5) --> RTC SCL
- 3V3 --> RTC VCC
- GND --> RTC GND
- D2 (GPIO4)--> LCD SDA
- D1(GPIO5) --> LCD SCL
- 3V3 --> LCD VCC
- GND --> LCD GND
- SUMMARY:
-
D1 (GPIO5): SCL for both LCD and RTC
-
D2 (GPIO4): SDA for both LCD and RTC
-
D4 (GPIO2): Data for DHT22 Sensor
-
3V3 (or Vin): Power supply for all modules
-
GND: Common ground for all modules
-
SOFTWARE SET UP
-
Since we make 2 versions of the project using the LCD and the OLED, we set it up in 2 different ways:
VERSION 1 PROJECT CODE (OLED):
VERSION 2 PROJECT CODE (LCD):
CODE BREAKDOWN
-
##include <DHT.h>, <RTClib.h>, <Adafruit_SSD1306.h> or <LiquidCrystal_I2C.h>
– These libraries are used to operate the DHT22 sensor, real-time clock (DS3231), and either OLED or 20x4 LCD display.
- setup()
– This function runs once when the device starts. It sets up the display, sensor, and RTC. It also checks if the RTC is connected and working. - loop()
– Continuously runs after setup. It reads temperature and humidity, gets the current date and time, calculates the heat index, and shows the values on the screen. - dht.readTemperature() and dht.readHumidity()
– Gets live values from the DHT22. If it fails, it shows an error message. - dht.computeHeatIndex()
– Computes how hot it actually feels by combining temperature and humidity. -
rtc.now()
– Reads the current time and date from the RTC for display on the screen.Testing and Calibration: - During testing, we initially connected the power source to the 5V pin, but the system did not work properly. We found that the ESP8266 module (NodeMCU) is designed to run on 3.3V, not 5V.
- To fix the issue, we transferred the power source from the 5V pin to the 3V3 (3.3V) pin on the ESP8266, and the device worked correctly.
- After fixing the power issue, we tested the DHT22 sensor and RTC to make sure they displayed temperature, humidity, and time correctly.
- We also checked if the display (OLED or LCD) was showing values clearly and updated in real-time.
- Minor adjustments were done to sensor reading intervals and display formatting for better visibility and accuracy.
- Make sure all components are properly connected and not loose.
- Ensure power supply is stable to avoid flickering or resetting.
VIDEO DEMONSTRATION
CONCLUSION
This tutorial demonstrate an real-time environmental monitoring. First, the serial communication, I2C connections, OLED screen, DHT22 sensor, and RTC module are initialized. To identify and notify in the event that the RTC or sensor fails, it incorporates error handling. After obtaining temperature and humidity readings from the DHT22 sensor, the code computes the heat index, which is a measure of perceived heat. It simultaneously gets the current time and date from the RTC. Temperature, humidity, and heat index readings, along with a corresponding custom-drawn icon, are displayed on the OLED display along with a formatted mini weather station title and the current date and time. In addition to temperature and heat index readings, the Celsius degree symbol is shown. In a small and easy-to-use format, the display shows current weather and time information, updating every second.
DOCUMENTATIONS
MINI WEATHER STATION WITH OLED
MINI WEATHER STATION WITH LCD
REFERENCES
- ESP32/ESP8266: DHT Temperature and Humidity Readings in OLED Display
- Weather station with OLED and WiFi - using ESP8266, OLED SSD1306, and sensors DHT11 or SHTC3
-
IoT Made Simple: Home Weather Station With NodeMCU and OLED
PROJECT AUTHORS
- Glydelle Arellano
- Arcel Alfaro