Introduction: High Power RGB LED Moodlamp Which Syncs With Philips Hue

In this instructable the main focus lies on the software which I've created - not so much on the hardware side. You needn't to use a high- power led for this, you can use every RGB- LED you like.

The "High Power RGB LED Moodlamp" is a high power rgb led lamp which can be controlled via http commands with help of the cloud based microcontroller ElectricIMP and an Arduino Uno. It can be synchronized with existing Philips Hue bulbs, it shows the actual local weather or displays your actual Nike Fuel status. You can control it with the the iOS/ Android App "NetIO Controller"

I'm very impressed by all of these very detailed instructables you can find here, so please indulge me because this is my first instructable and I think I've forgotten to write down a lot which could be helpful to rebuild this project. Also the source code is not perfect, so if you have any questions or suggestions please contact me or write down a comment. My only intention to publish all the work is to make it better with the power of the community.

Thank you!


Step 1: Parts and Useful Links

What you need to realize it without a high power LED circuit:

  • (1) Arduino UNO
  • (1) ElectricIMP "SD"-card and a IMPShield or IMP- Breakout board (Sparkfun product page)
  • (1) breadboard for prototyping
  • (1) RGB- LED
  • (1/ optional) Philips Hue starter package

You also need a local webserver. For example a Raspberry Pi with Lighttpd- web server with php- support. You'll find more information here or with help of google:

You need the local webserver because Philips Hue isn't very secure to let it operate in the internet with portforwarding, there is no authentication mechanism.

As mentioned before, the focus lies on the software side, but in the next step you'll find a short description of the high power led circuit I've built...

Step 2: Hardware Setup / LED Driver Shield (optional)

If you want to use a "normal" RGB- LED, connect it to following Arduino- pins: 11(red), 10(green) and 3(blue). The pins must be pwm- pins! Don't forget to use series resistors for the RGB LED. Here will you find a good documentation:

Stack the ElectricIMP- shield to the Arduino. Or connect the IMP- breakout to the Arduino:

The Imp's UART pins are 5 (TX) and 7 (RX) and connected to the Arduino pins RX on 8, TX on 9.

... for a high power LED you need an own voltage supply circuit:

Parts you'll need:

  • (1) high power LED 3*1W RGB
  • (1) case for the lamp (for example an "Ikea Lampan" lamp) just be creative, my one was a birthday present
  • (3) 1 W(!), 1.4 Ohm resistors
  • (3) Mosfets, N-channel (Fairchild FQP50N06L for example)
  • (3) 100k Ohm resistors 1/4W
  • (3) NPN transistors (Fairchild 2N5088BU for examples)
  • (3) Screwterminals (en mass 6 pins)
  • (4) Stackable header pins to build an arduino shield (
  • (1) 12V Powersupply,1500mAh
  • (1) Heatsink for the led module
  • (1) Stripboard
  • (1) self-adhesive thermal pad (M3 thermal pads)

The instructable was very helpful for me. For every color, I've adapted the above shown circuit (rgb), sorry I needed to "steal" the image, technically I couldn't embedded to this instructable.

„The main current flow is through the LED's, through Q2, and through R3. When too much current flows through R3, Q1 will start to turn on, which starts turning off Q2. Turning off Q2 reduces the current through the LED's and R3. So we've created a "feedback loop", which continuously monitors the LED current and keeps it exactly at the set point at all times. transistors are clever, huh!“ Source:

You need to know the specs and size for the resistor R3. In my case it's 1.4Ohm (1Watt resistor!!) - let's calculate:

Have a look at the rgb- module datasheet, there you'll find the right current value: In my case every color of the LED can have 350mA.

Formular: 0.5A (at 0.5A Q1 is switching) / current = resistor (500mA/350mA=1.43 Ohm).

You'll find detailed information about the calculation here:

My circuit:

The RGB-LED module is connected by a screwterminal with the Arduino- pins 11(red), 10(green) and 3(blue). The pins must be pwm- pins!

The power supply (12V) is directly connected to the Arduino. The LED- Modules 12 line is directly soldered to the power jack- pin of the Arduino.

At this moment, that's it from my side how to solder your own RGB- shield. In the next days I'll upload a "Fritzing file" where you can see more details about the circuit. I think you'll be able to find all necessary informations at the links I've posted here.

Step 3: Setup the Software


You'll find all the source code here:

Your local web server must be accessible through the internet with help of port forwarding and a dyndns- name. published a good howto here:

After you've downloaded the files from github, you'll need to customize the files and put them in the right location, let's begin:

Download and unpack the files from my GIT- repository:

Create a folder called "HSL" at your local webserver:


You'll need to secure the HSL folder on your web server with .htaccess. There is no need to reinvent the wheel so please have a look at this documentation (for example):

Put the files from the downloaded and unpacked folder "HTML/HSL" to the "HSL" directory on the web server.

I've configured a samba share at the webserver which included the /var/www directory to copy all these files.

Here you'll find a short samba documentation: to Create a Network Share Via Samba Via CLI (Command-line interface/Linux Terminal) - Uncomplicated, Simple and Brief Way!

Step 4: Setup ElectricIMP Agent & Device Code

If you haven't yet created your ElectricIMP login, please sign in and configure your ElectricIMP device as described here:
or here:

Login to the ElectricImp- DevCenter and create a new model, you can name it "Moodlamp" for example.

Copy and paste the code from the downloaded git- archive "ElectricImpCode/Moodlamp_Controller_AGENT.nut" to the agent code area.

Modify the following lines of the agent code (line 3-5):

//CUSTOM Vars:

webserver <- ""; //Your Webserver URL...

webserverAuth <- "BASE64 KEY" //Your .htaccess authorization key, have a look here:

weathercity <- "New York"; //Your location to display the actual weather with help of


The .htaccess authorization key is encoded as a base64 key, so encode your .htaccess authorization key with help of the above named online tool. Syntax is username:password

Next, copy and paste the "Moodlamp_Controller_DEVICE.nut"- code to the IMP device code area.

Please note your ElectricIMP- API key, you'll need it for the next steps:
You'll find it in the log area, when you build and run the code:

2013-11-12 18:00:07 UTC 1: [Agent] ElectricImp agent started on

Step 5: Setup "Color Control" API

You'll need to edit each of the highlighted PHP- files shown in the screenshot and put in your ElectricIMP api key there (line 2).

I think there could be a more better way to handle the API in one place, but that was the "quick&dirty" solution which I never touched again... ...sorry.

Step 6: Setup NikeFuel API

Edit the "HSL/Fuelband/getFuel.php" and insert your - login data (line 6):

// Please insert here your username and password

$object = new NikeplusFuelbandAPI('', 'PASSWORD');

Step 7: Setup Philips Hue API

To communicate with the Philips Hue base station we need to setup a new user which is allowed to query the needed data.

For this step, you'll find a fantastical documentation at Philips:

Create a user which you can name "electricimp" for example. If you've done this step then you need to modify the "HSL/phue.php"- file:

At line 6 add the local IP-address of the PhilipsHue base station.

At line 7 you'll need to insert the freshly created username.

At line 44 insert your ElectricIMP API key (in the meantime you should learned it by heart ;-) )

