Geekzone: technology news, blogs, forums
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.

1724 posts

Uber Geek


#195626 27-Apr-2016 12:00
Send private message

For anyone tinkering with the ESP8266/NodeMCU/Wemos devices, and are interested in MQTT, you should definitely check out the open source framework called Homie. This is a very well written and stable framework you can deploy to your device and it will handle all the WIFI and MQTT setup and connections etc. All you have to do is worry about reading your sensors etc.


One of the best things about the ESP8266 and Homie is that it supports OTA (over-the-air) updates. So you can deploy your devices and then upgrade the firmware without needing any physical access to the device - a huge advantage IMO!


In order to facilitate these OTA updates myself and another chap (JP Mens) have written a python based _Homie OTA Server_ which allows you to maintain an inventory of firmware versions, keep track of your Homie devices, and schedule OTA updates.


Just thought some of you might find this useful so figured I would share it here.



Create new topic
271 posts

Ultimate Geek

  #1542715 27-Apr-2016 12:21
Send private message

Thanks for starting up this thread.


I've been tinkering with with Homie and ESP8266 for a couple days now but I couldn't configure it to connect to my wifi.


I loaded the basic sketch and configure the wifi connection using this method:


But I kept getting invalid name error.  It looks like the name field of the JSON configuration is empty.


How do you guys configure the wifi connection?



1724 posts

Uber Geek


  #1542719 27-Apr-2016 12:30
Send private message

I have a special sketch I use to load the config onto the device first, which writes it to the SPIFFS. This will also format the SPIFFS first so make sure there is nothing on there you want to keep.


After this is loaded you can load a standard Homie sketch. When Homie starts up it will read the /homie/config.json from the SPIFFS and connect to your WIFI and MQTT broker.


And once you have a working Homie sketch loaded, you can unplug from your PC and all future firmware updates can be handled by homie-ota.






#include <ArduinoJson.h>
#include "FS.h"


bool saveConfig()
StaticJsonBuffer < 1050 > jsonBuffer;
JsonObject & json = jsonBuffer.createObject();


json["name"] = "Device 01";
json["device_id"] = "device-01";


JsonObject & wifi = json.createNestedObject("wifi");
wifi["ssid"] = "...";
wifi["password"] = "...";


JsonObject & mqtt = json.createNestedObject("mqtt");
mqtt["host"] = "mqtt.home";
mqtt["port"] = 1883;
mqtt["ssl"] = false;
mqtt["auth"] = true;
mqtt["username"] = "...";
mqtt["password"] = "...";
mqtt["base_topic"] = "/homie/";


JsonObject & ota = json.createNestedObject("ota");
ota["enabled"] = true;
ota["ssl"] = false;
ota["host"] = "web01.home";
ota["port"] = 9080;
ota["path"] = "/homie-ota";




File configFile ="/homie/config.json", "w");
if (!configFile) {
Serial.println("Failed to open config file for writing");
return false;
return true;


void setup()

Serial.println("Formatting FS...");


Serial.println("Mounting FS...");
if (!SPIFFS.begin()) {
Serial.println("Failed to mount file system");



void loop()






271 posts

Ultimate Geek

  #1543089 27-Apr-2016 22:38
Send private message

It worked. Thanks a lot.


Just wondering how you arrived using this method?


The standard suggested methods by Homie didn't work for you either?

1724 posts

Uber Geek


  #1543092 27-Apr-2016 22:40
Send private message

JP Mens, the chap who wrote homie-ota with me, devised it.

3344 posts

Uber Geek


  #1543117 28-Apr-2016 00:42
Send private message

Timely, I'm just part way into building an IoT thing with an ESP8266 and was planning to use MQTT so I can use Amazon IoT... the OTA updates definitely appeal.  Will take a gander - thanks!

3344 posts

Uber Geek


  #1543142 28-Apr-2016 01:20
Send private message

For the sensor I'm building, I intend to have it take a reading, dispatch the reading, and then enter deep sleep to save power (it will be powered by a small solar panel and rechargeable battery so it needs to be as frugal as possible).


I have been reading the API documentation, but could not determine any way to tell whether homie has sent and retrieved its MQTT message(s) yet, indicating it is OK to go back to sleep until the next reading is due. If I instead reached a timeout limit indicating it had failed to do so, the device might do a shorter sleep.


Would appreciate any thoughts, if you have the time :)  Thanks!

Create new topic

News »

Freeview On Demand app launches on Sony Android TVs
Posted 6-Aug-2020 13:35

UFB hits more than one million connections
Posted 6-Aug-2020 09:42

D-Link A/NZ extends COVR Wi-Fi EasyMesh System series with new three-pack
Posted 4-Aug-2020 15:01

New Zealand software Rfider tracks coffee from Colombia all the way to New Zealand businesses
Posted 3-Aug-2020 10:35

Logitech G launches Pro X Wireless gaming headset
Posted 3-Aug-2020 10:21

Sony Alpha 7S III provides supreme imaging performance
Posted 3-Aug-2020 10:11

Sony introduces first CFexpress Type A memory card
Posted 3-Aug-2020 10:05

Marsello acquires Goody consolidating online and in-store marketing position
Posted 30-Jul-2020 16:26

Fonterra first major customer for Microsoft's New Zealand datacentre
Posted 30-Jul-2020 08:07

Everything we learnt at the IBM Cloud Forum 2020
Posted 29-Jul-2020 14:45

Dropbox launches native HelloSign workflow and data residency in Australia
Posted 29-Jul-2020 12:48

Spark launches 5G in Palmerston North
Posted 29-Jul-2020 09:50

Lenovo brings speed and smarter features to new 5G mobile gaming phone
Posted 28-Jul-2020 22:00

Withings raises $60 million to enable bridge between patients and healthcare
Posted 28-Jul-2020 21:51

QNAP integrates Catalyst Cloud Object Storage into Hybrid Backup solution
Posted 28-Jul-2020 21:40

Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.

Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron

Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.