MQTT: MQ Telemetry Transport

I recently learned about MQTT ( a light weight sensor connectivity protocol. Played a bit with it and it looks really cool. The guy who invented the protocol uses it to monitor his house (like way before anyone else) and has a nice presentation (but a bit outdated) about it on Slideshare (

It's basically a message broker with some publishers and subscribers. Mosquitto ( is an open source implementation of the protocol.

It looks like MQTT is built for things like Flukso sensors so I thought it would be nice to bring up the topic here. I am planning to look at it and see what cool things one can do combining Flukso and Mosquitto but maybe this post can help someone developer who wants to hack something together.

Bart, did you ever consider MQTT for Flukso?

icarus75's picture

What would MQTT, or any other pub-sub architecture for that matter, allow you to do that's not possible with the existing server & FLM RESTful API? Do you have a specific use case in mind?

sem's picture

I read your presentation about MQTT for flukso in the future.
Is it planned to included in for current v2 device as firmware upgrade or it would only be available for new devices?

icarus75's picture

I'm still experimenting with MQTT on the FLM. But it's looking good so far. If we decide to make MQTT a central part of the FLM architecture, it will be made available as a firmware upgrade.

How would you use MQTT on the FLM?

sem's picture

I like to integrate it with monitoring I have on my linux server, so I can send some event based notifications in case of abnormal consumption etc.
I don't like http pull architecture very much. It's just keep my low power server very busy . If I can have something lighter , would be nice

Do you have somewhere a code base available to build test firmware ? or is it not ready for beta just yet ?

icarus75's picture

Not yet. It's all quite hackery at the moment. But I'll honk when it's ready for beta.

jrbenito's picture

Hi Icarus and SEM,

Just food for thoughts:

MQTT seems to be the protocol of choice of and it is very promise to easyly integrate and scale things around. Also based on measurements presented by article above it seems a very nice choice for publish FLM in a green fashion way. :D

Best regards,

jrbenito's picture


One more thing: At blog post "R223 release notes" you informed the MQTT topics for Flukso are:

/sensor/xyz/guage and /sensor/xyz/pulse

However, the second is not working; the correct topic is /sensor/xyz/counter as below debug shows:

Received PUBLISH (d0, q0, r0, m0, '/sensor/49cfd3fdc846ba52a2aadf245fb18ea0/gauge'


icarus75's picture

You're right about the topic being /sensor/xyz/counter. I've just updated the blog post accordingly.


gebhardm's picture

Bart, could you also update the manual accordingly, please? It's still the March, thus pre-223 version.
Thanks in advance and best regards

patlem's picture

Might be a good idea to tell the guys at that the Flukso is now fully MQTT enabled, so that they can add it to their list of "Things":


gebhardm's picture

Cool stuff! I just succeeded in getting sensor data from my FLM using MQTT - for all who are also interested, it's fairly simple:

  1. Install a MQTT client on your computer - use for example
  2. Having done that, you have a MQTT client, for example mosquitto_sub from
  3. Call your FLM using the command line: mosquitto_sub -h "your FLM's local IP address" -p 1883 -v -t /sensor/# - for example: mosquitto_sub -h -p 1883 -v -t /sensor/#
  4. The # denotes a wildcard that will show all your sensors' topics, so gauge and counter on each sensor-ID, -v is used to show which sensor sent what data...
  5. Enjoy!

A very nice intro on setting up mosquitto on a RasPi is provided by Jan-Piet Mens at - so the next step is sending all sensor readings with a Python script into an SQL database, like done via the REST-API by

To quote Hannibal Smith "I love it when a plan comes together" :-)

fablab-leuven's picture

I've recently started a project called dasling, which might be of help if you want to interface an FLM via MQTT to a database. Project Dasling is a MQTT-server with a Front-End for easy administration, and a database for storing the timestamp/values.

Details on dasling:
Details on the FLM source modifications:

If you experience difficulties setting it up, I'd be glad to help out:

icarus75's picture

@patlem You might want to reload the things page.

sem's picture

Did you try to use MQTT with solar sensors?
I wanted to use gauge readings to display solar performance but I have small issue . After solar panels are switch at night i still have previous non zero reading from the topic. Zero never comes out.
How do you workaround this ?

icarus75's picture

Software pulses will only be generated when at least 1Wh of energy has been consumed/produced. Since your PV panels do not generate any power at night, no software pulses will be generated. Power is calculated by dividing the energy content of a pulse by the time elapsed between two consecutive pulses. You could read out the timestamp of the last pulse that was generated via MQTT and calculate the power if a new pulse were to occur 'now'. If this calculated power is very low, e.g. < 1W, pad the readings with 0's.

sem's picture

I think I'm missing something
I have solar grid connected via pulse port
What you are saying is that MQTT gauge packet would only be send when there is reading from the pulse producer ? So it's not real gauge . Do I understand it correctly ? I'm probably just get confused with terminology
thanks a lot

icarus75's picture

Well, it is a 'real' gauge since it indicates instant consumption. OTOH we cannot just invent sensor data when no pulses are coming in. Then again, with the approach indicated above, and with knowledge of sunset/sunrise times, you should be able to let the gauge value drop to zero when applicable.

gebhardm's picture

For gauge display see also (now my FLM panel with dynamic sensor detection)

rs's picture

Installed the MQTT windows client, the testdata from are nicely scrolling over the screen but I did not got anything out of the FLM02B (V232).

My command : mosquitto_sub -h -p 1883 -v -t /sensor/2cc04f3227c3e75e5326974b8faeb2ef

where is the local ip of the FLM and 2cc04f3227c3e75e5326974b8faeb2ef is an active pulse sensor on port 4.

wifi is open at the firewall and I'm in the same network.

When I aks for the syslog after the request I've got an error :
/usr/lib/lua/luci/sauth.lua:80: Security Exception: Session ID is invalid! stack traceback: [C]: in function 'assert' /usr/lib/lua/luci/sauth.lua:80: in function 'read' /usr/lib/lua/luci/controller/rpc.lua:28: in function 'authen' /usr/lib/lua/luci/dispatcher.lua:370: in function 'dispatch' /usr/lib/lua/luci/dispatcher.lua:195: in function
and I have to login again.

My goal is to export (or import) the data from the sensors to my QNAP NAS and present it on a web page on the built-in internet-server.
The last part should not give any problems for me but to get the data in the database is not too easy.
Somehow it seems to be that all the examples have to fail. (No I'm not anyhow related to Murphy)

Regards, Robert.

rs's picture

Another subject:

Is there anyone who succeeded to connect the FLM to Exosite ?
Somehow the connection to pvoutput will not work for me also .... (murphy again ?)


gebhardm's picture

@rs you have to "wildcard" the sensor as there are subtopics gauge and counter --> mosquitto_sub -h -p 1883 -v -t /sensor/2cc04f3227c3e75e5326974b8faeb2ef/#

rs's picture

Thanks @Gebhardm, It's finally responding


rs's picture

Many thanks for your response, I discovered this already but somehow the Python module won't install on my NAS.

Therefore I used the solution of PeterJ for the Synology who's working on the FLM side but gives still an error on the database side : No direct access allowed!

Still working on it.