Technologies related to the smart home and home automation. Z-Wave, Wifi and other technologies that can be incorporated into your home, giving insights to your home data and creating energy savings.

MQTT vs Websockets vs HTTP/2: The Best IoT Messaging Protocol?

While doing any sort of development for an Internet of Things (IoT) connected device such as an Arduino, Raspberry Pi, or other embedded platform, the question inevitably comes up as to what is the best messaging protocol to use? Assuming your application can’t use straight up web pages, there are really two viable options at the moment and one up-coming.


MQ Telemetry Transport (MQTT) from IBM is the bad boy of small device messaging. It uses TCP, is lightweight, and has features beneficial to IoT devices. It is mature and there are a lot of client and server implementations, making it easier to develop upon.

MQTT works on a pub/sub architecture. A client subscribes to a channel on a server, and when a server receives new information for that channel, it pushes it out to that device.

Another great feature of MQTT is that you can set a priority or Quality of Service (QoS):

  • 0: The client/server will deliver the message once, with no confirmation required.
  • 1: The client/server will deliver the message at least once, confirmation required.
  • 2: The client/server will deliver the message exactly once by using a handshake process.

Each level uses more bandwidth but will give you varying assurance of deliverability.

With MQTT your application must have a library to talk to the MQTT server and handle publish/subscribe methods.


Now that browser websockets are standardized, they make a very compelling option for reading and writing data to IoT devices. Websockets are the best way to achieve full push/pull communications to a web server, which is not possible over basic HTTP protocol.

Websockets are great if you have a full web client! However, with many IoT devices, it is a lot of overhead which might not even be an option.

Another downside of using Websockets is that you would need to come up with your own protocol for the transmission of data. This isn’t too difficult (for example, using JSON) but does create a non-standard protocol.

MQTT over Websockets

A frequent use of Websockets is to actually use MQTT over Websockets. With this configuration, you can use the Paho JS MQTT client to make the connections and to read/write data. This makes for very easy development, but again you must be able to run the full browser stack on the device, so this can be very limiting. Since it does use MQTT, it may be beneficial to use this for any webpage MQTT reading of data. There is also some configuration to be done in the background to create the proxy between MQTT and Websocket, however there are plenty of services such as HiveMQ to do this for you.


The new HTTP protocol, soon to be seen everywhere, usually a totally different structure than HTTP/1.1. Where HTTP/1 was based on frames/packets, HTTP/2 is a streaming protocol. It supports a few features useful in this situation such as the ability for the client to suspend data streaming, however also has some drawbacks. HTTP/2 was designed to have the client remain connected to the server for the remainder of the browsing session. If using HTTP/2 as a messaging protocol, it would mean leaving this connection open indefinitely. You also miss out on some of the features of MQTT such as QoS. HTTP/2 is so new that some of these features could in theory be added to the protocol and libraries, however it is not yet mature enough to say whether that will happen.

For more discussion on this, check out Can HTTP/2 Replace MQTT from @kellogh.

What’s the Best?

Right now for most applications, I would say MQTT is the best protocol to use for most IoT devices. Since it is so widely adopted, even newer solutions like Websockets support MQTT in some respects so your device will be able to communicate its data effectively to other devices over the internet.

I’m excited to see where HTTP/2 takes us with regards to the Internet of Things. The protocol is better suited for lightweight communication and could definitely be a contender in the future.

Photo courtesy NodeMCU Wikipedia

Aeon Labs Smart Energy Meter (Home Energy Meter)

It has always been a goal of mine to have a ‘smart house’. In my old townhouse, I knew we were going to be moving so I did not take the time to install any of the neat equipment that I’ve been reading about. After purchasing a new home last year, I began researching in earnest – trying to figure out what makes the most sense from a usability and price conscious standpoint.

As a first step I knew I was going to go with Z-Wave. I’ll be going in-depth about this technology at a later date; but for now let’s just say it is a fairly open protocol for creating ‘smart’ devices that communicate with each other. You start off with a Z-wave controller, I ended up purchasing the Aeon Labs DSA02203-ZWUS Z-Wave Z-Stick Series 2 USB Dongle. This allows you to interface your computer with your Z-Wave network. There are many pieces of software that work with this device. I will review some of them at a later time.

Aeon Labs Z-Wave Smart Energy Meter

There was a great deal on the Aeon Labs Smart Energy Meter (Amazon link) for only $30 (US) where the “2nd Generation” version was $90. I thought this would be a great time to jump in and get started with making my house “smart”.

Installing The HEM


Watch the video below for my explanation on how to install the Home Energy Meter (HEM).

If you are not familiar with working with electricity, I would definitely recommend that you hire an electrician to perform this part. For an electrician this install would be very easy and shouldn’t be that expensive.

Essentially, you turn off your main power; install the meter leads around the 2 feeds coming in (if you have 2 phase power, you may also have 3 phase power and need a different unit for that); and then route the two leads out of the panel and into the HEM.

Pairing The HEM To Your Z-Wave Network

To pair the HEM to your Z-Wave network, follow the instructions on your controller. On the HEM you must have the batteries installed for it to pair properly. This threw me at first, since I thought when I plugged USB into the outlet that would be everything it needs. After installing batteries, press the button in the battery compartment to begin the pair process. I then pressed the button on the Z-Wave Stick and it paired without problems.

Next up, you need to add it to your Z-Wave controller software. Depending on what system you have this will be a different process for everyone. For me, this took the most amount of time to configure properly. I ended up using software named Domoticz which runs on an Ubuntu server I already use for serving up media files on my home network and is powered 24/7.

Here are some links with instructions on how to set up on different Z-Wave compatible controllers.

Getting Accurate Results

After getting my controller to recognize the HEM, it was reporting Wattage way higher than I knew my home was using; around 800,000 Watts.

There is a long discussion of this issue on the MiCasaVerde forums. It seemed that I had to do two things to get my meter reporting properly.

The first was to downgrade the firmware. I started off before installing by updating my firmware to the latest version (3.67 at this moment), both on my Z-Wave stick and also the HEM. After reading those forum posts, one user reported downgrading to 3.61 and that solved his issue. I installed HEM firmware version 3.61.


I also had to modify the settings field. I changed “Group 1 Reports” to 12; this is a decimal representation of a binary value which essentially says for it to report Wattage and kWh. I also changed it to report every 10 seconds instead of every 900 seconds. This makes for much nicer data collection.

After getting it all set up and reporting properly, the Aeon Labs Home Energy Meter seems to be working very well. The values are about accurate for my energy usage and I can see current usage at any point in time, as well as the past values. That even includes kWh used per day. With this data, I can reliably say what are the real energy users in my home and proactively fix energy drains before I get hit with high energy bills.

I would highly recommend this energy meter for anyone who is looking to get into the Z-Wave technology and wishes to monitor their whole house energy usage. For a fairly low price (under $75) I was able to start graphing my energy usage.

Buy the Aeon Labs Smart Energy Meter from Amazon

I would love to hear your experiences getting this set up and what controller you used!