IKEA TIVED, now an IoT floor lamp

Floor Lamps

IKEA TIVED LED wall clamp spotlight

Published on November 28th, 2016 |

by fbret

0

IKEA TIVED, now an IoT floor lamp

IKEA TIVED, now an IoT floor lamp

Photo: IKEA.com

A few months ago, Particle.io gave me a bunch of sample photons for mentioning them in my DefCon 24 talk. I needed something to use them and that reading lamp that is not connected to my home automation is bugging me…

So, the Ikea TIVED is a simple Led on/off floor lamp… not anymore! Add a Particle Photon to it and you have a dimmable Led Internet of Things:

  • One can still turn the light on & off via the foot switch.
  • Now one can also turn it on & off via the internet.
  • It’s also now dimmable!

The hardest was  fitting everything in there!

First, you need the following:

20161125_121922

Top left: Particle Photon (w/out headers as it won’t fit anymore!)

Top right: Generic transistor. I had a TIP-42 PNP laying around. DO NOT ATTEMPT to wire the Led through the Photon… you’ll fry it!

The case of the foot switch. How did I open it you ask?! Yes, those screws are in the way!

20161125_163836

Not to worry… an electric screwdriver with a flat head and sufficient vertical force will unscrew them :-)

Critical mods to the plastic shell:

  • for the base: remove the top clips and carve a slot for the board to sink into. Also cut part of the screw stands.
  • for the cover: thin the cover as much as possible and trim some of the screw post and button cylinder.
  • for the button: take out part of the flange.

Wiring is relatively simple:

Screen Shot 2016-11-25 at 5.04.26 PM

In other words, D1 is the controller of the transistor that powers the switch.

D6 reads the status of the foot switch to turn things on or off.

 

Here’s the source code:

<code>

#include “math.h”

int dim = 0;
int toggle;

void setup() {
pinMode(D1,INPUT);
pinMode(D6,INPUT_PULLUP);
toggle = digitalRead(D6);
Particle.function(“SetDim”,SetDim);
Particle.variable(“DimValue”, &dim, INT);

}

 

void loop() {

if (digitalRead(D6)!=toggle)
{
if (dim>0)
dim =0;
else
dim = 254;
toggle = digitalRead(D6);
}

for (int i=0;i<100;i++)
{
if (dim<254)
{
//off duty cycle
if (getPinMode(D1)!=INPUT)
{
pinMode(D1,INPUT);

}

delayMicroseconds(1*(254-dim));
}

if (dim>0)
{
//on duty cycle
if (getPinMode(D1)!=OUTPUT)
{
pinMode(D1,OUTPUT);
digitalWrite(D1, 0);
}
delayMicroseconds(1*(dim));
}
}

}

int SetDim(String command) {
/* Particle.functions always take a string as an argument and return an integer.
Since we can pass a string, it means that we can give the program commands on how the function should be used.
In this case, telling the function “on” will turn the LED on and telling it “off” will turn the LED off.
Then, the function returns a value to us to let us know what happened.
In this case, it will return 1 for the LEDs turning on, 0 for the LEDs turning off,
and -1 if we received a totally bogus command that didn’t do anything to the LEDs.
*/

dim = (254*command.toInt()/100);
return dim;
}

</code>

 

Once you have it all wired, do test before going further… I had to try a couple times before I could fit everything and still have functional electronic!

20161125_152932

Now beyond being able to turn on & off your lamp with the foot switch, you can control that lamp from the web by posting to http://ift.tt/2fs3LPn  with params=[DimValue]&access_token=[AccessToken] as the post data where DimValue is between 0 (off) & 100 (full on)

Here’s a simple curl request for testing:

curl http://ift.tt/2fs3LPn -d params=50 -d access_token=[AccessToken]

:-)

Enjoy!

– by Fred

http://ift.tt/oBHoI7

Leave a Reply