PlatformIO will manage the installation after you save the file. That is very neat.

Then new problems occurred when I started with integration of WiFiManager. Do not take me wrong. WiFiManager is very handy library, but you may experience some tricky issues.

The first problem that I hit was that WiFiManager interface was not visible at 192.168.4.1 port 80. ESP was apparently running in AP mode for configuration, but there was no web interface. This issue was caused by this line in my code:

ESP8266WebServer server(80);

I had web server in the main code before I merged the code from WiFiManager. Web server was serving simple REST API for controlling relay. Unfortunately this construct blocked the port so the AutoConnect web server. The server was not able to bind the port. Solution was simple. It was sufficient to instantiate web server after WiFi was working.

The second problem was that AutoConnect from WiFiManager was always turning in AP mode. I was hunting the problem for several hours without any result. One idea was that WiFiManager is not saving the password. That was not true. Other idea was that the memory is corrupted and reformat would help. Unfortunately it didn’t. I gave up.

That solved the problem. Seriously. I gave up and that solved the problem. I let the device running and then ding. It was online. For some strange reason ESP8266 was not able to establish connection with particular WiFi router at first shot. Then it turned on AP mode and after timeout of Config Portal it connected to the WiFi network. Remedy? Just shorten ConfigPortalTimeout:

wifiManager.setConfigPortalTimeout(60);

The third problem was that Config Portal was not displaying information stored as extra custom parameters. I stored there host name of MQTT broker and other options so they won’t be hardcoded. The problem was caused by WiFiManagerParameter constructed in global scope. Issue was similar the first problem with web server.

Solution was to move construction of WiFiManagerParameter to the method after loading configuration values from file config.json stored on file system.

I had an idea about next cool feature: turn on/off lamp based on sunset and sunrise. I found very simple and elegant solution that I would like to share with you.

Download Sunwait and compile it. The program just starts and waits until the time of sunrise or sunset based on geographic coordinates. You can also specify offset (how long before or after event) should program end.

Now you can put the sunwait into your local cron table and chain it with command that should be executed after sunrise/sunset occurs.

Here is example how to configure cron to turn on the lamp 15 minutes before sunset and turn it off 15 minutes after sunrise.

The lamp is now working. The only problem is the Android app. I thought that adding MQTT client to Android app will be as easy as adding it to ESP8266, but it’s far from truth. There are still some challenges 😉

23. October 2016

I spent a weekend researching about this topic. Here you can find extract with several links that might save you some time.

My goal was very simple. I’ve got Salt lamp with 15W light bulb and I would like to control it from mobile phone.

Before we embark on the journey I recommend to read RFC 1925 at least two points:

(1) It has to work.

(8) It is more complicated than you think.

Keep that in mind. Our journey can begin.

Group #1: Devices which do not care about net

The first group that I discovered were devices which has no integration with network.

Solight

It is simple and cheap hardware which allows time based control of power socket for the lamp: Solight time switch.

Price: 339 Kč / 12 EUR

Solight does not support remote control.

RSL2

Similar solution, but with remote control is RSL2. You can control several sockets with one remote control. The neat feature of this solution is ability to dim the light.

Price: 459 Kč / 17 EUR

The downside for this and several other sockets described in the article is that they’re targeted at German/Western market and you need to buy reduction to Czech/Slovak power plug.

Price: 71 Kč / 3 EUR

PowerCube

Then I found socket with interesting design which has support for remote control and you can turn it on just by pressing button: PowerCube. The button does not require any extra batteries. That’s very useful feature. Just some people on the internet complained that sometimes thay had to push the button twice. The button can be paired with more PowerCubes or more buttons can be paired one PowerCube.

Price: 659 Kč / 24 EUR

Group #2: Devices which do not care about cloud

I found this group at the end of my search.

Ubiquiti mFi mPower

Wow! mFi mPower! It has everything, because it is running on Linux. Wifi and even SSH interface. Android app or any script can interact with the device. The price is very reasonable.

Unfortunately the software development for this platform was placed on hold early this year. That is not good. Just two days ago there was another huge DDOS attack at Dyn which knocked out even GitHub. I’m not saying that it was caused by mFi devices. I just want to stress out that security patches are very important for smart devices.

Price: 1020 Kč / 42 EUR

BeeWi Bluetooth Smart Plug

Another device which is able to operate without cloud is BeeWi socket which communicates via Bluetooth with mobile phone. It is also possible to connect BeeWi to cloud, which requires special gateway from the same vendor.

Price: 1099 Kč / 45 EUR

Group #3: Devices addicted to cloud

There is large group of devices which operates on WiFi, but these devices are dependent on cloud. The dependency is not necessary bad thing, but you should be aware of it. It might very easy happen that the cloud is not accessible and you won’t be able to control the devices.

Isn’t it strange that with every flip of switch you need to generate some command and operation on remote server in the cloud?

D-Link DSP-W215 SmartPlug

Belkin – WeMo Insight Switch

WeMo solutions seems to be popular, but I found large number of very negative reviews of control app for Android. It reminds me on old bloated Samsung Kies. This solutions works via WiFi and requires connection to the cloud.

Price: 1561 Kč / 65 EUR

Group #4: Devices which talks together

This is the most complex group. These devices implements protocols like Z-Wave or Zigbee which does not operate with the same protocols as BlueTooth or WiFi. It means that you often need a server which controls behavior of devices and which is able to relay instructions from your mobile app to the protocol implemented by devices.

FIBARO – Wall Plug

FIBARO has simply great design, neat functions. Little bit more expensive, but where is the catch?

Price: 1799 Kč / 74 EUR

FIBARO – Home Center 2

Here is the catch. You need FIBARO Home Center 2 to be able to communicate with FIBARO Wall Plug. The device allows you to control and gather report from your smart home network. The only problem is that the price is little bit higher than you would expect.

Price: 16499 Kč / 687 EUR

There is also FIBARO Home Center Lite which has little bit simple HW configuration and it is about half the prices of Home Center 2.

Aeon Labs Z-WAVE USB Z-STICK GEN5

It is possible to use your own server instead of FIBARO Home Center, but you’ll need USB dongle like Aeon Z-Wave which is able to communicate via Z-Wave protocol.

Price: 1320 Kč / 55 EUR

OpenHAB

Once you’ve got USB dongle you can set up your own home automation server like OpenHAB. Just unzip the file, copy configuration. Start the Java server and connect to web interface. Then you can use application on your mobile phone to control your home network. OpenHAB is very flexible and authors received Duke’s choice award in 2013.

It is also possible to connect devices described in group “Addicted to cloud” and control these devices just from your own server. There are several other open source home automation systems. You can find the list at OpenSource.com.

Price: 0 Kč / 0 EUR

Zigbee

Zigbee is similar protocol to Z-Wave. It operates in 2.4 Ghz like WiFi or BlueTooth. You need also separate dongle to talk to this network of devices. Zigbee has been adopted also by Samsung Smartthings.

There are also other protocols, but the idea is always the same. You need dongle or special bridge to talk to your network of devices. These devices are often able to talk with each other.

Summary

As you can see the market is quite diverse and complex. We started with very simple solutions and gradually continued to very complex server controlled solutions. It is often confusing for beginners to spot difference between socket using WiFi or Z-Wave. I hope that this article shed some light to the topic.

Thank you for reading. If you see that something in article is not correct or misleading, let me know. I’ll be happy to fix it.

And what was my decision after weekend analysis of Smart Home? I will buy just a simple flash light and I will turn the switch manually 😉