Saber Wall Light: an IoT Lightsaber Lamp with the WizFi360-EVB-Pico

May the force be with you. This is one of my Star Wars-inspired projects: an animated saber wall light, built on the WizFi360-EVB-Pico, an RP2040 Wi-Fi board from WIZnet. WIZnet kindly sent me an evaluation board, and the project went on to win their design competition. It builds on my first saber wall light.

Video Blog

The concept

My hall is a bit dark, so I wanted wall lights with some personality:

  • Each light has a configurable blade colour.
  • Turning on and off is animated: a lightsaber ignition, a discharging wand, or another sequence.
  • A local switch turns each light on or off, and a PIR sensor in the handle turns it on when someone walks past.
  • It turns itself off after a period of time.
  • It connects to my local MQTT broker, so the lights can be configured over IoT and stay in sync: when one detects motion, they all come on.

The WizFi360-EVB-Pico

This isn’t a full review, but here is what matters. The board uses the RP2040 with the same pinout as a Raspberry Pi Pico, so Pico add-ons fit. Like the Pico it has an SWD debug port, and unlike the Pico it has both BOOTSEL and reset buttons, which saves me adding switches to my projects. It has 16 Mbit of flash.

Wi-Fi comes from the WizFi360 coprocessor on 2.4 GHz, in station or soft AP mode (or both). It talks to the RP2040 over a UART using AT commands, similar to, but not identical to, the ESP AT firmware. It supports TCP client, TCP server and UDP sockets, and is CE and FCC certified. The UART and the module’s reset line use a few GPIO pins, but there are plenty left.

Hardware and electronics

A quick health warning first. The project runs on a relatively safe 5 V, but it can draw 5 A. That is enough to heat and burn wires and insulation, and the electrolytic capacitors will explode if fitted the wrong way round. While building it I had a heart-stopping moment when smoke drifted across my desk. It wasn’t the microcontroller: it was the insulation on a power wire not rated for 5 A. Please double check everything.

  • The blade: a 1 metre strip of 144 WS2812B LEDs inside an acrylic tube. The data line goes through a 300 ohm resistor, as the specification requires, and a logic level shifter. For 144 LEDs I need a true 5 V signal rather than cheating with 3.3 V as I do on smaller projects.
  • Power protection: a 1000 µF capacitor on the LED strip stops the jump from all off to full on browning out and resetting the RP2040. A 5 A fuse and a 100 °C thermal fuse cut the power before anything can overheat.
  • Inputs: an SPST switch in pull-down mode, and an AM312 PIR sensor. The PIR gave false triggers, probably from power instability and the Wi-Fi, so it has its own smoothing and decoupling capacitors.
  • Status: an RGB LED shows the Wi-Fi and MQTT connection state, and a pulse LED shows the board is running.

The electronics sit on a narrow board that fits in the handle. The handle and tube cap are 3D printed, with M2 heat-set inserts to bolt the PCB, blade and wall mount together.

Software

The software stack, from the bottom up:

  • Pico SDK on the RP2040.
  • The WizFi360 driver from the CMSIS driver library. This was my first time with CMSIS and it caused some head scratching: the key is using WIZnet’s patches and the right library versions.
  • FreeRTOS coreMQTT on top of the socket connection, with my own transport adapter.
  • My TwinThings library for publish and subscribe and for managing digital twin state.
  • ForsakenNGS’s PicoLED library, driving the WS2812B LEDs through PIO (I wrote about it in Libraries for the Pico: ForsakenNGS PicoLED).

Two decisions: I didn’t use the WizFi360’s built-in MQTT AT commands, as they are limited to three subscriptions and aren’t in the RP2040 libraries. And I haven’t added TLS yet, as it would need to run on the RP2040 side.

A digital twin for configuration

Rather than saving settings in flash, each light’s configuration lives in a digital twin on my network and reloads whenever the light reconnects. That also lets me configure all the sabers as a group in one go.

A twin manager, a Python service in Docker, sits on the MQTT network like any other device. It stores state in MySQL, shared with my EMQX broker, and works out groups from the broker’s authorisation table. It can query and set many devices at once, a bit like SQL: for example, turning every saber on with a white blade for daytime. A saber manager application, also Python in Docker, gives me a web page for all this, styled in the LCARS look.

The result

The blade can be a Jedi blue or green, Sith red, or my favourite, a Pride rainbow. It can ignite like a saber, spark, or shoot like a wand, and three of them together look even better. (The sound effects are only in the video. I haven’t given the Pico sound yet. Sound effects from Pixabay, thanks to Pip, Arnaljl and Joe93Barlow.)

Code, schematics and 3D models: SaberWIZFi360 on GitHub, under MIT licence. The foundations are in my Udemy courses: C/C++ development environment for the Pico, Pico Micro Projects for WS2812B animation, and FreeRTOS on Raspberry Pi Pico.

One thought on “Saber Wall Light: an IoT Lightsaber Lamp with the WizFi360-EVB-Pico”

Leave a Reply