summaryrefslogtreecommitdiff
path: root/arduino/data_collect
diff options
context:
space:
mode:
authorElena of Valhalla'' Grandi <valhalla@trueelena.org>2015-05-03 20:14:02 +0200
committerElena of Valhalla'' Grandi <valhalla@trueelena.org>2015-05-03 20:14:02 +0200
commit2e49dcff5f0615ff7f166382cf6c1038c8643a60 (patch)
tree55a3c95d7b1385d937e89db02549beef36333767 /arduino/data_collect
parent71d0f75ef6af70b4f8b7b72f777ef54e14d5df21 (diff)
Fix client.connect and publish also humidityHEADmaster
Diffstat (limited to 'arduino/data_collect')
-rw-r--r--arduino/data_collect/data_collect.ino22
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);
}