Temperature and Humidity LEDs

by hra11 in Circuits > Arduino

293 Views, 0 Favorites, 0 Comments

Temperature and Humidity LEDs

board 5.jpg

If you’ve ever wanted a more visual thermometer, this project can help. We’ll be making a set of LEDs that display certain colors based on levels of humidity and temperature.

Materials

materials.jpg

For this Project You will need:

- 2 RGB LEDs

- DHT11 Temperature and humidity module

- 6 220Ω resistors

-12 breadboard jumpers (wires)

- Arduino UNO R3

- Arduino IDE (for coding)

- DHT Sensor Library (to make your temperature module function)

Wiring the Breadboard

instructable layout_bb.png

building1.jpg

You want to set up a proper power supply to each component, so let’s start with the ground and 5 volt connections

building2.jpg

Next, let’s set up the temperature sensor. Mine is connected to the 2 pin in the Arduino uno

building3.jpg

Finally let’s set up the LEDs. Both have the same wiring and resistor setup. My pins for the LED representing temperature readings are at 3, 5, and 6 while the humidity LED is set at pins 9, 10, and 11

board 5.jpg

You now have a finished circuit! Let's start working on the code allowing these LEDs to sense temperature.

First, define the pins for your temperature sensor and LEDs according to your pins and include the library for the temperature sensor. To include the library (in our case “DHT” is our needed library), go to the menu bar and select “Sketch> Include Library > Add .ZIP Library” and select the “DHT” ZIP folder from where you downloaded it.

Coding

2020-11-17.png
code3.png

2020-11-17 (3).png

Next, in Void Setup determine the output for both LEDs as well as the serial monitor for your sensor.

code3.png

In void Loop, write out the function of your serial monitor. This is where you will take temperature and humidity readings from for the loop function later.

code5.png

Run the Serial monitor by going to the menu bar and selecting “Tools> Serial Monitor”. You should get readings for temperature and humidity. Wait 30 seconds and write down the numbers that appear the most frequently for both temperature and humidity. Now that you have a reading, we can plug in these values for our next segment of code

code4.png

In order to make our LEDs light up accordingly, we have to write some "else" statements. Take the reading you took for temperature and plug it in to the first set of statements. If the temperature is higher than the value assigned, the light will turn red. Otherwise it will remain blue. The same applies to humidity. If the reading is higher than the value you took, the light turns red. Otherwise it will remain blue.

Done!

LEDs temperature sensor

You now have a your very own temperature and humidity sensing LEDs!