Skip to content

Instantly share code, notes, and snippets.

@tprochazka
Created January 6, 2014 21:05
Show Gist options
  • Select an option

  • Save tprochazka/8289818 to your computer and use it in GitHub Desktop.

Select an option

Save tprochazka/8289818 to your computer and use it in GitHub Desktop.
Arduino thermostat example project
#include <DHT.h>
#include <LCD5110_Basic.h>
const int COMFORT_TEMPERATURE = 21;
#define DHTPIN 3 // pin teplotního senzoru
#define DHTTYPE DHT11 // typ teplotního senzoru
#define RELAYPIN 2 // pin relé
LCD5110 myGLCD(8,9,10,11,12); // piny LCD displeje
DHT dht(DHTPIN, DHTTYPE);
extern uint8_t SmallFont[];
extern uint8_t MediumNumbers[];
extern uint8_t BigNumbers[];
void setup() {
Serial.begin(9600);
Serial.println("Thermostat by ATom");
pinMode(RELAYPIN, OUTPUT);
dht.begin();
myGLCD.InitLCD();
}
void loop() {
int humidity = dht.readHumidity();
int temperature = dht.readTemperature();
printLCD(temperature, humidity);
if (temperature < COMFORT_TEMPERATURE) {
digitalWrite(RELAYPIN, HIGH);
} else {
digitalWrite(RELAYPIN, LOW);
}
delay(500);
}
void printLCD(int temperature, int humidity ) {
myGLCD.clrScr();
myGLCD.setFont(SmallFont);
myGLCD.print("Temp.", LEFT, 10);
myGLCD.setFont(BigNumbers);
myGLCD.printNumI(temperature, RIGHT, 0);
myGLCD.setFont(SmallFont);
myGLCD.print("Humidity", LEFT, 39);
myGLCD.setFont(MediumNumbers);
myGLCD.printNumI(humidity, RIGHT, 35);
}
@mcquatro
Copy link
Copy Markdown

mcquatro commented May 8, 2014

I have an uno r3 board and a dht11 . Im not finding any sketch that will verify for me. new and struggling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment