diff options
author | Elena of Valhalla'' Grandi <valhalla@trueelena.org> | 2015-05-03 20:14:02 +0200 |
---|---|---|
committer | Elena of Valhalla'' Grandi <valhalla@trueelena.org> | 2015-05-03 20:14:02 +0200 |
commit | 2e49dcff5f0615ff7f166382cf6c1038c8643a60 (patch) | |
tree | 55a3c95d7b1385d937e89db02549beef36333767 /arduino | |
parent | 71d0f75ef6af70b4f8b7b72f777ef54e14d5df21 (diff) |
Diffstat (limited to 'arduino')
-rw-r--r-- | arduino/data_collect/data_collect.ino | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/arduino/data_collect/data_collect.ino b/arduino/data_collect/data_collect.ino index 27a44e3..482c9a3 100644 --- a/arduino/data_collect/data_collect.ino +++ b/arduino/data_collect/data_collect.ino @@ -3,7 +3,9 @@ #include <PubSubClient.h> #include "DHT.h" -#define TOPIC "data/here/temperature" +#define TOPIC_T "data/here/temperature" +#define TOPIC_H "data/here/humidity" +#define TOPIC_A "data/here/available" #define DHTPIN 2 #define DHTTYPE DHT22 @@ -21,19 +23,23 @@ void setup() { Ethernet.begin(mac, ip); dht.begin(); Serial.begin(9600); + if (client.connect("arduinoClient")) { + client.publish(TOPIC_A,"1"); + } } void loop() { - //client.loop(); float t = dht.readTemperature(); float h = dht.readHumidity(); - //String temp = String(t); - Serial.println(t); + //Serial.println(t); + //Serial.println(h); char temp[6]; dtostrf(t, 5, 2, temp); - Serial.print(temp); - if (client.connect("arduinoClient")) { - client.publish(TOPIC,temp); - } + //Serial.println(temp); + char hum[6]; + dtostrf(h, 5, 2, hum); + //Serial.println(hum); + client.publish(TOPIC_T,temp); + client.publish(TOPIC_H,hum); delay(5000); } |