In this article we will configure an RGB LED strip in HAP-NodeJS. I will also explain how to build the accessory physically, using a Wemos D1 mini board, an RGB LED strip and a few transistors.
Here too, I used the MQTT protocol (Mosquitto) to make the Raspberry Pi and the Wemos D1 mini communicate with each other.
As a prerequisite, you should of course have a Raspberry Pi with Mosquitto and HAP-NodeJS correctly installed.
Below are the links to the two guides:
Apple HomeKit on Raspberry Pi
MQTT Broker (Mosquitto) on Raspberry Pi
You must also have installed the npm packages for the MQTT module; if you haven’t, the commands are as follows:
cd /home/pi/HAP-NodeJSsudo npm install mqtt --save
sudo npm install mqtt -g
To start, connect to your Raspberry Pi via SSH and run the following commands to download and install the accessory.
cd /home/pi/HAP-NodeJS/src/accessories
wget https://fargionconsulting.com/wp-content/uploads/2020/02/RGBtestLight_accessory.ts
Now, if you have set up HAP-NodeJS to start automatically, restart the Raspberry Pi so that HAP-NodeJS detects the new accessory.
Also, if you have chosen to use BridgedCore.ts, the accessory will automatically appear alongside the accessory you created and paired previously; if you are using Core.ts, you will need to add the new accessory from your Apple device. Here too, pairing is done with the code 031-45-154.
Now let’s move on to the hardware. Unfortunately, unlike in the previous guide, there is no ready-made shield here: you will need to build it yourself, or with the help of a friend who is handy with a soldering iron. The components required are easy to find (especially online) and not particularly expensive.
The components I recommend are:
– 1 x Wemos D1 mini board;
– 3 x TIP120 or TIP122 transistors;
– 1 x 5V RGB LED strip (3 m max.) (so that it can run off the Wemos board’s 5V supply)
Make the connections as shown in the diagram below. I have also attached the Fritzing and Gerber files for anyone who wants to have the board manufactured, so that only the components need to be soldered.

Now let’s move on to the Arduino code, which you can download here.
Here too, note that some libraries need to be installed in the Arduino IDE; they are listed below:
- ArduinoOTA (available from the Library Manager in the Arduino IDE)
- PubSubClient by Nick O’Leary (available from the Library Manager in the Arduino IDE)
- RemoteDebug by Joao Lopes (available from the Library Manager in the Arduino IDE)
Now, before uploading the Arduino code to the Wemos D1 mini board (as well as selecting the right serial port, the correct board and the correct baud rate), we need to update the Arduino code with the name and password of our Wi-Fi network and the IP address of our Raspberry Pi — and that’s it!

Enjoy!
