ESP8266 meets Ikea Fado lamp

I bought a couple of Fado lamps for my kids rooms, and came across a video on youtube showing someone who put RGD led strips inside them. It made a nice effect, and i thought it would be fun to do something similar.

The plan was to install a NeoPixel ring in the base of the Fado lamp, together with the esp8266. Then wire it all up, so it workes just like a ordinary lamp, aswell as showing RGB animations.

So i ordered up some 24led RGB rings from China. They are copies of Adafruits NeoPixel rings, but work the same way. 

The software i decided to use was the McLightning which supports a load of different animations, but also make it possible to adjust brightness and the color channels individually.

https://github.com/toblum/McLighting/

First thing i needed to do was remove all the standard wiring and bulb mount from the Fado base. By doing that i was left with a fairly clean base where i could mount the electronics.

Fado lamp base striped down

As luck would have it, the NeoPixel ring dropped down perfectly into the inner circle of the base, almost like they were made for each other. I made a cut in the inner ring to guide the wiring through, which i later found out was not needed as i routed all wiring inside the ring and out the bottom.

I had to figure out where to put the ESP8266, it would’nt fit underneath the base, so i decided to create a small platform in the center where it could rest. I used some plexiglass and hotglued this onto the center pylon.

Plexiglass platform for the esp8266 hotglued in place

I then moved on to solder wires to the NeoPixel rings vcc,gnd and in terminals. After some trial and error, i ended up having the wires going into the ring, so everything can be wired up without having to have wired above the leds.

Wires soldered onto the NeoPixel

Next, the ring was hotglued onto the base.

NeoPixel glued onto base

Then the esp8266 was fastened to the small plexi platform in the center using some double sided tape.

ESP8266 and NeoPixel in place

The ESP8266 only outputs 3.3v on the GPIO pins, so i created a power harness which splits the 5v ( and ground ) coming out of the poweradapter. It then feeds the esp8266 and the ring seperatly. 

Power harness

The harness has a female microusb plug in one end, and 2x5v and 2xgnd on the other end. We are powering the esp8266 via the GPIO pins instead of using the microusb plug. 

The signal wire from the neopixel connects to a free pin( i used pin 5 )

The harness is threaded through the bottom and hotglued underneath the base plate. That way i can easily connect power to the installation from below.

Harnes sticking out base bottom

The last thing to do is to mount it all together, and fire it up.

McLightning has a built in webserver, which exposes alot of functionality through rest and websockets. It also have a neat webpage which lets you controlle several aspects of the lamp.

The kids are running this webpage on their tablets making them able to tune the light to their preference. 

I also created a small script which runs periodicly, turning the lamp on and off at different times of day.

So in the morning, the lamp fades in from dimmed yellow to bright over a period of 30 minutes. It also fades out in the evening when its bedtime. It turns off when we leave home, and turn on when we get home. 

Here is the script runnning in crontab which i wrote :
PHP script is placed in /opt on some local server. This could ofcourse run wherever you like.

<?php
$endpoint = $argv[1];
$method = $argv[2];

$fado = new Fado($endpoint);

switch( $method ) {
 case 'wakeup' :
 $fado->wakeup($argv[3],$argv[4],$argv[5],$argv[6],$argv[7]);
 break;
 case 'sleep' :
 $fado->sleep($argv[3],$argv[4],$argv[5],$argv[6],$argv[7]);
 break;
 case 'off' :
 $fado->off();
 break;
 case 'on' :
 $fado->on( $argv[3] );
 break;
}

class Fado {

 protected $lampEndpoint;

 function Fado( $lampEndpoint ) {
 $this->lampEndpoint = $lampEndpoint;
 }

 public function off() {
 file_get_contents($this->lampEndpoint . "/set_brightness?p=0");
 file_get_contents($this->lampEndpoint . "/off");
 print "Off - $this->lampEndpoint \n";
 }

 public function on($mode="rainbow") {
 file_get_contents($this->lampEndpoint . "/set_brightness?p=100");
 file_get_contents($this->lampEndpoint . "/$mode");
 print "On - $this->lampEndpoint $mode \n";
 }

 public function wakeup($fadeinTimeMinutes = 60, $startBrightness=0,$r=0,$g=0,$b=0 ) {
 file_get_contents($this->lampEndpoint . "/set_brightness?&p=$startBrightness");
 file_get_contents($this->lampEndpoint . "/set_mode?m=0&r=$r&g=$g&b=$b");

 $sleepTime = ( $fadeinTimeMinutes * 60 ) / (100-$startBrightness);
 for( $brightness=$startBrightness;$brightness<=100;$brightness++ ) {
 print "Wakeup - Dimming to $brightness on $this->lampEndpoint sleeping $sleepTime\n";
 file_get_contents($this->lampEndpoint."/set_brightness?&p=$brightness");
 sleep($sleepTime);
 }
 }

 public function sleep($fadeoutTimeMinutes = 60, $startBrightness=100,$r=0,$g=0,$b=0 ) {
 file_get_contents($this->lampEndpoint . "/set_brightness?&p=$startBrightness");
 file_get_contents($this->lampEndpoint . "/set_mode?m=0&r=$r&g=$g&b=$b");

 $sleepTime = ( $fadeoutTimeMinutes * 60 ) / ($startBrightness);
 for( $brightness=$startBrightness;$brightness>=0;$brightness-- ) {
 print "Sleep - Dimming to $brightness on $this->lampEndpoint sleeping $sleepTime\n";
 file_get_contents($this->lampEndpoint."/set_brightness?&p=$brightness");
 sleep($sleepTime);
 }

 file_get_contents($this->lampEndpoint . "/off");
 }

}
?>

 

Crontab :

15 19 * * 1,2,3,4,7 /usr/bin/php /opt/fado.php "http://<LAMP IP>" "sleep" 30 100 0 0 255  >> /var/log/fado.log
45 19 * * 5,6 /usr/bin/php /opt/fado.php "http://<LAMP IP>" "sleep" 30 100 0 0 255  >> /var/log/fado.log

15 06 * * 1,2,3,4,5 /usr/bin/php /opt/fado.php "http://<LAMP IP>" "wakeup" 30 0 255 88 0  >> /var/log/fado.log
30 06 * * 6,7 /usr/bin/php /opt/fado.php "http://<LAMP IP>" "wakeup" 30 0 255 88 0  >> /var/log/fado.log

00 08 * * 1,2,3,4,5 /usr/bin/php /opt/fado.phpp "http://<LAMP IP>" "off"  >> /var/log/fado.log

00 17 * * 1,2,3,4,5 /usr/bin/php /opt/fado.php "http://<LAMP IP>" "on" "rainbow"  >> /var/log/fado.log

Demo of rainbow function : 

One thought on “ESP8266 meets Ikea Fado lamp”

Leave a Reply