RFID Jukebox. and a Nightlight. With a Clock!
by bitsandpixels in Circuits > Gadgets
114 Views, 2 Favorites, 0 Comments
RFID Jukebox. and a Nightlight. With a Clock!


It all started with a once-in-a-long-time offer from the 3D printing and CNC machining service, Weerg (not affiliated): try out their clear, translucent resin 3D printing for an astonishing price of 0€!
This was around the time I’d finished the RGB Butterfly, and I was looking to build another night light for the kid. At that time, she was heavily into the Frozen, so after a bit of Internet searching I found this beautiful model.
This was too much of an opportunity to pass up on…
This project changed so many times over a few years, that it feels like a few separate ones. It ended up becoming a fancy nightlight, a clock, and a jukebox. Read the full story at bitsandpixels.io and check out the GitHub repository.
Idea of an RFID jukebox came from the Home Assistant's blog: place a card on the scanner and the music starts playing. The Home Assistant and its superb add-on, Music Assistant, are used to select what happens when a card is scanned.
Supplies

I decided to go with the following components, mostly because I already had some of them (they do fit surprisingly well, though):
- Lilygo T-Embed
- Muse Luxe hackable, connected speaker, or any other speaker or audio system that can be integrated with Home Assistant.
- PN532 RFID reader module (or any other supported by ESPHome)
- a couple of rings with WS2811 RGB addressable LEDs; I used:
- 12 LED NeoPixel ring, 37mm diameter,
- 16 LED NeoPixel ring, 68mm diameter
- LM2596S DC-DC step-down voltage converter module (like this one)
- USB-C breakout board
- semi-transparent PLA
- regular PLA
- assortment of wires
Note that except for the T-Embed dev board, you don’t have to use the exact same components from the list above. Design is flexible enough to accommodate different hardware, as long it is supported by the software (Home Assistant, ESPHome).
Even the T-Embed could be replaced by a similar development board, but it is slightly trickier because part of the casing design would have to switched to match the alternative module. Totally doable, though.
The voltage converter is adjusted to reduce and stabilize the output voltage at approximately 4.2V-4.7V (it’ll drop down even further when the LEDs are on) from the 5V supplied by the USB. The converter’s output is used to supply both LEDs and the T-Embed module.
If you’re using different ESP32 module, make sure that the output voltage of the converter is safe for that module.
The WS2811 LEDs can be supplied by voltages anywhere in the 3.3 - 5V range. T-Embed is meant to be powered from a USB connection, so it expects input to be at around 5V. It comes with its own voltage stabilizers dropping the voltage down to 3.3V.
The RFID module and the LCD screen both require 3.3V, so they’ll be powered directly from the 3.3V pin on the T-Embed. They probably could be connected directly to voltage converter’s output, but if you would like to do that, make sure that modules you’re using are 5V tolerant.
3D Prints



STL files are attached to this step and are also downloadable here or from the project’s GitHub repository, along with the source FreeCAD design. Additional attachment is the Prusa Slicer project file for the Liligo T-Embed module case, extracted from the manufacturer's STL files.
Parts are designed to have a tight fit, so it should be possible to assemble everything without glue or screws. Still, ribs on the walls are designed to be optionally attached to the base using small screws (M1.6 or so; not bolts, there are no holes in the base).
Assembly






Start with assembling the LED rings together: solder the power, ground, and data wires between the two rings. There should be approximately 15mm of space between the rings, enough to mount them to their stands on the base of the enclosure.
While soldering stuff, solder some wires between the USB breakout board and the DC-DC converter. There’s around 17mm between the two components, best use ~20mm wires. There’s some space in the enclosure to align them.
Next, I would recommend to prepare a power extension cord of sorts. I used JST connectors for power and ground, to avoid unfortunate accidents with swapping power and ground pins. Take a few 2-pin JST sockets and connect them together; maybe even wrap them in a heat shrink tube.
With the extension, you’ll have plenty of power connectors to extend2 the project in the future. Next, prepare ~50mm wires for power and ground outputs from the converter and crimp a 2-pin JST connector on one end3. Solder the other end to the converter.
Now that it’s been settled which pin is power and which is ground, you can safely solder power connector to the LED ring assembly. Around 5cm should be enough.
For the LED’s DI pin, I’d suggest picking a longer, ~20cm female-female wire (one for standard, 2.54mm gold pins), cutting it in half, and soldering one of the laves to the LED ring.
If using the T-Embed module, that’s the end of soldering. The LCD screen is on board, and the RFID tag reader can be connected using those nifty jumper wires.
Connect the remaining wires as follows (modules on the left, T-Embed pins on the right):
- LED Ring DI -> IO38
- PN532 SCL -> SCL
- PN532 SDA -> SDA
- PN532 VCC -> 3V3
- PN532 GND -> GND (any of them)
Make sure to pull the wires through the holes in the cover and the T-Embed’s encasing before connecting them to the module.
And that’s it. Assembly of the enclosure should be straightforward after all that. Align the wall so that its ribs match the notches in the base and press it down. If the fit isn’t too tight, you might need to use glue or screws to fasten the two parts together.
Finally, just glue the figure and the T-Embed on top. Hot glue works great.
Software

When it comes to software, there are two sides to this project: the device firmware, and the Home Assistant configurations.
The firmware, generated using ESPHome, handles the lights (including The Button that controls them), and the tag scanner (sends tag ID to the Home Assistant). It also exposes an additional binary sensor that latches the state of the scanned tag, to ensure that the card won’t be randomly re-scanned.
In the Home Assistant, one automation monitors the tags being scanned, looking for known tag IDs assigned to specific media players and media content. If a known card is scanned, the automation will call Home Assistant service to start the playback.
The other automation monitors state of the “tag active” latch. When it goes from on to off, calls Home Assistant service to stop the playback.
Check out the full description of the ESPHome project and the Home Assistant automation in the blog posts:
Download the source files from the GitHub repository.
Result



And here's how it turned out for me. Eventually (it took a lot of time and a lots of turns).
Check out the next steps for source files of the ESPHome project and the Home Assistant automations.
Home Assistant Automation
One the Home Assistant side of things, everything boils down to two automations, one of which is nearly identical to the one shown in the Home Assistant blog article on tags.
Read more about the Home Assistant automation: RFID Jukebox: Home Assistant Automation
ESPHome Project
This project uses the indispensable ESPHome project to generate firmware for the ESP32 microprocessor that powers the Lilygo T-Embed. It converts a machine-readable description of what the firmware should do to code that runs on the ESP32 with little to no coding.
You can download the full configuration file in the project's GitHub repository. Also check out the ESPHome's documentation to learn more about the structure of the file, core components, supported boards, etc.
Check out the detailed walk-through this ESPHome config file in RFID Jukebox: The FIrmware.