{"id":20326165,"url":"https://github.com/tibbis/led-strip-homekit-driver","last_synced_at":"2025-08-19T09:11:34.044Z","repository":{"id":141512115,"uuid":"83800118","full_name":"tibbis/LED-Strip-HomeKit-Driver","owner":"tibbis","description":"An RGB-LED strip driver that can be connected to a smart home with HomeKit using Raspberry Pi and Arduino.","archived":false,"fork":false,"pushed_at":"2017-03-19T20:58:48.000Z","size":12978,"stargazers_count":48,"open_issues_count":1,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-23T15:52:04.196Z","etag":null,"topics":["arduino","diy","homebridge","homekit","nrf24l01","pcb","raspberry-pi","rgb-ledstrip","smarthome"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tibbis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-03-03T13:20:04.000Z","updated_at":"2025-02-05T05:36:28.000Z","dependencies_parsed_at":"2023-09-18T17:56:23.459Z","dependency_job_id":null,"html_url":"https://github.com/tibbis/LED-Strip-HomeKit-Driver","commit_stats":null,"previous_names":["tibbis/led-strip-homekit-driver","gittibbe/led-strip-homekit-driver"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tibbis/LED-Strip-HomeKit-Driver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tibbis%2FLED-Strip-HomeKit-Driver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tibbis%2FLED-Strip-HomeKit-Driver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tibbis%2FLED-Strip-HomeKit-Driver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tibbis%2FLED-Strip-HomeKit-Driver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tibbis","download_url":"https://codeload.github.com/tibbis/LED-Strip-HomeKit-Driver/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tibbis%2FLED-Strip-HomeKit-Driver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271128754,"owners_count":24703879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","diy","homebridge","homekit","nrf24l01","pcb","raspberry-pi","rgb-ledstrip","smarthome"],"created_at":"2024-11-14T19:43:08.710Z","updated_at":"2025-08-19T09:11:34.016Z","avatar_url":"https://github.com/tibbis.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Siri Controlled RGB LED-Strip Project\n#### By Thibault and Ramtin\n### DIY RGB LED strip driver that can be connected to a smart home (HomeKit) using Raspberry Pi and Arduino.\n\nThis is a complete DIY guide going through all steps on how to build your own RGB LED Strip Driver that will be able to work together with Apple HomeKit. This will allow you to control the LED-strip wirelessly through the use of Siri. You simply tell Siri to turn on your LED-strip and set the color to e.g. red and through the combined work of the Raspberry Pi, Arduino Uno and a nicely crafted board, the strip will light up in the color of your choice.\n\n![Demo](https://github.com/GitTibbe/LED-Strip-HomeKit-Driver/blob/master/Pictures/demo.gif?raw=true?)\n\n_\"Hey Siri, put my LED Strip to red.\"_\n\n### Overview\nThis illustrates briefly how the complete system works. Basically, by giving Siri or HomeKit on an Apple device a command, the command will be passed to a homebridge server running on the Raspberry Pi. This command will then be passed to a local node.js server that will execute a program which in-turn will send color data wirelessly to an Arduino that is controlling a LED strip.\n\u003cp align=\"center\"\u003e\n  \u003cimg src=https://raw.githubusercontent.com/GitTibbe/LED-Strip-HomeKit-Driver/master/Pictures/MindMap.png alt=\"mindmap\" \n  width=40% height=40%\u003e\n  \n\u003c/p\u003e\n\n#### Components used for this project\n- RGB-LED Strip (5m with 4 pins)\n- Raspberry Pi 3 Model B+\n- Arduino UNO\n- 2x NRF24L01+ Radio transceiver\n- 3x N-Channel MOSFET transistors (IRLB8721, BUZ100 or similar)\n- 3x 160 Ohm Resistors\n- Circuit Board or breadboard\n\nYou may use any type of N-Channel MOSFET as long as they can handle the amount of current that your LED-strip requires per color channel.\n\n### Design of the circuit board for the LED-strip\nDepending on your resources you can create your PCB as you want as long you follow the following schematic: (rgb-board.sch)\n\u003cp align=\"center\"\u003e\n  \u003cimg src=https://raw.githubusercontent.com/GitTibbe/LED-Strip-HomeKit-Driver/master/Pictures/Schematic.png alt=\"schematic\" \u003e\n\u003c/p\u003e\n\nWe will provide an EAGLE file so that it can be milled on a double-sided copper plate using a PCB milling machine, but if you lack the resources, we will also include illustrative pictures of how to do all of this using traditional breadboards.\n\nIf you are using a breadboard, this image can be helpful:\n\u003cp align=\"center\"\u003e\n  \u003cimg src=https://cdn-learn.adafruit.com/assets/assets/000/002/693/original/led_strips_ledstripbjt.gif?1448059603 alt=\"breadboard\" width=50% height=50% \u003e\n\u003c/p\u003e\n\nThe left you see the EAGLE Board file design (rgb-board.brd) and to the right the result with the soldered transistors and resistors:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=https://raw.githubusercontent.com/GitTibbe/LED-Strip-HomeKit-Driver/master/Pictures/PCB.png alt=\"PCB1\" width=50% height=50%\u003e\n  \u003cimg src=https://raw.githubusercontent.com/GitTibbe/LED-Strip-HomeKit-Driver/master/Pictures/PCB-picture.png alt=\"PCB2\" width=49% height=49%\u003e\n\u003c/p\u003e\n\nNow that the LED strip has been prepared with the Arduino, we will take a look at how to hook it up with the RF24-module to enable receiving signals from the Raspberry Pi.\n#### Connecting RF24 transceiver to Arduino\n\nThis image shows how to connect the wireless transceiver to the Arduino pins.\n\u003cp align=\"center\"\u003e\n  \u003cimg src=https://raw.githubusercontent.com/GitTibbe/LED-Strip-HomeKit-Driver/master/Pictures/RF24-Arduino.png alt=\"PCB\" width=30% height=30%\u003e\n\u003c/p\u003e\n\n##### Implementation of code on Arduino\nThe following code is then implemented into the Arduino. (RGB_DRIVER.ino). Please note that the library RF24.h needs to be installed from e.g: https://github.com/maniacbug/RF24. The pins corresponds to the same pins as the pictures above and the same ID set to the parameter```const uint64_t pipe``` (i.e. in our case: 0xF0F0F0F0E1LL) will be used later on the Raspberry Pi program.\n\n```Arduino\n#include \"nRF24L01.h\"\n#include \"RF24.h\"\n#include \"RF24_config.h\"\n#include \u003cSPI.h\u003e\n/////////////////////////////-RF24-////////////////////////////////////////\nRF24 radio(9, 10); //RF24 pins\nconst uint64_t pipe = 0xF0F0F0F0E1LL; //ID\nunsigned long RGB = 0;\n/////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////-RGB-/////////////////////////////////////////\n#define REDPIN 5\n#define GREENPIN 6\n#define BLUEPIN 3\n#define FADESPEED 1     // make this higher to slow down fading\nint r, g, b, rPrev, gPrev, bPrev, f = 0;\nint blueMask = 0xFF0000, greenMask = 0xFF00, redMask = 0xFF; //decoding masks\n//////////////////////////////////////////////////////////////////////////\n\nvoid setup(void) {\n\n  //Radio module setup\n  radio.begin();\n  radio.openReadingPipe(1, pipe);\n  radio.startListening();\n\n  //RGB setup\n  pinMode(REDPIN, OUTPUT);\n  pinMode(GREENPIN, OUTPUT);\n  pinMode(BLUEPIN, OUTPUT);\n\n  //serial Setup\n  Serial.begin(9600);\n  Serial.println(\"Started Listening...\");\n}\n\nvoid loop(void)\n{\n\n  if (radio.available()) { //signal received\n\n    if ( !radio.read(\u0026RGB, sizeof(unsigned long)) ) {\n      Serial.println(\"ACK not received by client.\");\n    }\n\n    //save previous values\n    rPrev = r;\n    gPrev = g;\n    bPrev = b;\n    int[3] prevColors = [rPrev, gPrev, bPrev]; //array with previous color values\n\n    //decode RGB values\n    r = (RGB \u0026 0xFF);\n    g = ((RGB \u0026 0xFF00) \u003e\u003e 8);\n    b = ((RGB \u0026 0xFF0000) \u003e\u003e 16);\n    int[3] colors = [r,g,b]; //array with color values\n\n    Serial.print(\"Received RGB-value: R= \"); Serial.print(r); Serial.print(\", G= \");\n    Serial.print(g); Serial.print(\", B= \"); Serial.println(b);\n\n    //change color with a smooth transition\n    changeColor(colors, prevColors);\n\n  }\n}\n\n//change color with a smooth transition\nvoid changeColor(int[3] colors, int[3]prevColors){\n  //To determine increase or decrease\n  int diffR = colors[0]-prevColors[0];\n  int diffG = colors[1]-prevColors[1];\n  int diffB = colors[2]-prevColors[2];\n\n  int i = prevColors[0];\n  int j = prevColors[1];\n  int k = prevColors[2];\n\n  while (i==r \u0026\u0026 j==g \u0026\u0026 k==b)\n  {\n    //Red color\n    if (i!=r){\n      if (diffR\u003e0) i++;\n      else  i--;\n      analogWrite(REDPIN, i);\n\n    }\n    //Green color\n    if (k!=g){\n      if (diffG\u003e0) j++;\n      else  j--;\n      analogWrite(GREENPIN, j);\n    }\n    //Blue color\n    if (k!=b){\n      if (diffB\u003e0) k++;\n      else  k--;\n      analogWrite(BLUEPIN, k);\n    }\n    delay(FADESPEED);\n  }\n}\n```\n\n### Design and create your own box\nWe provide you 3D CAD files for a 3D-printable box that fits an Arduino UNO and our PCB that we used. Depending on your circuit board dimensions you may need to create your own box. It needs 3 openings, one for the Arduino USB and DC inputs, and one RGB-LED strip output port (in our case 4 pins). The box should contain the Arduino, circuit board and RF24 transceiver with all its wires.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=https://raw.githubusercontent.com/GitTibbe/LED-Strip-HomeKit-Driver/master/Pictures/BoxPicture1.png alt=\"cad1\" width=50% height=50%\u003e\n  \u003cimg src=https://raw.githubusercontent.com/GitTibbe/LED-Strip-HomeKit-Driver/master/Pictures/BoxPicture2.png alt=\"cad2\" width=49% height=49%\u003e\n\u003c/p\u003e\n\n### Connecting RF24-transceiver to Raspberry Pi 3 B+\nWhen the homebridge and node.js servers are running on the Raspberry Pi they will need to send the data received from HomeKit to the Arduino wirelessly. The image below shows how to connect the RF24 transceiver to Raspberry Pi using GPIO pins.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=https://raw.githubusercontent.com/GitTibbe/LED-Strip-HomeKit-Driver/master/Pictures/RF24-RPI.png alt=\"RF24-RPI\" width=30% height=30%\u003e\n\u003c/p\u003e\n\n#### Implementation of code on Raspberry Pi\nThis C++ program (RF24-remote.cpp + makefile) will be executed by the node.js server and send data through the transceiver. Please note that the library RF24.h must be installed from github (link:TMRh20) for it to compile and install successfully.\n\n```C++\n#include \u003ccstdlib\u003e\n#include \u003cmath.h\u003e\n#include \u003ciostream\u003e\n#include \u003csstream\u003e\n#include \u003cstring\u003e\n#include \u003cunistd.h\u003e\n#include \u003cRF24/RF24.h\u003e\n\nusing namespace std;\n\n//RPi genericpinconnection                                                      $\nRF24 radio(25,8);\n\n// Radio pipe addresses for the 2 nodes to communicate.\nconst uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };\n\nint main(int argc, char** argv){\n        unsigned int RGB=atoi(argv[1]);\n        cout \u003c\u003c \"Sending message to LED-Driver…\\n\";\nif (argv[1]){\n                // Setup and configure rf radio\n                radio.begin();\n\n                // Dump the configuration of the rf unit for debugging\n                //radio.printDetails();\n\n        radio.openWritingPipe(pipes[0]);        \n\n                printf(\"Now sending (RGB: %d)...\\n\", RGB);\nbool ok = radio.write( \u0026RGB, sizeof(unsigned int) ); //send mes$\n\nif (!ok){\n                        printf(\"Failed.\\n\");\n                        return 0;\n                }else printf(\"Message Sent!\\n\");\n\n        }else printf(\"Message not sent. No argument was given…\\n\");\n  return 0;\n}\n```\n\n## Setup of homebridge and node.js servers\nNow that all hardware is connected and its corresponding code implemented, the last and a bit tricky part of this guide is left.\n#### Install Homebridge\nFirst you will need to install homebridge on your Raspberry Pi by following this guide: link: https://github.com/nfarina/homebridge/wiki/Running-HomeBridge-on-a-Raspberry-Pi.\n\nAfter you have managed to successfully install homebridge you will need to create a background service for it using serviced. Look at this guide: https://github.com/nfarina/homebridge/wiki/Running-HomeBridge-on-a-Raspberry-Pi#running-homebridge-on-bootup-systemd.\n\nBy doing that it will automatically start on boot and as well after eventual crashes.\n#### Homebridge Plugins and config.js\nYou will have to install this plugin: `npm -install http-better-rgb.`\n\nThen you can use this config.js sample code for homebridge:\n```javascript\n{\n        \"bridge\": {\n                \"name\": \"Homebridge\",\n                \"pin\": \"987-65-431\",\n                \"username\": \"CC:22:3D:E3:CE:32\"\n        },\n\n\"accessory\": \"HTTP-RGB\",\n        \"name\": \"LED Strip\",\n\n        \"switch\": {\n            \"status\": \"http://localhost:8080/\",\n            \"powerOn\": \"http://localhost:8080/\",\n            \"powerOff\": \"http://localhost:8080/?name=0\"\n        },\n\n        \"brightness\": {\n            \"status\": \"http://localhost:8080/\",\n            \"url\": \"http://localhost:8080/?name=%s\"\n        },\n\n        \"color\": {\n            \"status\": \"http://localhost:8080/\",\n            \"url\": \"http://localhost:8080/?name=%s\",\n            \"brightness\": false\n        }\n}\n]\n}\n```\nYou can also add other accessories that you already have in your home that are compatible with various homebridge plugins.\n\n### Node.js Server\nUsing apache2 and nodejs we can run this server on localhost. This plugins need to be installed for it to work: `npm -install -g hex-rgb`and `npm -install -g http`.\n\n```javascript\n#!/usr/bin/env nodejs\nvar http = require('http');\nvar url = require('url');\nvar hexRgb = require('hex-rgb');\nconst exe = require('child_process').exec;\n\nvar hex;\nvar rgb\n\nvar server = http.createServer(function(req, res) {\n\n  var queryData = url.parse(req.url, true).query;\n  res.writeHead(200);\n\n  if (queryData.name) {\n    hex=queryData.name;\n    var rgb_temp=hexRgb(hex); //convert to rgb from hex\n\n    //encode to 24-bit RGB value\n\n    //command to run\n    var cmd = 'sudo rf24-RGB-remote ' +rgb;\n\n    exe( cmd ,(error, stdout, stderr) =\u003e {\n      if (error) {\n        throw error;\n      }\n      //console output\n      console.log('--------\\nHEX-value: '+hex+\", RGB-value: \"+rgb_temp+\"\\n\");\n\n      //output on web page\n      res.end('RGB-remote server is running! \\nRGB-value=' + rgb+'\\n\\nRF24:');\n    });\n\n  }     else { //no argument\n    res.end(\"Server is running! No hex value was given in url... \");\n  }\n\n});\nserver.listen(8080);\n\nconsole.log('Starting server. Listening on localhost:8080');\n```\n\n### [This document is being updated continuously...]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftibbis%2Fled-strip-homekit-driver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftibbis%2Fled-strip-homekit-driver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftibbis%2Fled-strip-homekit-driver/lists"}