@shramik_salgaonkar I tried to connect my Particle but it’s not happening. Do you know anyone that has one in the Cayenne team? I’m not sure how to tell why it’s not working. There are no errors that I can see, it just doesn’t connect. Here is the code I tried:
// 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);
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("cayenne", "username", "password");
//Particle.publish("setup finished");
}
int counter = 0;
void loop() {
//Particle.publish("loop");
counter = counter++;
if (client.isConnected()){
Particle.publish("connected");
client.loop();
String mesasge = "temp,f=" + counter;
client.publish("v1/username/things/clientid/data/1", mesasge);
}
delay(1000);
}
Guess I’ll try to connect to a local MQTT server to see if it’s a problem with Cayenne, the library, or the device. The photon is a cool easy to use device, I think it would be wise to get official support on it. @jburhenn
The (unsupported) library that someone ingenuously forked from Blynk to allow Particle to work with Cayenne no longer works. Ever since having to go MQTT. I have spent hours trying to use the Arduino-MQTT library for Cayenne and make it work with Particle and so far no luck. I have made an official request for MyDevices to get together with Particle and work on Integration. With Particle releasing thier new Mesh products I think there is going to be more of a demand for Cayenne users wanting to use Particle devices with their projects. I have a number of projects I have had to switch up to using a NodeMCU instead of Photon for this reason. I love the Photon!
I figured it was. I know you guys have a heavy workload already. Was just throwing something out there. I will be happy to do some beta testing when that time comes. Keep up the good work!
@Tim_G_Tech I set up a local MQTT server to mimic the Cayenne MQTT server (same user/pass/clientID) and I’m able to send data locally so I don’t believe it’s the device or MQTT library. I can even see that the photon is connecting (or it at least thinks it is) to the Cayenne server but as soon as it sends any data it’s being disconnected and the last data received on the dashboard doesn’t update. I pinged the slack group, waiting to hear back what’s going on at the server.
I took a loot at this MQTT library and compared with the Cayenne-Arduino-MQTT library downloaded from GitHub. It looks like there is a ton of stuff missing. Mostly a lot of other supporting libraries to make it all work properly.
I may attempt to fork it if I can make the time.
Here’s the link to the GitHub repo: GitHub - myDevicesIoT/Cayenne-MQTT-Arduino: Cayenne MQTT Arduino Library
I can confirm it does work. I used @adam’s example with mine and was ale to send data to the dashboard. So kudos to @adam! Now what I need is to be able to send actuator commands to the device. I toyed around with client.subscribe for a bit and didn’t have any luck. Just trying to use an on/off widget to tun an LED on or off.