Created
May 22, 2014 14:44
-
-
Save Sekhmet/ffacae786b8ba61d3183 to your computer and use it in GitHub Desktop.
This file contains 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
#include "DHT.h" | |
#define DHTPIN 2 // what pin we're connected to | |
#define DHTTYPE DHT22 | |
float t = 0; | |
float h = 0; | |
unsigned long czas; | |
uint8_t acc = 13; | |
DHT dht(DHTPIN, DHTTYPE); | |
void setup () { | |
Serial.begin(9600); | |
pinMode(A0, INPUT); | |
Serial.println("SimpleDataLogger ver. 0.21 by Patryk Pietrzak, Wiktor Tkaczyński"); | |
Serial.println("time t*C h% light"); | |
} | |
void loop() { | |
czas = millis(); | |
float h = dht.readHumidity(); //temperatura | |
float t = dht.readTemperature(); //wilgotnosc | |
int l = analogRead(A0); //swiatlo | |
if (isnan(t) || isnan(h)) { //suma kontrolna | |
Serial.print(czas / 1000); | |
Serial.print(" "); | |
Serial.println("ERR|0"); // 0 - data fetch failed | |
} | |
else { //pomiary | |
digitalWrite(acc, HIGH); | |
String returned_data = czas/1000 + "|" + t + "|" + h + "|" + l; | |
Serial.println(returned_data); // return value with \r\n delimiter | |
digitalWrite(acc, LOW); | |
} | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment