Skip to content

Instantly share code, notes, and snippets.

@kobeBigs
Last active August 29, 2015 13:57
Show Gist options
  • Save kobeBigs/9676992 to your computer and use it in GitHub Desktop.
Save kobeBigs/9676992 to your computer and use it in GitHub Desktop.
/**
* 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