-
1Build
Motivation
I have a 3D printer made in China running days and nights at home without monitor. I doubt if it has a proper fire hazard protection. So I decided to add some intelligence to override its power supply.
Two features I want:
1. Shutdown the power supply when shit happens. The signal may come from external smoke detector sent by Raspberry Pi.
2. Turn on/off the power supply by Octoprint server running in Raspberry Pi.
I looked around all smart power plugs in the market. They all use proprietary communication protocol and some even pass through my firewall at home. I hate to leave my door open. Call me a security paranoid. But it is never a good idea to leave any possibilities to let any hackers mess around the appliances at home.
So I decided to build one from ground up. All parts I used here are also made in China. I admit there is a logical fallacy -- using made in China components to prevent fire hazard of the appliance also made in China.
Wiring
The wiring is extremely easy. It doesn't worth my efforts to draw it in fritzing. If you don't know how to wire them, you should NOT try it on your own.
I uploaded ESP8266 specs doc. Go figure it out by yourself.
Note that I used a mechanical relay, instead of solid state relay. You can hear a click sound when you open/close. Depending on your load ( I probably will make the relay closed for a very long time ), solid state relay may need an additional heat sink to control heat build up. I don't want to add it into this small junction box. So I choose the mechanical one.
In addition, I'm waiting for the fuse and the fuse holder from China. So I don't show them here. But you should add one in case power surge.
Software
There is a popular RESTful framework in Arduino called aREST. But several things in aREST are foobar ( fuck up beyond recognition ). So I rewrote it from scratch. If you wonder why, read the README in my bREST framework.
All source code is the 2nd sample in my bREST framework. It also includes a simple Python script for you to test.
Just go to https://github.com/rickyzhang82/bREST
Alternative HardwareThe cost of the DIY home depot power plug is above $35. I found a ready-made Sonoff S20 costs less than $12 online. You can check out my project log regarding to the wiring.
The new firmware for Sonoff S20:
- enables physical button switch
- enables green LED and red LED to indicate if the power plug is open or closed
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Sweet! I may inspire myself of that project. I just need the addition of a switch for manual operation also.
Are you sure? yes | no
If you crank that physical manual switch into smart power plug, you may force yourself into a dilemma: should they be in series connection or parallel connection... I'd recommend to build a separate power switch with ESP8266 to turn on/off through REST call.
Are you sure? yes | no
Well, I have a second thought on adding a switch. I may add a momentary switch and hook up to ESP8266 GPIO to toggle on/off as well. My previous idea sucks. I will try it on once I got the parts.
Are you sure? yes | no
I enabled a physical button switch in Sonoff S20. Go check out my new project log. I updated firmware.
Are you sure? yes | no