Back in May, I designed a quick PCB to interface an RP2040 with the dirt cheap LD2410 presence sensors for some home automation projects. Though, I completely about the project up until a few weeks ago when I was looking for some cool Halloween projects to work on. I then came up with the idea to design a light to enhance the spookiness of my cheap Halloween candy basket.

Hardware Design:

The hardware design is pretty simple. The PCB I designed includes an RP2040, a 128MB flash chip, a vertical USBC connector (why? because screw your horizontal connectors!), a WS2812 (neopixel) RGB LED, and a header to interface with an LD2410 24GHz radar module over UART. To make things easy for mounting, I designed a generic enclosure for the PCB (can be adapted for different mounting configurations) and a custom bracket for taping the sensor to the rim of the basket. Since the neopixel is mounted on the RP2040 PCB, it's kind of difficult to see unless you're right in front of the sensor. So I decided to connect it to a light pipe that wraps around the rim of the basket and fully illuminates the area.

Software Design:

The software design is also pretty simple (you might be sensing a theme here). I decided to use Arduino and the arduino-pico core to make things easy for myself. I didn't really like the existing Arduino libraries for the LD2410 so I just wrote a quick sketch that checks for UART data from the sensor and (if data is available) reads the serial data byte by byte to check for the EOF signal (0xF5). If 0xF5 is read, I then read in 17 bytes of data and strip out the detection signal (byte 8) and the moving object distance signal (byte 9/10) and store them.

After doing some testing, I found that the output signals from the LD2410 can vary quite a bit over time so it is necessary to do some averaging to avoid sporadic behavior. For my sketch, I decided to average 5 sensor output frames before judging whether an occupant is detected or not and their distance from the sensor. I also made this average amount a macro at the top of my sketch so it can be adjusted based on your needs.

Once an occupant is detection in range of the sensor, the neopixel is illuminates in orange to indicate an occupant is detected within 200cm. If the occupant then moves closer towards the basket (120cm), the neopixel becomes green.

Checkout the GitHub repo for full source code!

Closing Thoughts:

This was just a simple and fun project I threw together over the course of a week or so (excluding original board design) for Halloween. I hope this design is useful for other users who are interested in working with the LD2410 and provides some mild amusement to trick or treaters who stop by my candy basket!

Demo Video: