Relayr / ESP8266_Lua. Issues 1., MQTT client support and. Luatool is a Python script that communicates with the ESP8266 using the serial port and sends. Configuring MQTT on the. The Lua software to run on # the ESP8266. Import os import string import paho.mqtt.client as mqtt import Adafruit_IO import time.
ESP8266 MQTT OLED Display Like many people I have been playing with the Espressif ESP8266 WiFi modules over the last few months. I’ve had a couple of modules running for a while now, one connected to an Arduino pro mini clone with a 2×16 OLED display and one running directly on the ESP8266 using the NodeMcu Lua interpreter controlling a relay over an HTTP REST-like API. One thing I was really hoping for was a native MQTT implementation as it is the protocol I use for my home automation and sensor network. Luckily tuanpm on the gave us a boxing day present in the form of a. MQTT on the ESP8266 means it will be easy to integrate input and output nodes in to my existing home automation and sensor network. For a first test I just changed the MQTT and WiFi settings in user_config.h, tweaked the Makefile for my environment and compiled with the (currently with the 0.9.3 Espressif SDK, I need to update) and it compiled fine, I flashed it to the ESP8266 and gave it a test run on a busy MQTT topic (all my environmental sensors) for a day or so and it handled it without a problem. The following day I hooked up a spare 0.96″ I2C OLED display and soon had it showing data from my sensors.
![Client Client](http://www.ernstc.dk/arduino/pic/flaher.jpg)
This demo is using the common ESP-01 variant of the ESP8266 board, available on eBay from Chinese sellers for around £2 each or a bit over double that from UK sellers. The downside of this module is that it only has two GPIO pins and we need both of those for the I2C and GPIO0 also to be grounded when we want to get into programming mode, a minor inconvenience but I also have some ESP-03 boards that I am working on a PCB for, as well as an ESP-12 and some ESP-WROOM modules that I got as a freebie from Espressif, all these have a lot more available GPIO pins.
The, it’s hardcoded to my setup but it should get you going if you want to give it a try. This code combines Tuan PM’s port of the (itself ported from the ), zarya’s and the.
It subscribes to three MQTT topics and displays them on the OLED (two temperature feeds and an info message on the bottom of the screen), the display I am using is but similar displays are widely available (plenty on eBay). Thanks for documenting this, it will be very useful to me. I’m using Node-Red with Ciseco XRF radios (measuring temperature, contacts and 2 relays) and a TADO heating controller all publishing to MQTT. The aim is to build a customised heating/water controller to replace the TADO eventually (just for fun). One observation, would it be better to have the topics for MQTT hardcoded to oled2 line1 oled2 line2 etc which could allow greater flexibility because you can then publish the MQTT temp data to the topic oled2 line1.
If you change your mind you wont need to reflash the esp8266 ?. Also, could I get 3 x GPIO (2x to drive relays and 1x pushbutton) and an oled working on one module? Hi, this is great, thanks for writing it up. I’m having problems though I can change any of the status strings like ‘STATION IDLE’ and see the effect when I recompile and re-flash the ESP8266.
However, no matter what I change the MQTT_HOST variable to, it insists on trying to connect to 192.168.1.21 – even though I grep the firmware files and see that I’ve changes the value to my local IP ranges. Any ideas???? I’ve tried about 20 times, and nothing fixes it.
![Arduino esp8266 serial Arduino esp8266 serial](https://i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2015/02/esplorer_tab.png)
But I can happily change status strings and see the effect with grep and when it’s running! I just spotted this – it is worth noting that Minh has now changed his coding slightly, there is no longer a setting in the config file for how many message the software subscribes to – also as of 2 days ago it works (there was an issue with simultaneous subscriptions coming in). For those looking in on Windows, don’t dispair this is no longer just for Linux people – compilation and flashing can now all be done in Eclipse in Windows – most of that is described somewhere on my blog at htttp://scargill.wordpress.com.