Temp and Humidity monitor

There are multiple components to the Temp and Humidity Sensor the DHT sensor that records the temp and humidity, the LCD display, and the Arduino. The LCD is powered by the Arduino and displays the DHT sensor data, and this data also changes the color of the neo pixel strip based on the temp.

Engineer

Raj T

Area of Interest

Computer Science / Engineering

School

Avenues

Grade

Incoming Sophmore

Reflection

When I was applying for Bluestamp I wanted to learn about coding, electrical work, and basic engineering. I also wanted to get in to the process of project work and learn how to research and work by myself and learn to solve problems when I get them. At Bluestamp I always felt like I was making progress even when I was stuck. I always had people around that helped me think through what was going on and figure out what to do. I had a great time at Bluestamp for the two weeks I was here and next year I want to come back for a longer period of time and get deeper into the process.

Final Project

To finish my project I added a neo pixel ring and strip that correspond with the temp and humidity. I connected both the ring and strip with the three main wires a data pin, VCC pin, and a ground pin. The neo pixel strip changes color depending on temp becoming hotter colors the hotter it is. The neo pixel ring displays the humidity by flashing blue lights. Each light is 10% humidity going up to 100% with the 10 lights. This required two different neo pixel objects and for loops in the code. The code is using the values from the DHT sensor and finds what temp range it then sets the strip color. It also does the same for the humidity.

Click To See Code for the Main Project

#include <Adafruit_NeoPixel.h>
//define NeoPixel Pin and Number of LEDs
#define PIN 5
#define PINTWO 3
#define NUM_LEDS 8
int NUM_RINGS = 3;
#include <LiquidCrystal.h>
#include <dht.h>
// dht library
#define datapin 7 // defines pin number
dht DHT ; // create a dht object
#define CONTRAST_PIN 9
#define BACKLIGHT_PIN 7
#define CONTRAST 110
const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 = 9, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
//create a NeoPixel strip and ring
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel ring = Adafruit_NeoPixel(12, PINTWO, NEO_GRB + NEO_KHZ800);

void setup() {
lcd.begin(16,2);
Serial.begin(9600);
// start the strip and blank it out
strip.begin();
strip.show();
ring.begin();
ring.show();
}

void lcdRecordAndPrint(){
int readData = DHT.read22(datapin); // reads date from DHT 22 sensor
float t = DHT.temperature; // gets value of temp
float h = DHT.humidity; // gets value of humidity
float f = (DHT.temperature * 9/5) + 32;
lcd.setCursor(0,0);
lcd.print(“Temp = “);
lcd.print(t);
lcd.print(” *C “);
lcd.setCursor(0,1);
lcd.print(“Humidity= “);
lcd.print(h);
lcd.println(“% “);
delay(500);
neoStripFlash();
neoRingFlash();
delay(500);
neoOff();
delay(500);
neoStripFlash();
neoRingFlash();
delay(500);
neoOff();
lcd.setCursor(0,0);
lcd.print(“Temp = “);
lcd.print(f);
lcd.print(” *f “);
Serial.print(“Temperature = “);
Serial.print(t);
Serial.print(” *C “);
Serial.print(” Humidity = “);
Serial.print(h);
Serial.println(” % “);
// prints everything on serial monitor and lcd
delay(500);
neoStripFlash();
neoRingFlash();
delay(500);
neoOff();
delay(500);
neoStripFlash();
neoRingFlash();
delay(500);
neoOff();
}
void neoRingFlash(){
ring.setPixelColor( 0,255, 0, 0);
ring.setPixelColor( 1,255, 0, 0);
ring.show();
float h = DHT.humidity;
if(h > 90){
NUM_RINGS = 12;
}
else if(h < 10){
NUM_RINGS = 3;
}
else if (h > 10 && h < 20){
NUM_RINGS = 4;
}
else if (h > 20 && h < 30){
NUM_RINGS = 5;
}
else if (h > 30 && h < 40){
NUM_RINGS = 6;
}
else if (h > 40 && h < 50){
NUM_RINGS = 7;
}
else if (h > 50 && h < 60){
NUM_RINGS = 8;
}
else if (h > 60 && h < 70){
NUM_RINGS = 9;
}
else if (h > 70 && h < 80){
NUM_RINGS = 10;
}
else{
NUM_RINGS = 11;
}
for(int g = 2; g < NUM_RINGS; g++){
ring.setPixelColor(g, 0, 0, 255);
ring.show();
}
}

