@Tim_G_Tech I found my mistake. I was putting in the wrong value for client ID. Try this code, it will just increment a temp widget.
// This #include statement was automatically added by the Particle IDE.
#include <DS18B20.h>
//DS18B20 ds18b20(D0);
// This #include statement was automatically added by the Particle IDE.
#include <MQTT.h>
void callback(char* topic, byte* payload, unsigned int length);
String username = "";
String password = "";
String clientID = "";
MQTT client("mqtt.mydevices.com", 1883, callback);
// recieve message
void callback(char* topic, byte* payload, unsigned int length) {
char p[length + 1];
memcpy(p, payload, length);
p[length] = NULL;
if (!strcmp(p, "RED"))
RGB.color(255, 0, 0);
else if (!strcmp(p, "GREEN"))
RGB.color(0, 255, 0);
else if (!strcmp(p, "BLUE"))
RGB.color(0, 0, 255);
else
RGB.color(255, 255, 255);
delay(1000);
}
void setup() {
Serial.begin(9600);
delay(5000); // Allow board to settle
client.connect(clientID, username, password);
}
int counter = 0;
void loop() {
counter = counter + 1;
if (client.isConnected()){
Particle.publish("connected");
client.loop();
String mesasge = "temp,f=" + String(counter);
client.publish("v1/" + username + "/things/" + clientID + "/data/1", mesasge);
}
delay(2000);
}