Espruino WiFi as the MQTT Broker

Posted on
  • Can the espruino (WiFi) in this case, act as the MQTT broker?

    I've got Device A hooked up to a GPS sensor and i'd like to send regular updates to listening devices B...D.

    I can and have been using Websockets, with Device A running a server, but wanted to try use MQTT instead as it sounds like it's better suited for this sort of simple comms, with Device A being the broker?

    All the examples i can find seem to have the Espruino connecting to a broker elsewhere, and then pub/subbing, unless i'm misreading it?

  • Yes, it could act as an MQTT broker, but you'd basically be implementing everything yourself as I don't believe anyone has done it on Espruino before. The existing client library is a good start:Ā­/blob/master/modules/MQTT.js - you just have to handle pub/sub and maintain lists of subscribed topics for each connected client.

    It's not that bad (to implement enough of it work fine - you could spend ages trying to implement the whole spec) and could be quite a fun project. If you do try and do it, it'd be great if you could share what you have - it might be quite useful for other Espruino users.

    One thing to note is that Espruino WiFi has a maximum of 5 sockets open at a time - so that's only 5 clients. It might restrict you a bit.

  • Ah ok, might be a sockets for the immediate future and a look into the MQTT a little later.

    Thanks very usefull to know : )

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Espruino WiFi as the MQTT Broker

Posted by Avatar for ct5845 @ct5845