An attempt to retrofit cheap RF plug sockets with WiFi.
Quick update - began the schematic in EAGLE tonight. I had to create a custom part for the Omron G5CA relay. This features 2x0.4mm elliptical pins for the switch contacts. I drew these up using oversized rectangular pads and added a wire to the milling layer, but I may change this to a 2mm round hole as the results may be more predictable from the cut price Chinese board manufacturers.
I also started the schematic for the esp8266. It's been a while since I worked with a bare module (boards like the NodeMCU and Wemos D1 have made things very easy), so I was drawing this up whilst breadboarding and testing in parallel. Took me a while to work out which pins needed pull-ups and pull-downs and how to get it to boot into flashing mode. I still need to make a final decision on which IO pins I'll be using for the LED, relay and button.
Still to do - power supplies (230V > 5V and 5V > 3.3V) and programming headers.
AC-DC Power Supply
I anticipate the biggest space-eater on the board to be the power supply. Now, I am by no means an electrical engineer and I have never designed a board that interfaces with 230V AC before, so to do this safely I looked for the most self-contained solution I could find.
That's when I stumbled across the HLK-PM01 (datasheet) and a series of very useful blog posts about how to implement it safely. The part takes a 230V AC input and supplies 5V DC up to 600mA, with minimal extra parts. It's a fairly bulky component, but at 34x24mm and 15mm height, it will just about fit in the bottom recess under the board with just under 2mm to spare.
As recommended by Skippy's blog posts, I'm going to add a varistor and fuse to the AC input. On the output side, hopefully a pair of 0.1uF and 10uF smoothing capacitors will provide a clean enough output to the low voltage side.
There are some concerns with emissions, but as I'm not developing this into an actual product, I'm not going to worry too much about this. I may revisit this if there are any wireless performance issues with the ESP8266.
Final note on this: it's a 5V power supply and the ESP8266 is a 3.3V board, but having both 5V and 3.3V available (via a linear regulator) on the board will give me more options later for part selection.
This one required a bit of searching to find something low-profile enough to fit where the housing tapers off to 13mm underneath the board in the middle. A common, cheap part that I was planning to use (the GHI SRD-05VDC-SL-C) has a height of 15mm.
I found the Omron G5CA-1A, a 10A @ 250VAC rated relay clocking in at a svelte 11mm height. This is also a normally open contact without a normally closed terminal, which should make the high current traces on the board easier to route (the common contact pin on the SRD-05VDC is nestled in between the two coil pins).
With the two largest components in place, I started doing some accurate measurements on the board and began the CAD layout.Read more »
My goal is to design a drop-in replacement PCB that will fit into the six 'Status' branded sockets I have.
It will need to contain the following components:
Here's what we have to work with:Read more »
I've been using 433mhz RF controlled plug sockets for home automation for around 5 years, and it has worked reasonably well. I started out sniffing the codes sent by the original remote control with an Arduino and a 433mhz receiver, before making an Arduino-based transmitter that received input over a serial connection from a server on my home network to control and automate various appliances in my home. As first this was just simple cron jobs to turn lights on at sunset, and a hacked together web interface to control sockets via my phone.
As times have moved on, I've embraced Apple's HomeKit ecosystem and the amazing community project Homebridge, which has a plethora of plugins available for controlling various connected devices. I was able to carry on using my 433mhz transmitter and shell scripts with the cmdswitch2 plugin.
This all works quite reliably 99% of the time, but there are a few downsides:
Introducing a microcontroller with on-board WiFi will solve both of these problems, and also open some other interesting doors for future revisions of the project such as power consumption monitoring and reporting.