6: $hueBaseIp = ''; //Your PhilipsHue base station IP

7: $hueUsername = 'electricimp'; //Your PhilipsHue username

44:'GET', '' value, true); // synchronous request

Step 8: Setup "NetIO for IOS/ Android"

You'll find the app (it's not free) at the nearest Appstore of your choice, it's called "NetIO" by Luvago:



You can build your own UI or just use my predefined configuration:

The NetIO- developers created a online UI- designer where you can customize your buttons, sliders, webviews etc. So the best way is to use this handy tool:

Sign into

Before you upload my JSON- File "ElectricIMP Moodlamp.json" there is some customization to do:

Open the json- file in a texteditor and do a search/replace with the following patterns:

"username": "username" , "password": "password", IMPAPI,

Please be careful and notice the quotes!
The best way is to go through the file manually step by step!

  • The "Username" : "Username" , "Password" : "Password" relates to the user/password combination of your web server

  • IMPAPI is the ElectricIMP key

  • relates to the URL/ IP of the webserver

After you've edited the file upload it with the UI designer.

To load the configuration to your smartphone, open the app and shake the phone, a login will appear where you can login -> choose the uploaded configuration and et voila you should see the interface.

Step 9: Setup Arduino/ Moodlamp API Commands

Open the file "/Arduino_Sketch/ElectricImp_Moodlamp/ElectricImp_Moodlamp.ino" with the Arduino IDE and upload it to your Arduino UNO.

You needn't to customize anything here.

That's it, now you should control your RGB- LED with the APP.

That's it!!!

Additional here is a list of all ElectricIMP Moodlamp http API commands:

"" - set brightness 0-255

"?sat =0" - set HSL saturation 0 - 255

"?hue =0" - set HSL hue 0 - 360

"?red =0" - set RGB red 0 - 255

"?blue =0" - set RGB blue 0 - 255

"?green =0" - set RGB green 0 - 255

"?blue =0" - set RGB blue 0 - 255

"?readr" - get RGB red value

"?readg" - get RGB green value

"?readb" - get RGB blue value

"?readh" - get HSL hue value

"?reads" - get HSL saturation value

"?readbr" - get HSL brightness value

"?tempalarm =0" - set temperature alarm 0=off, 1=on (alarm when temp. changes by 3 degrees Celsius), 2=fix

"?setphsync =0" - set PhilipsHue sync 0=off, 1=on

"?readphsync" - get PhilipsHue sync value if on or off

"?readphbulb" - get the name of the synced PhilipsHue bulb

"?getfuel" - get NikeFuel and change color

"?readt" - get temperature value

Sources, useful links & software which helped me a lot to realize this project:

getRGB() function:

dim_curve idea by Jims:

Philips Hue color conversion:

Slim Framework:

HSL- Slider concept:


Philips Hue:

Nike+ Fuelband API:

Uberspace .htaccess tutorial:

LED driver circuit:

LED driver instructable:



Make It Glow Contest

Participated in the
Make It Glow Contest