Architecture of the Wall Light Device

The wall lamp is based on a Raspberry PI PICO as the central processor.  The following diagram shows the architecture I used for the device. 

The PICO  managed a string of 144 WS2812 LEDs to animate the blade, in just the same way that I demonstrated in my Udemy course on the C development for the PICO. The WS2812 requires 5V power and 5V signal logic, therefore a logic level converter is used for the signal logic. 

The LEDs can pull 4 amps in my test. I did give myself a heart stopping movement during breadboard prototyping with magic smoke floating across my desk. Fortunately this turned out not to be the PICO but the power wire going to the LEDs which was getting very warm carrying 4 Amps of current. I have therefore used very large trails on the PCB and appropriate wires for the connection. To safeguard the unit I included a 5 Amp fuse and thermal fuse (approximately 100C).

The PICO does not have any Wifi connectivity out of the box. I eventually settled on using ESP-01S as a wifi module. These can be purchased very cheaply but require some work to upgrade them to a more recent firmware version. The Github repo has more details on what was needed.

Local control is a switch that pulls a pin to ground, debouncing is done in software, and a PIR sensor. I chose the AM312 which is nice and small and 3.5 volts but has no sensitivity controls included. I found the AM312 to be incredibly sensitive to any electrical interference and required capacity to filter its supply.

I also used a common cathode RGB LED as a status LED. I could have used another WS2812 but didn’t have any single through hole units on hand. I also had code for managing the RGB LED written to reuse along with plenty of spare pins off the PICO.

Solution Architecture

The wall lights connect over Wifi to an MQTT Hub, EMQX. This provides the backbone of communication using publish and subscribe message architecture. For security purposes MQTT is done 

over SSL, though certificates are not checked at the moment.

The wall lights are fairly dumb devices and store no configuration in flash. Its configuration must be reloaded on start up. To handle this a digital twin service, Twin Manager, reloads the configuration (twin state) of a wall light. It also updates its cache each time the wall light notifies it of a change of state. 

The Twin Manager is a little more than an online cache. It also understands that the wall lights are a group of devices. It allows control software to operate on the wall lights as a group. So changes to configuration can be done at group level. Even if a wall light is offline the change is stored and applied as soon as the wall light connects to the network.

Using the Twin Manager the management control panel, SWL Manager, for the lights is actually very simple. It can pull back and update the state of all the lights in one go.

Software and Libraries

The wall lights firmware is written in C++. It requires some concurrency to handle the comms properly along with using both cores of the PICO. I therefore chose to use FreeRTOS to provide concurrent tasks. There are a number of other libraries that made this development significantly easier. So my thanks and praise for their work goes to:

A couple of C++ libraries got build as reusable components for other projects coming down the line:

The Twin Manager and SWL Manager software was written in Python. Notable libraries used include:

I also mirrored my digital twin library into python for use by the Twin Manager and SWL Manager. 


The handle design was all done in OpenSCAD and 3D printed in PLA. Blade is a 20mm x 3mm x 1000mm OPAL Acrylic Tube. You can find these on ebay, though I found ebay quite expensive. Bought mine from The Clear Plastic Shop in the UK.  


This has been about a 6 month project part time. For the PICO development I practice what I preach in agile development using rapid iteration and testing frameworks where possible inside a microcontroller. I use a Raspberry PI 4 to build, deploy, debug, and monitor the microcontroller. The use my Mac as a comfortable development environment. The smoother the tooling for iterative development the faster progress is made. If you are new to this check out my course Introduction to C Development Environment for Raspberry PICO on Udemy.

I’ve tried to share the project in the github repo.