/arduino-uno-aws-weather-station

Weather Station with Arduino Uno board, Temp & Humidity Sensor, UV Sensor, LCD screen, ESP8266 WiFi module, and AWS IOT

Primary LanguageC++Apache License 2.0Apache-2.0

Connected Weather Station with Arduino to measure Temperature, Humidity, Heat Index and UV light

PROJECT ARCHITECTURE

This repo accompanies the "Connected Weather Station" YouTube series. it contains the code, library, diagrams, and more information that I promised in the videos.

Video 1: Building an IoT Weather Station with Arduino, DHT11, and LCD Screen This episode shows you how to use the DHT11 temperature and humidity sensors with the Arduino Uno board to build a weather station that displays current temperature and humidity on an LCD screen.

Video 2: Connecting the IoT Weather Station to AWS IoT using ESP8266 This episode builds on the previous one and continues forward by pushing the temperature & humidity data received through the DHT11 sensor, onto an AWS IoT account using an ESP8266 WiFi module.

Video 3: Adding a UV sensor to the weather station This episode builds on the previous two and shows how to add a UV Light sensor to the weather station.

⚡️ COMPONENTS AND SUPPLIES

🖥 APPS

📦 Libraries

What is humidity?

Humidity is the water vapour around you mixed with air. It is measured in %. So, if the humidity is 60%, then 60% of the air around you is water vapour. If it is 100%, then it means either the sensor is not correct, the sensor is broken/damaged, the Arduino crashed, the Arduino can't receive any signal, there's an error in the code or you're underwater(1). If it's 0%, it means all the reasons above except the last one, you're in space or you're in the middle of a desert(2).

(1) Correction: it means the air cannot hold any more water. (2) The air in a desert does contain some water but it is a very little amount compared to a normal place. The Sahara Desert has a mean humidity of 25%.

How to measure Temperature & Humidity

To the right, is a DHT11 sensor, it is a temperature and humidity combined sensor with calibrated digital signal output. It's is a reliable sensor for determining temperature and humidity. There is a newer and more accurate module on the market called DHT22 but we will stick with the DHT11 for this demo

How to measure UV Light

UV sensors like the GUVA-S12SD to the left, are Ultraviolet testers and outdoor ultraviolet detectors that use calibrated light sensing algorithms that can calculate UV Index. This type of sensors don't contain an actual UV sensing element, instead they approximate it based on visible & IR light from the sun. This particular sensor measures ambient ultraviolet intensity in the 200 to 370 nanometer range, including solar ultraviolet UVA, UVB, and UVC light. This UV Sensor also provides a built-in amplifier with adjustable levels

LCD Screen - Schematic Diagram

The LCD needs six Arduino pins, all set to be digital outputs. It also needs 5V and GND connections.

There are several connections to be made. Lining up the display with the top of the breadboard helps to identify its pins without too much counting, especially if the breadboard has its rows numbered with row 1 as the top row of the board. Do not forget, the long yellow lead that links the slider of the pot to pin 3 of the display. The potentiometer is used to control the contrast of the display.

Adding the DHT11 to the Schematic Diagram

Wire the DHT11 sensor to the Arduino Uno development board as shown in the following schematic diagram.

Adding the ESP8266 ESP01 to the Schematic Diagram

The ESP8266 WiFi Module is a self-contained stack that can give any microcontroller access to your WiFi network. The ESP8266 is capable of either hosting an application or offloading all Wi-Fi networking functions from another application processor. The ESP8266 module is an extremely cost-effective board with a huge, and ever-growing, community.

Adding the UV Sensor to the Schematic Diagram

Code Walkthrough

The code itself is straightforward and well commented (help is of course welcome) but I wanted to explain something I struggled with when I first started learning my way through the Arduino world, and that is the difference between Software Serial and Hardware Serial.

Let's go through the function sendDataToWiFiBoard(). This function allows the Arduino board (the logic board) to communicate with the ESP8266 board (The WiFi board)

String sendDataToWiFiBoard(String command, const int timeout, boolean debug)

So after connecting the two boards following the wiring diagram above, and initializing a new Software Serial object called wifi

// ESP TX => Uno Pin 2
// ESP RX => Uno Pin 3
SoftwareSerial wifi(2, 3);

Anything passed to the print() function will be sent through the pin 2 to the WiFi board.

  wifi.print(command); // send the read character to the esp8266

This is different than calling the same print() function on the Serial object, which sends the string through the Serial monitor.

Pin 3 is then used to read any response coming back from the WiFi board through the read() function.

  while((time+timeout) > millis()) {
    while(wifi.available()) {
      // The esp has data so display its output to the serial window
      char c = wifi.read(); // read the next character.
      response+=c;
    }
  }

  return response;
}

Next Step

For code that goes into the WiFi board (ESP8266 ESP01) and more explanation, please head out to this repo: https://github.com/MecaHumArduino/esp8266-01-aws-mqtt