Electronic – ESP8266 WiFi module light switch

esp8266switch-mode-power-supplywifi

Info

So I've decided to hop on the ESP8266 WiFi module bandwagon and build a light switch with a couple of differences.

1) the light switch needs to go in the wall and be the same size as the existing panel light switches (deeper will be OK)

2) the circuit needs to pull power from the existing 250v power that runs through the switch

3) the light switch needs to contain a microphone so I can walk around the house issuing voice commands and each light switch will be able to hear the command and relay it to a central hub for processing.

4) the light switches will use the esp 8226's ability to be a wifi client and AP to create a mesh network so commands can be relayed around the house.

5) I need a design that an support up to 4 switches in one light switch panel.

Questions

1) What should I use to pull 5v from the 250v power supplier. I've seen switching power supplys but these are all fairly bulky and contain transformers. I was hoping that there was a smaller solution. I only need 250mA to power the device.

2) Can the esp 8226 be used to forward raw audio from a digital microphone. I would estimate the device will need to handle about 100Kbps given I probably won't have sufficient room on the device to compress before I send the data. So there are two parts to this question

a) is it possible to wire a microphone to the esp 8226 and capture the audio

b) can it handle 100Kbps

3) If I 3d print the panel and a mount box in PLA is that considered electrically safe ?

4) How much of a challenge is reception going to be if the antenna is in the wall? Should I expose the antenna on the switch face plate? As i'm designing the light switches as a mesh network there should be another light switch just a few meters away in most cases.

Sorry if the questions are dumb but I'm a programmer not an electrical engineer.

Best Answer

  1. "Only" 250mA is not the word I'd use when you want to drop up to 345V (if full wave rectified) - I'd like to hear you managed to dissipate 80+ Watt in a linear regulator. The 2 common options are a) full wave rectify, and use a buck converter to drop to 5V (addendum by bss36504: flyback converters do both) b) Use a transformer to drop the AC voltage first, then rectify and you may use either a linear regulator depending on the dropout voltage and the voltage ripple across the filtering capacitor of the rectifier. My advice to you is: c) don't reinvent the wheel, it's time consuming, expensive, and potentially dangerous. Use one of those 5V wall wart. They're bulky due to their transformer, but they work first try and they have been safety-checked. Otherwise you'll have to ask an electrician to check your system to cover your back in case anything goes wrong (I suspect insurance may not reimburse your home if it burns down because of something that you've done yourself and has not been checked...)!
  2. The ESP8266 will never be able to send uncompressed audio at 100kbps in real time. This source has tested it and measured 7kbps in TCP, and 19kbps in UDP. What you could do though is recognise commands, and send the command waveform at a slower rate. Assuming one command takes 1 second, it would take 15s to send the command over in TCP and 6s with UDP. Maybe you can compress on board first, reducing the time it takes to send the data, but I doubt you can do it with a ESP8266 alone (I've seen it done on Atmega328s). As for the microphone connection, you've got 2 GPIO's exposed on the connector of the common 8-pin ESP8266, and I THINK none of them are analog. Enough for a serial microphone module. The chip has 1 ADC though, so there are bigger boards with more signals routed and in particular 1 ADC which would allow you to use the more commonly available analog microphone modules such as this one. Seeing how voice recognition is barely good enough with a decent PC or smartphone microphone, I have no idea if the audio will be clear enough with cheap microphone modules, you need to test it.
  3. As long as you use a decent wall wart (or equivalent) to drop mains voltage to less than 25V, a PLA enclosure is absolutely fine and in fact it would be legal to leave the box open if the environment is dry. This should be valid in Europe only although I suspect it's similar elsewhere. I don't have my BS EN 7671 book with me, so you'd better check the details yourself for anything above 12V.

I'm about to do the same here, and my advice to you is that you should probably trade some of this off: I'm personally going to use "OK google" on my phone, and send the commands to the correct ESP8266 in the house. After all, who wanders around without their phone nowadays?