Electron + MQTT

Got someone MQTT on the Electron running? It seems it can’t connect to my broker. The same code runs on the Photon and RedBear Duo without a problem.
Ok the problem seems to be related to the usage of UDP where MQTT needs TCP to run properly.
So the question is, is there a MQTT-S library available for the Electron because MQTT-S should also work via UDP.

According to this post by @zack the Electron can do TCPClient …

In this example also uses TCP client.

So I’ve tried the MQTT library from github (https://github.com/hirotakaster/MQTT) which works fine with the photon and which makes use of the TCPClient but it doesn’t connect to any broker, I’ve tested public brokers and also my own one without any success. Spark.publish works without any problem on my Electron.

For the record, we tested MQTT PubSubClient with an Electron loaded with v0.5.0-rc.1 today, and it works.

1 Like

@jpmens That’s great news! This was not supported earlier. There is an official (I think) Arduino MQTT library as well. I use it with the Photon and it works just as well as the PubSubClient. I haven’t had the time to upgrade my Electron to v0.5.0-rc.1.

If you have the time and don’t mind trying it, could you please try the MQTT library from Arduino? You can find it here
Arduino-MQTT - An MQTT library for Arduino based on the Eclipse Paho projects

MQTT and v0.5.0-rc.1 work with the electron 3G model - however the 2G model does not.

We did our tests with the 2G model; works fine.

I’ve been playing around with MQTT and Photon to get ready for the Electron… I just got the Electron and flashed, serial, right out of the box the same code successfully working with the Photon. Went into Safe Mode… updated firmware, to v0.5. 1f… reflashed, serial, works good!
Has any analysis been done with using MQTT compared to CoAP messaging?

1 Like

Could you post the code for a simple MQTT topic post?
Want to try on an Electron.

Have a look at my posts …I’ve posted two mqtt … variables that work