void neoStripFlash(){
for(int i = 0; i < NUM_LEDS; i++){
float t = DHT.temperature; // gets value of temp
// temperature ranges associate with a color 33 c and above is red, 21 – 33 c is yellowish orange, 10 – 21.1 c is green, 0 – 10 c is purple, 0 – -17 is true blue, -17 and lower is bright baby blue
if(t > 32.2){
strip.setPixelColor(i, 255, 0, 0);
}
else if(10 < t && t < 21.1){
strip.setPixelColor(i, 255, 255, 0);
}
else if(0 < t && t < 10){
strip.setPixelColor(i, 115, 0, 255);
}
else if(-17 < t && t < 0){
strip.setPixelColor(i, 0, 0, 255);
}
else if(-17 > t){
strip.setPixelColor(i, 0, 229, 255);
}
else{
strip.setPixelColor(i, 250, 150, 0);
}
strip.show();
}
}

void neoOff(){
for(int i = 0; i < NUM_LEDS; i++){
// set pixel to off, delay(1000)
strip.setPixelColor(i, 0, 0, 0);
strip.show();
}
for(int g = 2; g < 11; g++){
ring.setPixelColor(g, 0, 0, 0);
ring.show();
}
}
void loop() {
lcdRecordAndPrint();
}

Libraries used : Liquid Crystal, DHT sensor, wire, neopixel libraries

Second Milestone

For my Second Milestone, I connected a DHT sensor to my LCD and got it to print the temperature and humidity of the room. I had to hook up the sensor to the Arduino with three wires one to the data pin, VCC pin, and a ground pin. Once I connected the sensor I coded a program that records temp and humidity and prints to the LCD. Now that this is working I need to start working on Modifications. I’m going to connect a neo pixel strip and wheel, and make it light up different colors according to temp and humidity. I already have it printing the temperature in Celsius. So another goal I want is for it to print in Fahrenheit as well.

Challenges to get to this milestone was making sure I was using the right libraries and the code matched with my wiring. The libraries I got off the internet weren’t designed to work with my code and it took me a few tries to get the right one. I had an 18 pin and 16 pin i2c at first that didn’t work well with my code because they’re pin have different functions.

First Milestone

My First Milestone for the temp and humidity sensor was to get the LCD hooked up and printing. Connecting the LCD to Arduino takes 8 pins and connection to ground and VCC. The LCD also needs a potentiometer to control the brightness of the LCD. The code is a simple hello world program that displays a smiley face and hello world on the LCD. The next step will be to incorporate the DHT sensor and print out data on temp and humidity.

Starter Project

The Process

While working on the battery I used soldering throughout to make my circuit. I also had to desolder some of my mistakes when assembling. I learned to keep polarity in my mind, and many other things while assembling to make sure nothing goes wrong. I used two double a batteries which are 3 volts, but the phone charger needs 5 volts. So to increase the voltage we use inductor and a boost converter.

How it works

The flow of electricity through the inductor creates a magnetic field, and the boost converter switches it on and off . This collapses the magnetic field creating a boost in power. Which goes to the capacitor through a diode. This is why when you test the number of volts it reads 5 volts even though it is a 3-volt battery. When the switch opens the magnetic field comes back again, and the flow of electricity stays in the circuit loop. This concept of a change in the magnetic environment of a coil of wire. Which causes a voltage (emf) to be “induced” in the coil is Faraday’s law. Volts stored in the capacitor go through the charging cable into the phone. The capacitor also keeps the number of volts going in the phone steady.

Minty Boost Demo

img_2344

Start typing and press Enter to search