News for hackers. Stuff that matters.
Re:More awful IoT stuff by tzs on Wednesday June 22, 2016 @02:07PM (#11955793)
If you are OK with building it yourself, you could do this with an ESP8266, a USB to serial cable, a solid state relay, a power brick, and some miscellaneous things like a power cord and a socket (and ideally some case to put all this in for safety).

The ESP8266 is a micro controller with built in WiFi and network stack and a serial interface, and several digital I/O pins you can use to interface to other things.

Various vendors sell small modules that couple an ESP8266 with some flash memory to hold your code. These often come with built in firmware that provides a serial interface similar to the old modem "AT" interface, but with commands for WiFi. There is a free SDK available for programming the thing in C/C++. There are several firmware replacements available. There is one that brings the Arduino environment to the ESP8266. There is one that offers MicroPython. There is one that offers Lua.

A solid state relay is a four terminal device. Two terminals are the control terminals, and two are the load terminals. Put a specified voltage across the control terminals, and the devices acts like a closed switch between the load terminals. If the control voltage is below the specified level, the device acts like an open switch between the load terminals. A typical SSR can handle AC voltage on the load terminals of well over what any standard household or office uses. The control voltage is typically around 3-30 V to close the virtual switch, which a logic one in a 3.3 V system (like the ESP8266) falls within, so you may be able to control the SSR directly from an ESP8266 I/O pin. (But you'd need to check the specs for the relay and make sure it doesn't require more current than the pin provides. If it does you might have to toss in a transistor to drive the relay).

This would be a good first project to get started in micro controllers or IoT or home automation or home sensing.

Re:More awful IoT stuff by gh02t on Wednesday June 22, 2016 @02:14PM (#11955843)
Don't even need to make it yourself, Itead sells the Sonoff for $4.85 + S&H. It's an ESP8266 connected to a relay, with integrated AC-DC power supply and a properly designed, physically isolated PCB.

Two caveats are that it doesn't directly have a USB plug. The serial header is exposed and you can reprogram the device with your own firmware to make it report whatever you like, but you do need a USB-Serial cable and maybe to solder on some header pins. Also, it is meant to be spliced into a power cable - it has input and output wire terminals and not an outlet-type connector.

I have a couple of these, they're quite useful. One controlling a fan and another I spliced into a light switch to control some overhead lights.

https://www.itead.cc/sonoff-wifi-wireless-switch.html

http://tech.scargill.net/itead-slampher-and-sonoff/

Re:More awful IoT stuff by hueving on Wednesday June 22, 2016 @02:49PM (#11956084)
This is exactly what I've been looking for. Where can I pick up some cheap adapters to get an outlet on one end and male plug on the other?
Re:More awful IoT stuff by extrapickles on Wednesday June 22, 2016 @04:12PM (#11956618)
Get a power strip and a electrical enclosure from the hardware store or you can get a replacement appliance cord+wall outlet+electrical box. Also get a outlet wiring tester to make sure you wired it correctly (eg: didn't get hot/neutral/ground mixed up)

Make sure to put a 10A fuse in series, use wire rated for 10A and pass the ground wire through.

Re:More awful IoT stuff by gh02t on Wednesday June 22, 2016 @05:33PM (#11957200)
To add to this, the whole board pops out of the protective plastic enclosure with minimal effort and is pretty compact, so if you wanna build your own enclosure it's pretty easy.
Re:More awful IoT stuff by gh02t on Wednesday June 22, 2016 @05:26PM (#11957155)
You can use something like a two-prong lamp extension cable, I have one similar to these:

http://www.aliexpress.com/item/USA-Canada-2-Prong-Male-to-Fe...

Or just cut and splice the regular power cord, that's what I did with a room fan. The Sonoff has thick plastic covers for the terminals with little teeth to hold the wires in place as it's meant to be put directly in line with a power cable. Note that the relay inside is claimed rated for 10A, so I wouldn't power appliances with it. It also only switches the hot and neutral lines, so if you need a 3-pin connection you have to splice it to the line and neutral while keeping the ground line connected.

It goes without saying however that you should be extremely careful and only splice wires like this if you know what you're doing. Don't damage cable insulation while stripping, wire things up to the right connectors, don't leave exposed wires, use the correct wire gauges for your load, etc. Mains electricity is dangerous, yo.

Re:More awful IoT stuff by mivade on Wednesday June 22, 2016 @02:31PM (#11955970)
Thanks for this. I had somehow never heard of this chip before. Link for the lazy: http://esp8266.net/
Re:More awful IoT stuff by pikewood on Wednesday June 22, 2016 @05:09PM (#11957056)
Anyone have recommendations for a relay that could handle 20A but would work with the ESP8266's 3.3V?
Re:More awful IoT stuff by tzs on Wednesday June 22, 2016 @06:32PM (#11957566)
I've not used this, but it looks like it would fit the bill: https://www.sparkfun.com/products/13015

The datasheet says the control current is 7.5 mA at 12 V. It doesn't say what it would be at 3.3 V, so that would be the one thing I'd worry about. ESP8266 GPIO pins can source a maximum of 12 mA, so if you want to hook it up in a way that uses the GPIO pin as the current source there might be some issues.

I think to be safe, I'd just go ahead and add a transistor. That also can provide protection against a logical 1 being enough less than 3.3 V or a logical 0 being enough more than 0 V to cause problems.

You can find similar relays on Amazon for a bit less (search "solid state relay"), and even cheaper on AliExpress if you aren't in a hurry.