A year ago I decided to make a simple device with a web interface for reliably turning on/off a couple of mains sockets via Wi-Fi. I thought that ESP-01 (having GPIO0 and GPIO2 available), and 2-channel Relay Module would be enough for that, and with NodeMCU writing a software would be not a problem at all.

During the prototyping of the device, the set of requirements were expanded a little:

  • Wi-Fi shall be configurable through Web Interface (both Access Point (AP) and connection to another Wi-Fi network). Setting up Wi-Fi shall not turn on/off the mains sockets.Ssuch a trivial thing like moving Power Strip from one place (with one Wi-Fi network) to another (with another Wi-Fi network or without it) shall not prevent re-setting Wi-Fi with the Web UI;
  • The device shall work even without Wi-Fi network available (detect it during start up, and turn on th AP where a smartphone can connect);
  • Some functions of UI shall be accessible to admin only, some - to user (2 security roles); the credentials shall be configurable through Web UI;
  • Controls for turning on/off shall be configurable through Web interface;
  • Web IDE shall exist for quick fixing / small enhancements. Web IDE shall work without Internet access (ad-hoc intranet created by ESP8266 AP shall be enough).

The requirements (especially the requirement about ports state reliability) influenced not only the software, but the hardware.
At first it turned out, that my ESP-01 instance may restart itself if I touch any wire (including GND and the output contacts of the relay module). I thought that there is something wrong with my ESP module, and replaced it with another one, but the second module behaved the same. After quickly browsing ESP-related Internet resources and checking the wiring, I found that I am probably unique to have this problem (it seems that ESP8266 just confused me with Mr. Bean, and acted accordingly).
Secondly, I found that http server can easily run out of memory when handling several requests simultanously, and restart as the result (under NodeMCU 0.9.5 with about 22k of RAM available for lua).
And last but not least, I didn't want the ports state to be changing when I will be playing with the lua software in runtime via Web IDE.
I hope that the reasons mentioned above answer the potential quetion you might have: "Why did you overkill the schema with the Arduino board in addition to the ESP8266 which itself could do everything?". IMHO an extra cheap Arduino Mini clone is a fair price for extra runtime hackability.

The project is open source, it is not hard to reproduce (especially if you own a 3D printer and necessary skills), and the components are achievable and relatively cheap.