Introduction: Modified RGBW LED Strip Controller, PIR Controlled, ESP8285

About: I like to combine electronics like Arduino's, ESP8266 etc with 3D designing and 3D printing.

Above my desk at home I have installed a RGBW LED strip. The WiFi LED RGBW controller should work with an app like the Magic Home app. However, I contains a ESP8285 chip which I flashed with my own firmware. I added a PIR by which the LED strip switches off when I am away for a few minutes. And switches on again when I return.

In this Instructable I show you how I hacked this controller and added a PIR and I share with you my designs and software.


  • Magic Home RGBW WiFi controller: link
  • RGBW LED strip: link
  • HC-SR501 PIR sensor: link

Step 1: Hardware Modification

My RGBW controller has connections for an IR receiver (GND, VCC and data). I use these connections to connect the PIR, which also has these connections.

I found out that the IR connection is connected to GPIO4 and pulled up HIGH via a pullup resistor of 20k Ohm. This is suitable for the PIR.

The PIR then is connected as shown in the picture. In this way the PIR runs on 3.3V from the RGBW controller bypassing the on board regulator.

I soldered a JST connector to the IR connections and added hotglue to support the JST connector. I drilled and filed a rectangle hole in the case for the JST connector.

Step 2: The Software

The code is published on my Github. The software is based on my software for my LED bulb.

The module uses MOSFETs to switch the LED R, G, B and W channels on and off. By applying a PWM signal to the MOSFETs, you can generate every color from RGB and also dim the White LEDs. See this website for some more information about PWM signals.

The ESP8285 can generate PWM signals with a duty cycle from 0% to 100% via the analogWrite function to the desired pin with a value of 0 - 255 to set the brightness of the channel.

In this module the green channel is connected to GPIO5, red to GPIO12, blue to GPIO13 and the white channel is connected to GPIO15. In the code you see that as: #define GREENPIN 5, #define REDPIN 12, #define BLUEPIN 13 and #define WHITEPIN 15. As decribed in the previous step, the PIR is connected to GPIO4 (#define PIRPIN 4).

When the device is powered up, it starts as a White LED strip, since in most cases I desire a white light. It then connects to WiFi and my MQTT broker connected to Openhab, it is like in this Instructable. If you want, I can show you my Openhab setup.

The device has a webinterface to set the color, dim the LED strip, set a scene or enter the HTTPupdateserver.

Function of the PIR

When the PIR detects motion, its output pin is HIGH. The ESP8285 checks whether this pin is HIGH and resets a timer. When there is no motion detected for a defined time (in my case 4 minutes/240 seconds), the timer activates a function which stores the current values of the PWM dutycycles of the colors channels and then sets them to '0'. This switches of the LED strip.

When the LEDstrip is off and a motion is detected, the previous values are restored and the LED strip is on again.

Flashing the ESP8285

See this instruction and this instruction how to flash a ESP8285 via the exposed connector pads. When my code is flashed once, you can flash a new version over the air (OTA) via the HTTPupdateserver.

Step 3: Assemble

I designed a cover for the PIR and 3D printed it. I used hot glue to glue the PIR in the cover. Via the holes in the cover you can access the potmeters for the range/sensitivity and pulse time (not used in my setup, this is controlled in the code).

The LEDstrip is quite bright, so I added a white cover which diffuses the light, see the pictures. I designed the cover as 5 parts of about 16 cm which fitted on my 3D printer bed.

The PIR and the LED strip covers are published on my Thingiverse.

Arduino Contest 2020

Participated in the
Arduino Contest 2020