Arduino UNO WiFi to cayenne dash board

Okey, I am starting to figure it out. I have read that even Arduino has problems with this board. I will make wider research.

Thanks

If I had one, I’d sort it out even if we need to bang out our own driver. Looked at buying one, but they cost more than I’m willing to pay for functionality I already have.

Cheers,

Craig

You are right. :slight_smile:

Hello,
I posted a similar question : I also have an Arduino Uno with Integrated Wifi. It connects to the internet without any issue. I tested it succesfully with ThingSpeak.

However, I do not understand how to connect it to cayenne, since cayenne only supports a limoted number of devices unfortunately. Cayenne tries to initialize the Wifi, but this is not necessary with my device (already done). So IMHO the easiest way to connect to the cayenne backend would be to get a URL and post a simple rest message : is it doable ?

Thanks !!

Geoffrey

I don’t think Cayenne has a REST service yet.

Blynk doesn’t support it unless you run it through Caio and use their REST interface. Cayenne is using a subset of current Blynk functionality.

Our best bet is getting the Uno Wifi to talk MQTT as this is fully supported by Cayenne now.

Cheers,

Craig

Hi Craig,
Thanks for your answer.
However I am not sure to udnerstand what you’re suggesting : sorry for asking :wink: With Cayenne I need to choose the device I’m using, and the Uno with Integrated WiFi does not appear in the list. Which device shoukld I choose from the following list ? And how is MQTT going to help, since the issue with the sketches is when I’m trying to initialize Cayenne.
Thanks for your help !!

To be a bit more clear, this is the code I’m using to connect to Cayenne :

and this is what I see on the serial:

[0] MAC: FE-E5-A6-E6-E8-A5
[0] Getting IP…

And it hangs there.

Thanks

Geoffrey

There are two ways currently to connect to Cayenne.

The first way is using the Blynk library to connect to a port. The Blynk library relies on a standardized Wifi Library for the device being connected. The Uno Wifi device’s Wifi library doesn’t work, and the libraries that do work are not compatible with Blynk - unless you use the Caio library and the Blynk REST interface which isn’t supported by Cayenne currently.

The other way is by using the MQTT interface. Cayenne has libraries for that too, but they are not compatible for the above mentioned reasons. However, MQTT is a standard that can be implemented WITHOUT using the Cayenne libraries. I’m sure that we can cobble some code together that uses the Caio library that talks MQTT.

I see you just posted some code, and yes, there are issues with the UnoWifiDevEd library.

Cheers,

Craig

Hello Craig,
I haven’t worked on the issue for some time, but I gave it another try recently, using MQTT this time. unfortunately I got stuck very soon :frowning: Cayenne gives me a 32-characters MQTT Username. With the Arduino-with-built-in-WiFi, the MQTT settings (including MQTT Server, MQTT Username and MQTT password) are specified via a configuration webpage (e.g. opening a chrome webpage specifying the private IP address of the Arduino). Unfortunately the Arduino-with-built-in-WiFi accepts MQTT usernames of max 31 characters :frowning:

I have been told to perform a firmware upgrade of my arduino-with-built-in-wifi, but I’m quite reluctant to do so as it sounds like a very heavy operation for solving such a basic issue. Moreover, a Firmware Upgrade is a very risky operation…

Regards

The firmware upgrade is very painless and quick. It makes the UI a lot more friendly. However, the MQTT option you see there will only allow very basic operations. May or may not be what you’re looking for.

In related news, looks like people are successful in connecting to Blynk. Might be time for me to revisit this board again…

I don’t think anyone has been able to get Uno Wifi up on Cayenne yet in any
way.

I guess I ought to try.

Not much support from Arduino on this board.

Craig

Hello,
I have made some progresses using the PubSubClient library for MQTT from Nick O’Leary, available on Github : GitHub - knolleary/pubsubclient: A client library for the Arduino Ethernet Shield that provides support for MQTT..

My arduino gets rejected by the Cayenne server with an MQTT Return Code 2, i.e. “Connection refused, identifier rejected”.

I’m using the credentials provided on the cayenne webpage.

The sketch is below:

/*
Basic MQTT example

This sketch demonstrates the basic capabilities of the library.
It connects to an MQTT server then:

  • publishes “hello world” to the topic “outTopic”
  • subscribes to the topic “inTopic”, printing out any messages
    it receives. NB - it assumes the received payloads are strings not binary

It will reconnect to the server if the connection is lost using a blocking
reconnect function. See the ‘mqtt_reconnect_nonblocking’ example for how to
achieve the same result without blocking the main loop.

*/

#include <PubSubClient.h>
#include <WiFi.h>

void callback(char* topic, byte* payload, unsigned int length) {
Serial.print(“Message arrived [”);
Serial.print(topic);
Serial.print("] ");
for (int i=0;i<length;i++) {
Serial.print((char)payload[i]);
}
Serial.println();
}
const char* mqtt_server = “mqtt.mydevices.com”;

WiFiClient ethClient;
PubSubClient client(ethClient);

void reconnect() {
// Loop until we’re reconnected
while (!client.connected()) {
Serial.print(“Attempting MQTT connection…”);
// Attempt to connect
//Client ID, MQTT Username, MQTT Password
if (client.connect(“a5a72834-3244-11e7-85a7-c34806d4e04d”,“ae8d97b0-f7680-11e6-81d7-ad79ee868075”,“f6fb0e6176dbb2527617a2333f14859b3e9fdaf8”)) {
Serial.println(“connected”);
// Once connected, publish an announcement…
client.publish(“outTopic”,“hello world”);
// … and resubscribe
client.subscribe(“inTopic”);
} else {
Serial.print(“failed, rc=”);
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}

void setup()
{
Serial.begin(9600);

client.setServer(mqtt_server, 1883);
client.setCallback(callback);

// Allow the hardware to sort itself out
delay(1500);
}

void loop()
{
if (!client.connected()) {
reconnect();
}
client.loop();
}

I get the following error:
Attempting MQTT connection…failed, rc=-2 try again in 5 seconds

Any help identifying why my device gets rejected would be appreciated :wink:

Thanks

Can you post the full output from the serial monitor?

there is nothing more than what I posted :

Attempting MQTT connection…failed, rc=-2 try again in 5 seconds
Attempting MQTT connection…failed, rc=-2 try again in 5 seconds
Attempting MQTT connection…failed, rc=-2 try again in 5 seconds
Attempting MQTT connection…failed, rc=-2 try again in 5 seconds
Attempting MQTT connection…failed, rc=-2 try again in 5 seconds

etc…

Do you have port 1883 open on your router/firewall?

One of the first things I tried. Couldn’t get Nick’s PubSub working with Cayenne.

It’s on my list of things to look at.

Cheers,

Craig

Duh…this is for the uno wifi, I didn’t scroll up. Yes that library will not work unless you flash the WiFi Link firmware.

Hello, yes the port is open. The Cayenne MQTT Server rejects the connection request, hence it receives the request

Not sure why you say “it will not work”. My sketch based on Nick’s pubSub library definitely compiles on the Arduino with built-in WiFi. According to Nick, his library is not built for a specific hardware.

The Cayenne MQTT Server receives the connection request, and rejects it. I’m trying to figure out why. One of the ways to debug would be to attempts an MQTT connection to another MQTT Server. But I could not find any “online test” MQTT server : any advise would be appreciated.
Thanks

1 Like

I found this video as a problem solver, This may help you. All MQTT Errors explained very well and Suggester Different troubleshooting techniques [Solved] Attempting MQTT connection... Failed. rc=-1 or rc=-2 or rc=-4, try again in 5 seconds - YouTube