When my son was born, I wanted to get him a soft LED lamp or toy that would change color when he interacted with it and that I could control remotely (ideally through Home Assistant). After hours searching, I couldn't find anything that I liked, so I settled on a Mr. Miffy lamp (that only comes with a white LED module) that I would modify myself.
This module hosts an arduino microcontroller that runs a neopixel ring, gyroscope, and battery monitor, as well as communicates with an XBee3 module that uses zigbee to talk to zigbee2mqtt. I have z2m running in Home Assistant, which is how I remotely control the lamp. It is charged wirelessly via a Qi receiver.
A large percentage of my time was spent learning (read: fumbling through) the zigbee protocol to communicate with z2m. Since the XBee module is not natively supported as an end device in z2m, I had to add a device handler to the server, as well as manually alter the z2m database so that z2m knew to link the device with my new device handler.
When the gyro detects motion, the arduino overrides the current neopixel state and displays a colorful, pulsing loop for a short period, then it returns to the previous state. The 3D-printed case allows access to all of the internal components, and it has heat-set inserts to mount components. It fits perfectly into the Mr. Miffy silicone shell.
Here is a list of things I'd still like to implement:
- Add "device response" so that the module can confirm it received a command
- Add battery state reporting to z2m
- Properly incorporate XBee module as end device in z2m
- Modify the case to properly hold the Qi receiver and battery
- Modify the case to hold the neopixel ring with a press fit