|
|
@@ -93,9 +93,10 @@ void setup() { |
|
|
|
mqttbroker.fromString("192.168.1.127"); |
|
|
|
Serial.println(mqttbroker); |
|
|
|
} |
|
|
|
bme.read(Pressure, Temperatur, Humidity); |
|
|
|
|
|
|
|
// MQTT |
|
|
|
MQTTclient.setServer(mqttbroker, 11884); |
|
|
|
MQTTclient.setServer(mqttbroker, 1883); |
|
|
|
MQTTclient.setCallback(MQTTcallback); |
|
|
|
|
|
|
|
//Serial leeren |
|
|
@@ -114,7 +115,7 @@ void loop() { |
|
|
|
|
|
|
|
//MQTT |
|
|
|
if (!MQTTclient.connected()) { |
|
|
|
MQTTclient.connect("Arduino1"); |
|
|
|
MQTTclient.connect("Arduino","loxberry","OSVL0AMqISFXgr5g"); |
|
|
|
Serial.print("MQTT Client state:"); |
|
|
|
Serial.println(MQTTclient.state()); |
|
|
|
// Abonieren von Nachrichten mit dem angegebenen Topic |
|
|
@@ -122,11 +123,15 @@ void loop() { |
|
|
|
Serial.println("connected to MQTT"); |
|
|
|
} |
|
|
|
temp.toCharArray(buff,temp.length()); |
|
|
|
MQTTclient.publish("/Stall/Temperatur", buff); |
|
|
|
MQTTclient.publish("Arduino/Stall/Temperatur", buff); |
|
|
|
press.toCharArray(buff,press.length()); |
|
|
|
MQTTclient.publish("/Stall/Pressure", buff); |
|
|
|
MQTTclient.publish("Arduino/Stall/Pressure", buff); |
|
|
|
hum.toCharArray(buff,hum.length()); |
|
|
|
MQTTclient.publish("/Stall/Humidity", buff); |
|
|
|
MQTTclient.publish("Arduino/Stall/Humidity", buff); |
|
|
|
snprintf(msg, 50, "%ld", millis()); |
|
|
|
Serial.println("Publish message: "); |
|
|
|
Serial.println(msg); |
|
|
|
MQTTclient.publish("Arduino/Stall/data/Alive", msg); |
|
|
|
|
|
|
|
// MQTTclient.loop(); // Schleife für MQTT |
|
|
|
|
|
|
@@ -145,10 +150,7 @@ void loop() { |
|
|
|
} |
|
|
|
clearAll(); |
|
|
|
|
|
|
|
snprintf(msg, 50, "Alive since %ld milliseconds", millis()); |
|
|
|
Serial.println("Publish message: "); |
|
|
|
Serial.println(msg); |
|
|
|
MQTTclient.publish("/home/data", msg); |
|
|
|
|
|
|
|
|
|
|
|
// listen for incoming clients |
|
|
|
EthernetClient client = server.available(); |
|
|
|