MQTT on ESP8266

3,645 views
Skip to first unread message

Philippe Gregoire

unread,
Nov 26, 2014, 4:17:47 AM11/26/14
to mq...@googlegroups.com
Is there any initiative to integrate MQTT client in the ESP8266 firmware?

[ESP8266 is a ultra low-cost (<$4) Wifi-on-a-chip solution, sporting a 32bit mpu with upgradable firmware and a public C sdk. You talk to it using UART Tx/Rx, and default f/w has a set of AT-style commands to drive the admin and use TCP/IP stack. It has free GPIO for use (most common board exposes 2 on its connector)]

Someone has posted a replacement firmware that exposes LUA scripting instead of AT, I'm wondering if the MQTT LUA client could be used on the chip. This would be an excellent IoT base for autonomous sensors, with or without a companion mpu to drive I/Os.

Stefano Costa

unread,
Nov 26, 2014, 5:13:08 AM11/26/14
to mq...@googlegroups.com
On 26/11/2014 10:17, Philippe Gregoire wrote:
> [ESP8266 is a ultra low-cost (<$4) Wifi-on-a-chip solution, sporting a
> 32bit mpu with upgradable firmware and a public C sdk. You talk to it

Interesting Philippe, but can't find reference to the public C sdk, where?

Stefano

Kyle Gordon

unread,
Dec 10, 2014, 9:03:33 AM12/10/14
to mq...@googlegroups.com
Their SDK appears to be recently made available on https://github.com/espressif . They also used http://bbs.espressif.com/viewforum.php?f=5 for a while.
> --
> To learn more about MQTT please visit http://mqtt.org
> --- You received this message because you are subscribed to the Google Groups "MQTT" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
> To post to this group, send email to mq...@googlegroups.com.
> Visit this group at http://groups.google.com/group/mqtt.
> For more options, visit https://groups.google.com/d/optout.

Kyle Gordon

unread,
Dec 10, 2014, 9:27:09 AM12/10/14
to mq...@googlegroups.com
Replying to myself…

Further to that, micropython is now ported to the ESP8266, so that may be a good candidate for easy adoption of MQTT support.

The only downside is that they’re still figuring out how to make wifi work on it. Looks promising though!

http://hackaday.com/2014/11/29/micro-python-now-runs-on-the-esp8266-contributors-wanted-to-get-wifi-working/

Stefano Costa

unread,
Dec 10, 2014, 10:02:04 AM12/10/14
to mq...@googlegroups.com, ManeraBW Riccardo
Thanks a lot! Looks very interesting.


S

--
  Stefano Costa
  R&D, Managing Director
  Skype stefanocosta.bluewind
  Twitter @stefanobluewind

Philippe Gregoire

unread,
Dec 12, 2014, 3:39:54 AM12/12/14
to mq...@googlegroups.com
Thanks Kyle for posting the links, I've been busy trying out the chip and haven't taken time to follow-up.

My early impressions is that LUA is probably the easiest way to go, I could flash the LUA F/W yesterday and that seems quite versatile, more than the official AT command set.
LUA simulates a filesystem on the flash, and allows to store scripts, with a special script that runs upon boot. If you couple this with an external MCU that handles sensors &actuators, it can make a very low-cost/low footprint IoT device.
LUA support is provided by NodeMCU, links to GitHub at http://nodemcu.com/index_en.html. I used their flasher which so far has been the most reliable for me, quite neat UI, which also generates a set of MAC addresses, and their flashcodes (not sure what that would be for, tough...).

Another way would be to port the MQTT client C code, maybe extend the AT command set, i.e. AT+MQTTSUB="topic" AT+MQTTPUB="topic",len,payload, incoming subs would come the same way as incoming IP traffic, they currently have a +IPD output, could have a +MQTTD on the same principle.

For a summary of H/W and some S/W links, you may want to check this wiki out too: http://hackerspace.pbworks.com/w/page/88183850/ESP8266

PhG.

Philippe Gregoire

unread,
Dec 12, 2014, 4:09:10 AM12/12/14
to mq...@googlegroups.com
Forgot to mention that:
1) ESP8266's maker is Espressif, product page at https://espressif.com/en/products/esp8266/, and their official support channel is a 'BBS' at http://bbs.espressif.com/ (re Kyle's post)
2) There's a quite active community-supported forum at http://www.esp8266.com/, with a specific section about LUA support.

There are already people having built a sensor which sends data to the cloud through HTTP, such as http://www.instructables.com/id/ESP8266-Wifi-Temperature-Logger. Using MQTT for that would allow more flexibility (fire-and-forget for publish, and actuator integration through subscribe, which is more awkward to do with HTTP polling)

PhG

Marcel Verpaalen

unread,
Jan 2, 2015, 10:21:27 AM1/2/15
to mq...@googlegroups.com
Hi Philippe,

Seems indeed a native client has been developed. see here : http://www.esp8266.com/viewtopic.php?f=6&t=1031
There are other attempts as well, but not yet functional e.g. https://github.com/soynerdito/ESP8266-MQTT

I'm getting my ESP8266 shortly, , aim to get it running mqtt soon as well.

Op woensdag 26 november 2014 10:17:47 UTC+1 schreef Philippe Gregoire:

Philippe Gregoire

unread,
Feb 3, 2015, 8:48:24 AM2/3/15
to mq...@googlegroups.com
Hello all,

So, the latest LUA firmware for the ESP from last week-end has MQTT integrated now (LUA bindings for the aforementioned MQTT port project)
This makes sending sensor readings to platforms such as IOTF very simple indeed.
This latest LUA brew also has support for popular Temp/H%/barometric sensors DS18B20, DHT11, SHT2x in LUA source (script) form.
PhG

Stefano Costa

unread,
Feb 3, 2015, 8:55:11 AM2/3/15
to mq...@googlegroups.com
Hi Philippe good news! 

What about auth/encryption? Is TLS supported already? Or user/password only?

Thanks!
--
  Stefano Costa
  Twitter @stefanobluewind
 

--

nemik

unread,
Feb 5, 2015, 9:30:48 AM2/5/15
to mq...@googlegroups.com
It's not Lua, but this C-based project https://github.com/tuanpmt/esp_mqtt support TLS and user/password. According to http://tech.scargill.net/esp8266-and-mqtt-exciting-times/ it recently became pretty stable for use. I'm waiting for my samples to arrive to start flashing this. Compiling the toolchain and firmware was pretty easy.

Paul Fremantle

unread,
Jul 21, 2016, 3:35:01 AM7/21/16
to mq...@googlegroups.com
By the way, I've had a very easy time getting MQTTS working on ESP8266, thanks to the great ESP8266 TLS support from Ivan Grokhotkov.

I used Nicholas O'Leary's PubSubClient and just configured it with a WifiClientSecure instead of WifiClient. That was all I had to do.

Once the mqtt client is connected you can do a wifiClientSecure.verify to validate the fingerprint of the server certificate.

Paul
--
Paul Fremantle
Part-time PhD student - School of Computing
twitter: pzfreo / skype: paulfremantle / blog: http://pzf.fremantle.org
Co-Founder, WSO2
Apache Member and Committer
07740 199 729

Paul Fremantle

unread,
Jul 21, 2016, 3:36:11 AM7/21/16
to mq...@googlegroups.com
I should have said, I'm using the Arduino tool with ESP8266 support added in,  v 1.6.9. 

Paul
Reply all
Reply to author
Forward
0 new messages