Hi All,
I need to troubleshoot MQTT on an Argon device. I'm using a local MQTT broker on a Raspberry Pi, that is working fine with other clients (on a Mac, an ESP32, and an iphone), but will not maintain communication with an Argon.
The other clients in the network will work for over 24 hours, no problem (which is long enough), but the Argon can't receive or publish a message after just a few minutes (but it works fine up until the time that it doesn't...).
The code is below:
I'd appreciate any help in understanding what I need to do to view logs, etc to try to understand why this unit doesn't keep a connection when other devices do.
btw - I put in a Particle.disconnect() at the end of setup because the internet is intermittent, and I want that out of the equation.
The code is a slightly modified version of mqtttest.ino example from the library.
#include "MQTT.h" void callback(char* topic, byte* payload, unsigned int length); /** * if want to use IP address, * byte server[] = { XXX,XXX,XXX,XXX }; * MQTT client(server, 1883, callback); * want to use domain name, * exp) iot.eclipse.org is Eclipse Open MQTT Broker: https://iot.eclipse.org/getting-started * MQTT client("mqtt.eclipse.org", 1883, callback); **/ byte server[] = { 10,240,140,72 }; MQTT client(server, 1883, callback); // recieve message void callback(char* topic, byte* payload, unsigned int length) { char p[length + 1]; memcpy(p, payload, length); p[length] = NULL; RGB.control(true); 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); RGB.control(false); } void setup() { // connect to the server client.connect("sparkclient"); // publish/subscribe if (client.isConnected()) { client.publish("sensorHeartbeat","hello world"); client.subscribe("checkIn"); } Particle.disconnect(); } void loop() { if (client.isConnected()) client.loop(); }