Jolynn Awesome
Published © GPL3+

Ambient Temperature Controller

Control the temperature in your room using a DHT22 sensor, a relay, and a RedBoard to turn on/off a heat source in this case the light bulb.

BeginnerFull instructions provided1 hour1,379
Ambient Temperature Controller

Things used in this project

Hardware components

SparkFun RedBoard
SparkFun RedBoard
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
Relay (generic)
×1
light bulb
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
light bulb housing
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Temperature controller Diagram

Code

Ambient Temperature Controller

Arduino
 /*Ambient Temperature Controller
 * DHT22 libraries downloaded from Github-Adafruit
 * DHT22 code used in this program was origianally written by Lady Ada
 * * 
 * Jista Awesome 5 August 2016
 * Be Awesome!
 */

#include "DHT.h"
#include <LiquidCrystal.h>

#define DHTPIN 8     // what digital pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
int lightBulb = 13;

//initialize the library with the numbers of the interface
//Pins on the LCD(rs E  d4 d5 d6 d7
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
//Using a Potentiometer instead of 10k Resistor
// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors.  This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);

//LCD Setup of amount of characters per row 16 with 2 columns
void setup() {
  //Setup the LCD's number of columns and rows
  lcd.begin(16,2);
  dht.begin();  //DHT22 setup
  
  //Heatsource
  pinMode(lightBulb, OUTPUT);
}

void loop() {
  //Read humidity takes about 250 milliseconds
  float h = dht.readHumidity();
  //Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

  
delay(9000);  //9 second delay to avoid lightbulb possibly burning out if it were to turn on in 2 second intervals


//Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
//Setup start location clear screen
lcd.clear();
lcd.print("Temp: ");
lcd.print(f); //Fahrenheit
lcd.print(" *F ");
lcd.setCursor(0,1); //prints to the next line
lcd.print("Humidity: ");
lcd.print(h); //humidity
lcd.print("%    ");

//Relay Switch information
//Checks to see what currently value stored in "f" and sends a signal to pin 8 which is connected to the relay
if (f <= 80.5) {  // Temperature value
  digitalWrite(lightBulb, LOW); //set pin to low which turns heatsource on which is a light bulb
} else {
  digitalWrite(lightBulb, HIGH);  //esle turn lightBulb off
}

}

Credits

Jolynn Awesome

Jolynn Awesome

5 projects • 41 followers
I have a crazy obsession with ducks!

Comments