IoT Power Strip

The device that allows to turn on/off two pairs of the outlet sockets via Web browser through Wi-Fi. Based on ESP8266 and Arduino Mini.

Similar projects worth following
IoT Power Strip is a DIY device that allows to turn on/off two pairs of the outlet sockets via Web browser through Wi-Fi.
It doesn't require any infrastructure besides the Wi-Fi enabled device with HTTP browser (e.g.: smartphone, tablet, laptop). That means that you don't need some IoT server to be installed in your intranet (like MQTT server or Web Server), you even don't have to have internet access to operate the IoT Power Strip.

The software features:
* Operate secondary controller ports through Web Interface;
* HTTP Server with optional authentication for 2 users;
* Wi-Fi configurable through Web interface (both connecting to existing Wi-Fi network and creating a new Wi-Fi AP with the option of disabling AP on successfull connectin to Wi-Fi network);
* In AP mode all the DNS queries are resolved to ESP8266 IP address;
* Ports Control UI configurable via Web UI;
* Send raw UART commands through Web interface;
* Built-in IDE for editing the software through

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.

View all 9 components

  • Apps added

    dev-lab01/11/2022 at 17:49 0 comments

    Several apps added for Bare NodeMCU IoT Generic Switch as the implementation of the following requirements:

    1. Internet router rebooter. Sometimes routers stop working for an unknown reason. Even those network devices that are considered reliable may fail a couple of times a year. Mankind has developed the ultimate solution for it: power off/on cycle. Therefore, the requirement for the device is to resemble what human does: to check availability of through router's wifi, and restart the router (by turning it off and on) when the Internet disappears.
    2. UVC lamp timer. Ultraviolet-C can kill Covid-19 (among other life forms), but it is not safe to turn on the lamp (you have to wear a special goggles which is sometimes inconvenient). So, the requirement is to turn on the lamp either remotely, or with a button (after some delay), and turn it off automatically after 20 minutes of exposure. The device must also work reliably without internet/intranet (operatable by a button).
    3. Scheduler. Turn on/off holiday lights on schedule (when it is dark, but no one is sleeping yet), or turn on the storage water heater at night (when electricity is cheaper because everyone is asleep and not using it).

    These apps have been in use for about a year, so they can be considered relatively reliable. Here are some details.

  • Arduino virtualized on NodeMCU ;-)

    dev-lab04/13/2021 at 18:04 0 comments

    Actually, Arduino GenericPin (the backend controller module) was implemented on NodeMCU lua.

    Thanks to Sonoff, there are now many ESP modules, which I prefer to use with NodeMCU. I flash them with Flash Stepler and upload the Bare ESP8266 NodeMCU IoT Generic Switch software to them.

  • ESP8266 NodeMCU IoT Generic Switch 2.0.0

    dev-lab04/04/2021 at 22:18 0 comments

    • The IoT Generic Switch 1.0.0 was  created on NodeMCU 0.9.6. The current version of NodeMCU is 3.0.0, where some old API methods were removed, and some new API appeared instead of deprecated ones. So, I've updated the project to be agnostic to NodeMCU versions.
    • Web UI is now responsive. That helps working on small screens.
    • Web UI slider now more usable when using from touch screens.
    • The HTTP methods that may change the server state (ESP8266+arduino) are now POST only.
    • As expected, the changes above affected the size of the project. Now it is about half Kb smaller.

    You can download it here:

View all 3 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates