Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Explore
ContestsClasses
Publish
Featured:
Gardening
For Teachers
3D Scanning Class
With Instructables you can share what you make with the world, and tap into
an ever-growing community of creative experts.
Download
7 Steps
Shar e
1. Controls a 2-relay board - one for a room heater and one for a humidifier.
2. Checks the temperature and humidity every 10 minutes - this can be set in
the code
3. The algorithm is very simple - Switch off the heater if the temperature goes
1 degree above the set-point and switch it on again if it goes below the set-
point. This is similar to most commercial systems.
4. The humidifier gets switched on if the humidity is below 40% and gets
switched off if it goes above 60%.
5. Uses the EEPROM to save the preset
6. Has one button that is used to change the preset - single click to increase
the temperature by 1 degree, long press to decrease the temperature by 1
degree. The temperature circles between 25 and 30 degree centigrade.
Step 1: Electronics
The Fritzing layout is above. I know it looks extremely confusing but this was
the best I could do (this was my first attempt at using fritzing).
The circuit is actually very simple:
1. OneButton: http://www.mathertel.de/Arduino/OneButtonLibrary.a...
2. DHT11: http://playground.arduino.cc/main/DHT11Lib
3. Timer: https://github.com/JChristensen/Timer
4. EEPROM & LiquidCrystal: both part of the Arduino IDE
#include "OneButton.h"
#include "EEPROM.h"
#include "Timer.h"
#define HUM_SET2 60
#include "LiquidCrystal.h"
#include "dht11.h"
#define DHT11PIN 13
dht11 DHT11;
int temp_set;
Timer t;
void setup() {
pinMode(DHT11PIN, INPUT);
pinMode(LCD_RS, OUTPUT);
pinMode(LCD_EN, OUTPUT);
pinMode(LCD_D4, OUTPUT);
pinMode(LCD_D5, OUTPUT);
pinMode(LCD_D6, OUTPUT);
pinMode(LCD_D7, OUTPUT);
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
lcd.begin(16, 2);
Serial.begin(9600);
EEPROM.write(0,TEMP_SET);
temp_set=TEMP_SET;
else {temp_set=EEPROM.read(0);}
lcd.print("Setpoint: ");
delay(2000);
checkTemp(0);
t.every(60000*CYCLE,checkTemp,(void*)0);
button1.attachClick(tempPlus);
button1.attachPress(tempMinus);
void loop() {
button1.tick();
t.update();
void tempPlus(){
Serial.println("Plus");
temp_set++;
if (temp_set > MAX_TEMP) temp_set = TEMP_SET; // Cycle between TEMP_SET and MAX
_TEMP
lcd.clear();
lcd.print("Setpoint: ");
lcd.print(temp_set);
EEPROM.write(0,temp_set);
delay(1000);
checkTemp(0);
void tempMinus(){
Serial.println("Minus");
temp_set--;
if (temp_set < TEMP_SET) temp_set = MAX_TEMP; // Cycle between TEMP_SET and MAX
_TEMP
lcd.clear();
lcd.print("Setpoint: ");
lcd.print(temp_set);
EEPROM.write(0,temp_set);
delay(2000);
checkTemp(0);
/* switch (chk)
case DHTLIB_OK:
// Serial.println("OK");
break;
case DHTLIB_ERROR_CHECKSUM:
// Serial.println("Checksum error");
break;
case DHTLIB_ERROR_TIMEOUT:
break;
default:
lcd.println("Unknown error");
break;
}*/
lcd.setCursor(0, 0);
Serial.println(DHT11.humidity);
lcd.print("Humidity: ");
lcd.print((float)DHT11.humidity, 2);
lcd.setCursor(0, 1);
lcd.print("Temp: ");
lcd.print((float)DHT11.temperature, 2);
Serial.println(DHT11.temperature);
digitalWrite(RELAY1, HIGH);
Serial.println("H1");
digitalWrite(RELAY1,LOW);
Serial.println("H0");
digitalWrite(RELAY2, HIGH);
Serial.println("T1");
digitalWrite(RELAY2,LOW);
Serial.println("T0");
Step 4: Assembly
The assembly was slightly difficult as fitting the entire circuit, LCD, Relay board
and power adapter inside the extension cord was a tight fit. However, you can
see how everything was fit inside in the photgraphs above.
Also, this would depend a lot on the model of your extension cord and hence
there is no "right way"
1. Controls a 2-relay board - one for a room heater and one for a humidifier.
2. Checks the temperature and humidity every 10 minutes - this can be set in
the code
3. The algorithm is very simple - Switch off the heater if the temperature goes
1 degree above the set-point and switch it on again if it goes below the set-
point. This is similar to most commercial systems.
4. The humidifier gets switched on if the humidity is below 40% and gets
switched off if it goes above 60%.
5. Uses the EEPROM to save the preset
6. Has one button that is used to change the preset - single click to increase
the temperature by 1 degree, long press to decrease the temperature by 1
degree. The temperature circles between 25 and 30 degree centigrade.
1. RX and TX pins
2. Reset pin (to program the arduino)
3. pin 13
4. Two sets of +5 and GND
By replacing the DHT11 and reprogramming, this can be used as a smart power
strip. Some of the uses I could think up are:
Suggestions welcome - please let me know how you would extend this in the
comments below.
The code utilises the following libraries (and all thanks to the authors of these
libraries):
1. OneButton: http://www.mathertel.de/Arduino/OneButtonLibrary.a...
2. DHT11: http://playground.arduino.cc/main/DHT11Lib
3. Timer: https://github.com/JChristensen/Timer
4. EEPROM & LiquidCrystal: both part of the Arduino IDE
More Comments
About This Instructable
11,464views
33favorites
License:
Public Domain
dushyantahujaFollow 164
More by dushyantahuja:
Related
Smart Terrarium
by vakaati
FEATURED CHANNELS
Woodworking
Paper
Kitchen Hacks
Puzzles
Laser Cutting
Space
Homesteading
3D Printing
Sewing
Newsletter
Let your inbox help you discover our best projects, classes, and contests. Instructables will help you
learn how to make anything!
I'm i n!
About Us
Who We Are
Advertise
Contact
Jobs
Help
Find Us
Facebook
Youtube
Twitter
Pinterest
Google+
Resources
For Teachers
Residency Program
Gift Premium Account
Forums
Answers
Sitemap
Terms of Service|
Privacy Statement|
Legal Notices & Trademarks|
Mobile Site