Hacker News new | comments | show | ask | jobs | submit login
Turn a light bulb on with every new user or download (rigoneri.com)
89 points by rigoneri 1604 days ago | hide | past | web | 39 comments | favorite

BIG FAT WARNING: If you're going to relay your Raspberry Pi / Arduino to mains electricity, be very, very careful!

Mains electricity can KILL. Make sure you learn about safe shielding, connecting and grounding practices.

Above all, be extremely cautious!

I can't stress this enough.

EDIT: For more information: http://tubelab.com/Safety.htm

Better yet: Don't connect your Raspberry Pi / Arduino at all to mains electricity unless you use an opto-isolator, or you have training in designing such circuits.

The usb relay is NOT designed for this! See the picture: http://www.circuitgizmos.com/products/cgu451/cgu451.shtml

In a device intended for hybrid hi/low voltage there is a clear gap between the high and low voltage components, and an isolation transformer or opto-isolator between them.

I have training in designing such circuits and I'd still use an opto-isolator.

This is not manufacturing. It's a one-off project. It's not a highly refined design. You don't have to worry about finessing a marginally lower build cost because of what it will mean in 10k unit quantities. Just use the opto-isolator.

You're overreacting!

An isolation transformer would be of absolutely no use here and the optoisolator would provide the same functionality that the existing relays on that board do.

I can't see how the PC board is laid out so I can't verify if there is inadequate separation between the control side and the isolated side of the relay (even so, you only need about 5mm separation to be minimally safe at 120V), but barring that, it's fine!

Yes, this particular device is not explicitly designed to deal with all the hazards of switching a high voltage load, but I don't see anything that leads me to believe that it's unsafe for that purpose.

Others have mentioned the Belkin WeMo, which seems to be the best solution for anyone who doesn't want to mess with circuits (though I have no experience with, so can't comment). Does anyone know if it is available in a 220v format?

But if you do mess around with RasPis or Arduinos for that, I can't stress how useful the PowerSwitchTail is http://www.powerswitchtail.com/Pages/default.aspx - you give it a low power signal, and it switches a high power one. They have a 220v version as well.

Thanks a lot for the link. I've been idly pondering a couple of projects that would involve switching mains power with a microcontroller, but didn't encounter anything like that at a price that made me want to consider it. You may have saved me from a fiery doom.

It's sold in New Zealand where I am, and we are on 240v.

LEDs would be much better suited for this.

In fact if I had the free time then I'd build a binary display for page hits using a series of LEDs on a Raspberry Pi (sadly I have a million other projects going on at the moment - such as finishing my website so I can get hits to begin with hehehe)

Indeed. For your own good, don't do this: http://palace-dci.sourceforge.net/images/electronics.jpg

Amazingly, I never had a single incident with that parallel port->breadboard+transistors+relays->lights setup from my high school days.

Pro tip: avoid hardware, stick to software. Just kidding.

This falls - as others have already commented - in the 'knows just enough to be dangerous' category.

Please use LEDs, don't even bother messing around with opto-isolators and so on unless you have experience with both mains electricity and designing safe circuitry.

Agreed 100%. Not happy with the Pi's 3.3v pins and want to light something brighter than a couple of LEDs? Try this:

- 12v power supply (from like anything in your house)

- 12v LED strip (super cheap on eBay or basically anywhere)

- This awesome MOSFET from Adafruit http://www.adafruit.com/products/355

This is what I used for a cool RPi + RFID + LED project this year, write-up coming eventually, here's a clip for now: http://vine.co/v/bvZQVJLnemh - my example only has a few LEDs but in the final product I used strips with about 30.

This seems like a really great use for raspberry pi. I recently finished a project involving a pi + a relay to activate a door buzzer, written in javascript. It was surprisingly simple and straightforward.

Besides turning on lights, the cool thing about relays is that most things involving physical push-buttons can be taken apart and easily wired up to a relay.

Arduinos can (supposedly) host webpages, and pins can be powered or depowered by (properly parsed) HTML POST commands. Combining this with a relay means we can create WIFI website interfaces for anything that uses electricity.

The opportunities to improve current products are so endless that I become overwhelmed whenever I think about this. We all have the parts to do this today, but so few are assembling them.


Want to set an outlet to turn on or off at different times? No need to buy a timer, just goto that outlet's website on your WIFI LAN, and set it on a timer. Or you could depower the outlet to make it child-safe.

Are you going on a trip and you're afraid you left the toaster plugged in and your house might burn down? Just VPN to your home LAN, sign into your kitchen's website and have it power off all outlets.

Locked out of your car? Pull out your phone, securely sign into your car's website, and tell it to unlock the doors.

Power and depower garage door openers, sprinklers, RC cars, even industrial equipment from a simple web interface.

Couldn't agree more. I wrote a blog post about it a while back demonstrating my take on this. Here's common household appliances getting web interfaces that can be accessed with any smartphone by QR Code. No arduino or soldering mains current required. I think every electronic thing in my house should have a little QR Code next to it so I can just point my phone at it and get its interface.


The video halfway down shows it in action.

Arduino or Raspberry Pi are kind of overkill for this ...

