Hello! Once the arduino has been modified with the MQTT library, it still seems to connect for a short time and permanently lose the connection soon after.
Also today I can not add any actuator to a new console rpi3, during the procedure, after choosing INTEGRATED GPIO, it does not give me the possibility to add the actuator. Tips?
#define CAYENNE_DEBUG
see in your serial monitor what is happening.
Iâm sorry but the connection is via serialUSB, activating the DEBUG would fail immediately
So,seem being some problems with mqtt libraries and arduino serial connection via rpi3. I installed a new arduino with original sketch but, after the first connection, system goes offline. On my rpi terminal i can see that socat is still working and transferring.
any suggestions?
Would you mind posting your code @davide.azzali?
~benny
Benny, I am 3 weeks from home and depend on Cayenne to control/monitor my home in Vermont. Suddenly my system is offline saying I need toi update to MQQT AT HOME. PLEASE help me temporarily regain control. Itâs COLD up North!
Terry King terry@terryking.us
- Cayenne
Hi @terry1,
Donât worry, your device was not taken offline. Weâre working to deploy a fix that will not keep that pop-up always appearing. Give us 24 hours to make some changes here. Youâll still have access to your Arduino, we have not cut anythinig off. Iâll check back in tomorrow!
~benny
Hello Benny,
THANKS! For your quick and reassuring email!
Iâm sure you understand about the importance of reliability of Cayenne
applications that control buildings.
I write http://ArduinoInfo.Info and plan to show new examples using the
MQQT interface.
Meanwhile we took 4 weeks off to travel from Vermont to the South of USA
and Makerfaires and for âvacationâ. Our Log Cabin back in Vermont is
monitored and controlled by the Cayenne application. We depend on the
option of activating backup electrical heat if our furnace fails.
So we are a little nervous!
Regards, Terry King
âŚIn the Woods in Vermont USA
terry@yourduino.com
-The One who Dies with the most Parts LOSES. What do you need??
ok!
iâve changed type of connection and hardware to⌠arduino mega connected via ethernet
now i can see millis value on channel 0 but when i add a relay switch it remain unreachableâŚ
hereâs the code:
#define CAYENNE_DEBUG // Uncomment to show debug messages
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <CayenneMQTTEthernet.h>
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = âxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxâ;
char password = âxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxâ;
char clientID = âxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxâ;
//const int VIRTUAL_CHANNEL = 4;
//const int ACTUATOR_PIN = 4;
void setup() {
Serial.begin(9600);
pinMode(4, OUTPUT);
Cayenne.begin(username, password, clientID);
}
void loop() {
Cayenne.loop();
}
// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
Cayenne.virtualWrite(0, millis());
// Some examples of other functions you can use to send data.
//Cayenne.celsiusWrite(1, 22.0);
//Cayenne.luxWrite(2, 700);
//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
}
// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG(âChannel %u, value %sâ, request.channel, getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(âError messageâ);
}
CAYENNE_IN(4)
{
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 0) {
digitalWrite(4, HIGH);
}
else {
digitalWrite(4, LOW);
}
}
what am I doing wrong?
did you add a custom button widget?
on the dashboard?
yes
i add a relay switch and modified the sketch. right now iâve tried to add a custom widget and changed my sketch to
CAYENNE_IN(VIRTUAL_CHANNEL)
{
int value = getValue.asInt();
CAYENNE_LOG(âChannel %d, pin %d, value %dâ, VIRTUAL_CHANNEL, ACTUATOR_PIN, value);
// Write the value received to the digital pin.
digitalWrite(ACTUATOR_PIN, value);
}
but still remain unreachableâŚ
add a custom button widget with channel 1 and upload this code with your MQTT credential. open serial monitor and post the output of the serial monitor if you get any error.
// This example shows how to connect to Cayenne using an ESP8266 and send/receive sample data.
// Make sure you install the ESP8266 Board Package via the Arduino IDE Board Manager and select the correct ESP8266 board before compiling.
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
// WiFi network info.
char ssid[] = "ssid";
char wifiPassword[] = "wifiPassword";
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "MQTT_USERNAME";
char password[] = "MQTT_PASSWORD";
char clientID[] = "CLIENT_ID";
unsigned long lastMillis = 0;
void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}
void loop() {
Cayenne.loop();
//Publish data every 10 seconds (10000 milliseconds). Change this value to publish at a different interval.
if (millis() - lastMillis > 10000) {
lastMillis = millis();
//Write data to Cayenne here. This example just sends the current uptime in milliseconds.
Cayenne.virtualWrite(0, lastMillis);
}
}
//Default function for processing actuator commands from the Cayenne Dashboard.
//You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN(1)
{
int x = getValue.asInt();
Serial.println(x);
}
iâve added a button widget (not custom);
modified code to
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTEthernet.h>
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = âxxxxxxxxxxxxxxxxxxxxxxxxâ;
char password = âxxxxxxxxxxxxxxxxxxxxxxxxxxxâ;
char clientID = âxxxxxxxxxxxxxxxxxxxâ;
unsigned long lastMillis = 0;
void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID);
}
void loop() {
Cayenne.loop();
//Publish data every 10 seconds (10000 milliseconds). Change this value to publish at a different interval.
if (millis() - lastMillis > 10000) {
lastMillis = millis();
//Write data to Cayenne here. This example just sends the current uptime in milliseconds.
Cayenne.virtualWrite(0, lastMillis);
}
}
//Default function for processing actuator commands from the Cayenne Dashboard.
//You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN(1)
{
int x = getValue.asInt();
Serial.println(x);
}
and here is the output:
[0] MAC: FE-32-E7-89-77-F9
[4519] IP: 192.168.1.78
[4520] Connecting to mqtt.mydevices.com:1883
[5100] Connected
[5235] Publish: topic 4, channel 65534, value Arduino Mega, subkey , key
[5248] Publish: topic 6, channel 65534, value ATmega2560, subkey , key
[5324] Publish: topic 7, channel 65534, value 16000000, subkey , key
[5398] Publish: topic 5, channel 65534, value 1.1.0, subkey , key
[5469] Publish: topic 8, channel 65534, value W5100, subkey , key
[10562] Publish: topic 1, channel 0, value 10562, subkey , key
[16595] Connection ok
[20616] Publish: topic 1, channel 0, value 20616, subkey , key
[26649] Connection ok
[30670] Publish: topic 1, channel 0, value 30669, subkey , key
[36703] Connection ok
[40724] Publish: topic 1, channel 0, value 40724, subkey , key
[46757] Connection ok
[50778] Publish: topic 1, channel 0, value 50778, subkey , key
[56811] Connection ok
[60831] Publish: topic 1, channel 0, value 60831, subkey , key
[66866] Connection ok
[70887] Publish: topic 1, channel 0, value 70887, subkey , key
[76920] Connection ok
[80941] Publish: topic 1, channel 0, value 80941, subkey , key
[86974] Connection ok
[90995] Publish: topic 1, channel 0, value 90994, subkey , key
[97028] Connection ok
[101049] Publish: topic 1, channel 0, value 101049, subkey , key
[107083] Connection ok
[111104] Publish: topic 1, channel 0, value 111104, subkey , key
[117139] Connection ok
button is still unreachable
Iâd suggest Cayenne to work closely with Terry King who is a well recognized Guru especially in network matters.
Iâd just love a good working code example of UNO / ESP to Cayenne itâs been bugging me for days. Perhaps all my problems of the last week should be put on the back burner until this gets resolved.
In the meantime Iâm sure I can speak for all users who appreciate the free access to Cayenne
Cheers
please use a custom widget and see if it works. as the serial monitor shows connection ok and it should be able to add a custom button widget.
can you try by adding a new device. go to add new > bring your own thing , this will give you MQTT credential. copy in the code i gave above and try adding a custom widget.