Last active
August 29, 2015 13:57
-
-
Save kobeBigs/9676992 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* temperature & humidity logger | |
* | |
* @kobebigs Thu Mar 20, 2014 15:14:30 | |
*/ | |
#include <Time.h> | |
#include <DHT.h> | |
//define connected pin | |
#define DHTPIN 7 | |
//define type of DHT sensor | |
#define DHTTYPE DHT22 | |
//create an object of DHT | |
DHT dht(DHTPIN, DHTTYPE); | |
void setup() | |
{ | |
// start serial port at 9600 bps: | |
Serial.begin(9600); | |
dht.begin(); | |
establishContact(); | |
} | |
void loop() | |
{ | |
} | |
void establishContact() { | |
while (Serial.available() <= 0){ | |
//read temperature | |
float t= dht.readTemperature(); | |
//check if returns are valid, | |
if(isnan(t)){ | |
Serial.println("Failed to read from DHT"); | |
} else { | |
Serial.println(t); | |
} | |
delay(2000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment