Alexa Enabled USB Power Switch
Many devices are powered by USB power now, but few home automation systems provide USB power switching. “Alexa, turn off the ThingyStick!”.
Alexa, Turn on the ThingyStick…
More and more devices are powered by USB, many of these tend to be “dumb” devices without internet connectivity or home automation options (e.g. LED lights), how can we automate or control them remotely? Perhaps a USB supply plugged into a mains switch, that’s a bit overkill, especially if we want 4 devices controlled individually!
This project allows you to control the power supply to USB powered devices via the internet, and by using the Tinamous SmartHome Skill for Alexa, you can enable voice control for your dumb USB devices.
Currently their are very few devices on the market to control USB power remotely, when I started this project I didn’t find any (in the UK), but a couple have recently appeared as part of multi-gang outlets (yes, the idea started a long time ago, in a galaxy far away), these are not by well known home automation manufacturers, instead by unbranded manufacturers (i.e. ZLD-34UK) so we have the issue of whose device cloud they use, is the data going to China and back, what happens if that manufacturer no longer exists, how secure is it, how usable is the software, will it be in the recycling box next week, and many of the other normal concerns of Internet connected devices, not to mention not being hackable in the same way an open source Arduino powered device can be.
Examples of USB powered devices we might wish to control:
- USB powered lights
- Kindle Fire / Chrome cast sticks (esp. in kids rooms to stop them watching TV)
- USB humidifiers
- Echo Dot (make Alexa shut itself down for the night? or just reboot the device)
- Development boards. Need to reboot that project because your codes gone into an infinite loop?
- Devices that are difficult to access but need to be rebooted occasionally (i.e. sensors in the loft).
- Devices installed at client premises where we want to ensure it is powered (by measuring the current consumption and the input voltage)
Simple power control: Internet enabled power switching, either via Alexa voice control or other commands through Tinamous. On and Off.
Smart power control: Many USB lamps have touch controls to switch the lamp on, which means we can’t switch the light on remotely, but we can switch it off, and a lot of the time that’s all we want (trying to sleep, left a lamp on? Going out, want all the lights switched off?).
However, once we’ve used Alexa to Turn Off the USB lamp, we then have to ask Alexa to Turn On the lamp before we can then switch it on, that’s just silly. With smart power enabled, the off command will turn the lamp power off for a few seconds before restoring power to the device. Enough to turn the lamp off, but also allowing normal operation after.
Timer Automation: Have your devices automatically power down at set times. Kids watching Amazon TV on the fire stick to late? Have the USB supply shut down automatically at 8pm.
Power monitoring: If you’re developing USB powered hardware you may well want to know how much current you device is taking, particularly when it is first switches on, or you may like to profile battery pack charging. With the on-board INA219 you can monitor current consumption (I managed about 1kHz sampling with little effort). Voltage drop on USB leads at high current can also be a problem, the INA219 monitors the power into the device so we can warn of low voltage. A terminal block is also provided to allow for higher currents and bigger cables to be used.
Power failure: By using the battery option on the MKR 1000 we can monitor the USB supply voltage and send notifications if the input power has failed. This might be useful for remote (off site) solutions that use USB power but need a bit of extra monitoring, or just as a simple mains power fail detection for your house.
This project is fairly simple, an Arduino MKR1000 at the heart, USB power switching using two LM3526M’s to provides high side switching and fault detection (low voltage, over current), along with power monitoring (voltage and current) using an INA219, and finally LEDs and switches for local control options.
I had a PCB made at DirtyPCBs.com, you could also send the .brd file off to OSHPark.com to have some made as well. The Arduino socket has pcb pads either side of each pin to allow for hacking. e.g. you could easily add some sensors for environmental conditions, or a small OLED display to show voltage and current.
In the github repository their is a 2 port and 4 port option. Be-careful with the 2 port PCB as I messed up and got the layout for the USB socket wrong (they are back to front – wrong polarity!).
Victory from the jaws of defeat:
As it turns out mounting the USB socked on the back of the board is actually a nice solution and meant the pin connections were correct (however for the 2 port board it also means the silk screen is on the wrong side!). The Arduino with headers in a socket was a bit pushed for space with the height required to get the USB sockets out of the enclosure so it actually worked out better, I decided to re-do the board with sockets, switches and LEDs on the reverse side and to add two extra ports, hence the four port version was created (also, I had the LEDs horribly aligned on the 2 porter, so that got fixed as well!).
Theirs very little stopping this being extended to a 6 or 8 port switcher, although the LEDs and switches might need to be dropped or improved on.
The schematic looks a lot more complex to build that it is. A lot of the resistors are optional. Resistors R23, 19, 27 and 26 are all pull-ups for the switches, likewise R20-22, R14 & R15 are pull-ups for the USB control and fault detection. These can all be done through the INPUT_PULLUP pin mode in the Arduino, however if you wanted to put the Arduino to low power sleep and use interrupts to wake it, you may wish to populate these so they don’t float (and bounce around).
Read more: Alexa Enabled USB Power Switch
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w