Copyright ©

Mongoose OS Forum


How to make a firmware build incl. MQTT Broker?


I am trying to make a build of Mongoose-OS for esp8266-01 that includes a MQTT-Broker. Unluckily with no success. I can`t connect to the ESP on port 1883 with MQTT-Lens.

I tried to incl. following line in the build_vars section:

General build making was successfull though without telling whether the broker started. The standard web page "Welcome to Mongoose OS" shows up, so I know the ESP8266 is in fact running.

Thanks in advance for any help for a bloody beginner ;-)



  • SergeySergey Dublin, Ireland

    Try this:


    ALso, you need to add MQTT server code (see to the firmware manually.

    Can you describe your project please, why do you need MQTT server ?

  • Ok. I'll try. My project is about a garage door, which I check for being open or closed, which i cannot see from inside the flat. The sensor is Adafruit VCNL4010 module read out by an ESP8266, which shall publish the data to a mqtt broker. Another ESP8266 subcribes the data and lets a LED shine green depending on the value. All that more for fun and curiosity. Nice would be the mqtt broker on the subscribing ESP. I'd like to have cheap own private mqtt broker, since i have read, that public broker's data is accessible by everyone.

  • SergeySergey Dublin, Ireland

    Got it, thank you.

    Another option is to let these two esp8266s talk over RPC. You won't need to write any C code for that option.
    An example of the RPC server is:

    which is part of the smart heater example.

  • To include mqtt_broker code to the firmware I changed mos.yml source part and copied Makefile & mqtt_broker.c into the src-directory. I had to to change the #include "../../mongoose.h" to #include "/mongoose-os/mongoose/mongoose.h" since mos told me it couldn`t find such file. But after change another error message appears, which I cannot handle. Build.log says this:

    src/mqtt_broker/mqtt_broker.c: In function 'main':

    src/mqtt_broker/mqtt_broker.c:24:25: error: storage size of 'brk' isn't known
    struct mg_mqtt_broker brk;

    Did I do something wrong to include the source or does the source code have errors?

    I`d rather like to stick to a mqtt solution.

  • SergeySergey Dublin, Ireland

    Well, I don't think it's a good idea to make an MQTT broker out of ESP.

    But anyhow, add

    MG_ENABLE_MQTT_BROKER: 1 to your build_vars

  • Hello Sergey,

    stubborn as I am, I really wanted to get Mongoose MQTT-Broker running on a ESP8266 ESP01-S module. It`s working! Please see here.

    I compiled the mongoose networking library with merged code examples from Cesanta. It has a restriction though: It only allows connection from one MQTT-client. Here I think I could need some help.

  • SergeySergey Dublin, Ireland

    but ... why ? :)

Sign In or Register to comment.