How can I use the Xively MQTT server with Arduino?

I am trying to connect my Arduino with ethernet to Xively using my MQTT server, but I have authentication problems. When I do client.connect("arduinoMQTT") , I get a crash. I tried passing my API key as a username by running client.connect("arduinoMQTT", "APIKEY") , but then the code will not compile.

How can I authenticate to the Xively MQTT server on arduino.

+4
source share
1 answer

If you check the api docs for the Arduino MQTT client, you will see that you need to specify the password argument, as well as the username. When connecting to Xively, you use your api key as the username and null for the password:

 client.connect("arduinoMQTT", "APIKEY",null) 

You should probably use something more unique than arduinoMQTT as a client identifier.

+6
source

Source: https://habr.com/ru/post/1489132/


All Articles