#include <UIPEthernet.h>
#include "PubSubClient.h"
#define CLIENT_ID "BoilerRoom"
#define INTERVAL 15000 // 15 sec delay between publishing
uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
EthernetClient ethClient;
PubSubClient mqttClient;
long previousMillis;
void setup() {
// setup serial communication
Serial.begin(9600);
// setup ethernet communication using DHCP
if(Ethernet.begin(mac) == 0) {
Serial.println(F("Ethernet configuration using DHCP failed"));
for(;;);
}
// setup mqtt client
mqttClient.setClient(ethClient);
mqttClient.setServer("192.168.0.222",1883);
Serial.println(F("MQTT client configured"));
previousMillis = millis();
}
void loop() {
// check interval
if(millis() - previousMillis > INTERVAL) {
sendData();
previousMillis = millis();
}
mqttClient.loop();
}
void sendData() {
char msgBuffer[20];
if(mqttClient.connect(CLIENT_ID)) {
mqttClient.publish("boilerTemp", "5000");
Serial.println(F("Attempted to send temp"));
}else{
Serial.println(F("Failed"));
}
} if(mqttClient.connect(CLIENT_ID)) { if(mqttClient.connect(CLIENT_ID, "myUsername", "myPassword")) {--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.
--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.
--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.
an email to mqtt+unsubscribe@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.
Links:
------
[1] https://stackoverflow.com/q/44310817/1156096
[2] https://groups.google.com/group/mqtt
[3] https://groups.google.com/d/optout
--
To learn more about MQTT please visit http://mqtt.org
--- You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.