USB breakout board -> MSP430 -> LEDs/Buzzers/Whatever

You're talking somewhere around $14.

Yes, you'll need to know C or assembly for the MSP430 and likely a scripting language for the PC, but it makes a lot more sense than bringing in all of that horsepower to essentially get an I/O and light an LED.

Your solution works totally fine, but it also involves using an entire computer to run the thing, which may or may not be overkill depending on whether or not you already have a computer that can be dedicated to it. Personally, I prefer these kinds of projects to be self-contained.

What protection do you use for the Pi's GPIOs?

Working with mains power is stupid. Don't do it if you can avoid it, especially if you don't know what you are doing.

You can get a small remote power switch for $100 or so.

Belkin WeMo is only $49 and programmable via IFTTT.

Edit: $45 on Amazon at present.

We've had success with a WeMo and this project: https://github.com/issackelly/wemo which lets you control the WeMo switch from within your local network. A quick python script to query the database for new users followed by calls to on() and off() works great.

There are remote-controlled RF switches for $20 for four. The Raspberry Pi can send RF signalss to these switches. Unfortunately, I don't have an oscilloscope to reverse-engineer the signal for mine, so the most I could manage to do is turn them off (but not on).

That's a very safe way of doing these things. If anyone else knows how I can reverse-engineer the signal, I'd appreciate it (I also want to make the Raspberry Pi open my garage door, same deal).

This is when I feel envy toward engineers who can program hardware. I'm so involved with Ruby and HTTP and CSS etc. that I have negligible knowledge about Arduino, Raspberry Pi, and Beaglebone.

I don't even know where to start and whether it will be a fruitful exercise (i.e. will I be able to devote sufficient time to it to actually learn something worthwhile).

Anyway, this is a neat project and I wish you good luck OP!

With any of these three platforms you could be doing this project in an afternoon. Processing isn't any harder than Ruby. You can do it.

Check out http://Raspberry.io for some resources the python community put together to use Raspberry Pi

Check out makezine for resources designed for people who aren't even familiar with programming. It doesn't take much to get up to speed with some basic on/off circuits. With a little high-school physics or just some asking around of friends you can get custom devices going.

I built something similar recently to flash a light every time someone buys something on Creative Market (video here https://vine.co/v/bTnnTVmH5eD). I know nothing about mains electricity, so I pulled together an Arduino and a LED with a bit of socket work to get a green light flashing. Once someone completes a sale, a piece of Javascript is requested from a Node.js HTTP server I setup. The server then pings the computer with the Arduino plugged into it over UDP and the client sends a serial response to the Ardunio, flashing the light. It's pretty simple, but it was fun to get all the components together and learn more about hardware development. Since a flash of the LED is requested on every sale and the UDP responds pretty quickly, it acts as a great thermometer during high sales peaks.

I'm now in the process of abstracting the entire thing into a self-contained box that communicates over wifi and uses mains electricity. Hopefully I don't kill myself.

Cool project!

Maybe iterate it to use LEDs instead of incandescents.

For hardware hacking- you have 3 types of hardware that can make life easy- but there are tradeoffs:

1) Arduino 2) Raspberry PI 3) Beaglebone

Arduino is great when you want low power, but it isn't an awesome internet platform.

Raspberry Pi is great when you're going to leverage a full blown PC Monitor, but using it for hardware hacking requires a bit of elbow grease

The Beaglebone is great for when you are doing something internety & hardware hacky, but without a full blown pc monitor.

I would have done your project with a beaglebone, fwiw. I'd also have used LEDs instead of incandescents. But this is a great project! Nice work!

Never forget the MSP430, which is either $5 or $10 depending on when you hit it.

Nice one! When I did something similar, I found the clicking sound of the relay more satisfying, than a lightbulb, so I eventually completely removed the lightbulb.

At the time I used MacMini, which was a tiny bit expensive for this very purpose (also not everyone in the office likes a blinking light 24/7) then eventually I came up with the following oneliner:

tail -f "<access_log>" | grep --line-buffered "<whatev>" | sed -ue "s/^.*$/\x07/"

I also needed to set the terminal bell to be a "click" instead of a "bell" for this to sound acceptable during moderate traffic.

For a larger company with more signups/uploads, I'm envisioning a wall of LEDs, controlled by an Arduino board.

Or better yet, make it interactive with something like this:


Peggy's could be fun too:


The Peggy 2 looks really neat. I just might spend some time on this during the summer...

Not quite the same, but your description reminded me of Movable Type, the installation in the New York Times building:


Hook up a USB Flashing Police light to failed CI builds


I think a blend of raspberry pi + phillips hue lights + data + code = awesome product.

Newman 314s idea of email tags triggering a different light colour, combined with this...

I would build one for new email alerts, a different color for each account...

I wonder why he didn't use something like IFTTT.

I built this for our company using IFTTT; we have a little blue siren that goes off when a user converts. It's powered by the production app sending an email to IFTTT which power cycles a Belkin WeMo. Very simple, and it works quite well (excepting for a 10 second or so delay between the conversion and the siren going off).

Awesome! :) \m/

Applications are open for YC Winter 2018

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact