{"id":2085,"date":"2018-11-04T01:49:36","date_gmt":"2018-11-04T00:49:36","guid":{"rendered":"http:\/\/www.sciencetronics.com\/greenphotons\/?p=2085"},"modified":"2025-06-29T19:43:01","modified_gmt":"2025-06-29T17:43:01","slug":"hacking-ikea-tradfri-lighting-automation","status":"publish","type":"post","link":"https:\/\/www.sciencetronics.com\/greenphotons\/?p=2085","title":{"rendered":"Hacking IKEA tr\u00e5dfri lighting automation"},"content":{"rendered":"<p>I recently visited IKEA again and got interested in their affordable line of home automation\/LED lighting products called <strong>TR\u00c5DFRI<\/strong> (meaing <em>wireless <\/em>in a play-with-words kind of Swedish). Of course there was already an internet community active in hacking these devices and I joined in.<\/p>\n<h3>Getting started<\/h3>\n<p>I installed the gateway and after pairing devices to switches and switches to the gateway I finally could get around and experiment. I found quite a good introduction into hacking the gateway by sending your own commands here: <a href=\"https:\/\/learn.pimoroni.com\/tutorial\/sandyj\/controlling-ikea-tradfri-lights-from-your-pi\" target=\"_blank\" rel=\"noopener\">PIMORONI: Controlling IKEA Tr\u00e5dfri Lights from your Pi<\/a> &#8211; however after a couple of hours trying I had to notice that something in the description was heavily outdated.<\/p>\n<p>During 2017 IKEA had reacted to some early security issues and introduced a new layer of safety in the user identification scheme. This had in the meantime been fixed in the underlying GIT repository by <a href=\"https:\/\/github.com\/hvanderlaan\/ikea-smartlight\" target=\"_blank\" rel=\"noopener\">Harald van der Laan<\/a> but sincePimoroni had insisted on improving the original code in their own fork, this new change was of course not reflected in their code which I had tested and failed with. In the mean time I have been in contact with Pimoroni and they told me that they are working on an updated version.<\/p>\n<h3>Control from a Raspberry<\/h3>\n<p>Well I don&#8217;t know what the original improvements to the code from Harald van der Laan might have been, but after cloning his repository onto the Raspberry Pi I ad been using for my experiments, everything worked out quite well and only a couple of minutes later I was controlling my first lamps from the commandline in a Putty terminal:<\/p>\n<figure id=\"attachment_2086\" aria-describedby=\"caption-attachment-2086\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.sciencetronics.com\/greenphotons\/?attachment_id=2086\" rel=\"attachment wp-att-2086\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-2086\" src=\"https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/tradfri_use-300x154.png\" alt=\"\" width=\"300\" height=\"154\" srcset=\"https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/tradfri_use-300x154.png 300w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/tradfri_use-768x394.png 768w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/tradfri_use-150x77.png 150w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/tradfri_use-400x205.png 400w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/tradfri_use.png 877w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-2086\" class=\"wp-caption-text\">Putty terminal showing the communication with the IKEA TR\u00c5DFRI gateway.<\/figcaption><\/figure>\n<h3>Hardware hacking<\/h3>\n<p>It didn&#8217;t take me long to disassemble a GU10 LED light with built-in TR\u00c5DFRI remote control in order to extract the Zigbee module according to the description <a href=\"https:\/\/www.instructables.com\/id\/Zigbee-LED-Strip-Dimmer-IKEA-Hack\/\">by ehsmaes on Instructables<\/a>. But it wasn&#8217;t before a couple of minutes ago that I actually desoldered the Zigbee board and connected it to an LED on a breadboard for further experiments:<\/p>\n<figure id=\"attachment_2089\" aria-describedby=\"caption-attachment-2089\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.sciencetronics.com\/greenphotons\/?attachment_id=2089\" rel=\"attachment wp-att-2089\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-2089\" src=\"https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/IMGP7269a_770-300x239.jpg\" alt=\"\" width=\"300\" height=\"239\" srcset=\"https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/IMGP7269a_770-300x239.jpg 300w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/IMGP7269a_770-768x612.jpg 768w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/IMGP7269a_770-150x120.jpg 150w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/IMGP7269a_770-400x319.jpg 400w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/IMGP7269a_770.jpg 775w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-2089\" class=\"wp-caption-text\">IKEA TR\u00c5DFRI Zigbee module on a breadboard.<\/figcaption><\/figure>\n<h3>PWM internals<\/h3>\n<p>Since this is a dimable LED it supports setting brightness values between 0 and 100 using the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Constrained_Application_Protocol\">CoAP interface<\/a> unlike the other receivers which I have been using so far and which are switched wall socket adapters. But how do these brightness values translate into the corresponding duty cycles of the output pwm-signal of the Zigbee module &#8211; and what are the general parameters of this output, anyway?<\/p>\n<figure id=\"attachment_2090\" aria-describedby=\"caption-attachment-2090\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.sciencetronics.com\/greenphotons\/?attachment_id=2090\" rel=\"attachment wp-att-2090\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-2090\" src=\"https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/IMGP7270_800-300x239.jpg\" alt=\"\" width=\"300\" height=\"239\" srcset=\"https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/IMGP7270_800-300x239.jpg 300w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/IMGP7270_800-768x611.jpg 768w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/IMGP7270_800-150x119.jpg 150w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/IMGP7270_800-400x318.jpg 400w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/IMGP7270_800.jpg 796w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-2090\" class=\"wp-caption-text\">PWM signal at the output of the Zigbee module.<\/figcaption><\/figure>\n<p>I don&#8217;t feel the need right now to dig deeper into the firmware of the Zigbee module, since it is enough for me to perhaps repurpose some of these modules out of legit GU10 TR\u00c5DFRI lamps (the cheapest item of the series), but if I wanted to, I would start at <a href=\"https:\/\/github.com\/basilfx\/TRADFRI-Hacking\">basilfx GIT repository<\/a>. The actual layout of the module has been hacked by <a href=\"https:\/\/tradfri.blogspot.com\/2017\/04\/pinout-of-tradfri-zigbee-module.html\">Mikael Sundin<\/a>:<\/p>\n<figure id=\"attachment_2088\" aria-describedby=\"caption-attachment-2088\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.sciencetronics.com\/greenphotons\/?attachment_id=2088\" rel=\"attachment wp-att-2088\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-2088\" src=\"https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/tradfri_pinout-300x225.png\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/tradfri_pinout-300x225.png 300w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/tradfri_pinout-768x576.png 768w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/tradfri_pinout-1024x768.png 1024w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/tradfri_pinout-150x113.png 150w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/tradfri_pinout-400x300.png 400w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/tradfri_pinout.png 1058w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-2088\" class=\"wp-caption-text\">The pinout of the TR\u00c5DFRI module -as reverse engineered by Mikael Sundin.<\/figcaption><\/figure>\n<p>OK, so what are the parameters of the pwm-signal now?<\/p>\n<div align=\"center\">\n<table style=\"border-collapse: collapse; width: 43.6598%; height: 299px;\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"width: 30%;\">Signal level<\/td>\n<td style=\"width: 70%;\">standard 3.3 V CMOS<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 30%;\">PWM frequency<\/td>\n<td style=\"width: 70%;\">600 Hz<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 30%;\"><\/td>\n<td style=\"width: 70%;\">\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"width: 50%; text-align: center;\"><strong>Brightness value<br \/>\n<\/strong><\/td>\n<td style=\"width: 50%; text-align: center;\"><strong>Duty cycle<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">0<\/td>\n<td style=\"width: 50%; text-align: center;\">0% (off)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">5<\/td>\n<td style=\"width: 50%; text-align: center;\">5.7%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">10<\/td>\n<td style=\"width: 50%; text-align: center;\">6.6%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">15<\/td>\n<td style=\"width: 50%; text-align: center;\">7.7%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">20<\/td>\n<td style=\"width: 50%; text-align: center;\">9.0%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">25<\/td>\n<td style=\"width: 50%; text-align: center;\">10%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">30<\/td>\n<td style=\"width: 50%; text-align: center;\">12%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">35<\/td>\n<td style=\"width: 50%; text-align: center;\">14%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">40<\/td>\n<td style=\"width: 50%; text-align: center;\">17%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">45<\/td>\n<td style=\"width: 50%; text-align: center;\">19%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">50<\/td>\n<td style=\"width: 50%; text-align: center;\">22%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">55<\/td>\n<td style=\"width: 50%; text-align: center;\">26%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">60<\/td>\n<td style=\"width: 50%; text-align: center;\">30%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">65<\/td>\n<td style=\"width: 50%; text-align: center;\">35%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">70<\/td>\n<td style=\"width: 50%; text-align: center;\">41%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">75<\/td>\n<td style=\"width: 50%; text-align: center;\">47%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">80<\/td>\n<td style=\"width: 50%; text-align: center;\">55%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">85<\/td>\n<td style=\"width: 50%; text-align: center;\">64%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">90<\/td>\n<td style=\"width: 50%; text-align: center;\">75%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">95<\/td>\n<td style=\"width: 50%; text-align: center;\">87%<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; text-align: center;\">100<\/td>\n<td style=\"width: 50%; text-align: center;\">100% (constantly on)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>As you can see it is quite a non-linear scale &#8211; as expected for a smoothly dimming light source due to the non-linearity of our eyes.<\/p>\n<figure id=\"attachment_2096\" aria-describedby=\"caption-attachment-2096\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.sciencetronics.com\/greenphotons\/?attachment_id=2096\" rel=\"attachment wp-att-2096\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-2096\" src=\"https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/20181104_tradfri_pwm-300x236.png\" alt=\"\" width=\"300\" height=\"236\" srcset=\"https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/20181104_tradfri_pwm-300x236.png 300w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/20181104_tradfri_pwm-150x118.png 150w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/20181104_tradfri_pwm-400x314.png 400w, https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/20181104_tradfri_pwm.png 737w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-2096\" class=\"wp-caption-text\">Relation between the set brightness value using CoAP and the PWM duty cycle.<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>I recently visited IKEA again and got interested in their affordable line of home automation\/LED lighting products called TR\u00c5DFRI (meaing wireless in a play-with-words kind of Swedish). Of course there was already an internet community active in hacking these devices and I joined in. Getting started I installed the gateway and after pairing devices to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2089,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[22,11,8,40],"tags":[],"class_list":["post-2085","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-computers_en","category-electronics_en","category-everything_en","category-leds","entry","has-media"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.sciencetronics.com\/greenphotons\/wp-content\/uploads\/2018\/11\/IMGP7269a_770.jpg","jetpack_shortlink":"https:\/\/wp.me\/p48grL-xD","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=\/wp\/v2\/posts\/2085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2085"}],"version-history":[{"count":11,"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=\/wp\/v2\/posts\/2085\/revisions"}],"predecessor-version":[{"id":2600,"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=\/wp\/v2\/posts\/2085\/revisions\/2600"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=\/wp\/v2\/media\/2089"}],"wp:attachment":[{"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}