Raspberry Pi Domotica – Disco lightbulb!

I’ve continued my domotica project but switched to Raspberry Pi. Combined with NodeJS and a relay module I’ve made an interactive disco lightbulb in my living room!

As you may know from previous posts, I was working on a project that could boost my Arduino skills. The project being a domotica system which can make the lights in my home switch on/off using my smartphone.

A lot has happened since the last post, the biggest change being that I’ve switched from Arduino to a Raspberry Pi 2. I’ve found that working with internet-based applications such as my Domotica-system to be very hard with Arduino. It required loads of hacks/workarounds to be compatible with the Arduino platform. I’ve got more projects planned for Arduino, but my Domotica project will be based on Raspberry Pi.

Having said that: I’ve made progress! Fancy progress:

Generic components

I like generic components over specific components. I could have bought an Arduino relay shield (a specific component for Arduino), but I’ve bought a generic electical relay and now it doesn’t matter in what configuration I use it. A change of ‘eco systems’ would make me have to buy another shield for my Raspberry.

RelayModule

The generic relay module I bought

This is the same line of thought I use in my day-to-day work as a front-end developer: I really don’t understand the whole app-business. I think it’s bad to try to keep people in the iOS or Android ecosystem because it excludes people as well. How many times you’ve seen a nice game on iOS or Android but that game isn’t available for your platform? A lot of apps I see can be built with open standards and should be websites anyone can use instead of apps you can only use when you’re part of the same ecosystem the app is built for.

Starting simple

Anyway: this was the plan I drew on my whiteboard:

RaspberryPi domotica: diagram

I found myself thinking: “Well that shouldn’t be so hard”. And really, the technical aspect of it really wasn’t if you do front-end development as a job. I’m not really experienced with NodeJS, but I had all the prerequisites to started working with it. It was the electrical circuit that took more time than I estimated. 230V/10A can be deadly when tinkered with in the wrong way, and I’ll admit I was a bit scared to attach my Disco creation to the power grid of my home.

I’ve found the solution in a way a lot of programmers think: “Start simple, then build up”. So, I started simple with connecting an LED to an external power source I got out of a Doritos can speaker gadet (3x AAA batteries, 4.5V). Touching this wouldn’t fry my body so I was comfortable with testing the circuit this way. The beauty of the circuit below is that the led is powered with it’s own power source, just what I need only less deadly:

RaspberryPi domotica: LED

Getting NodeJS to work

NodeJS projects consist out of two parts: a client part and a sever part. This is also the case in this project, sending and receiving the commands each client gives. On the press of a button the server side decides if the led is on or not and toggles it’s state:

High voltage!

I had to cut the power in my home to be sure I wouldn’t be electrocuted when attaching the Disco bulb creation to the grid. I took a separate plate of wood on which I attached the Raspberry Pi and the Relay switch. A thing to note when you’re going to work with relay swiches on high voltage: take a look at the bottom! It’s a raw component so you don’t want to touch the soldering on the bottom, and you need to have some isolating material beneath it when using it.

RaspberryPi domotica: attached to grid!RaspberryPi domotica: attached disco lightbulb

Conclusion:
I really like the disco lightbulb being controlled via my smartphone. If I open up a port on my router I’ll be able to access the local network from outside my home, and start a disco party in my home from anywhere in the world! My girlfriend is on a short holiday with some friends, I hope she likes what I’ve done to the living room ^_^

Lessons learned:

  • Generic components are better than specific components because of reusability across ecosystems
  • Working with 230V in your projects requires good preparation
  • I can’t dance without music. Next project? :-)