Playing Music on a Tag Reader

The tag reader, and it’s relative the NFCDeck have piezo buzzers in them. These can be used to play monotone music via PWM signal from an ESP. As an addition to this, there’s a simple music file format from the early years of cellphones that’s also supported by this system. Combine these together and we have an interesting little music box.

The ring tone text transfer language was developed by Nokia in order to send ring tone songs over simple text streams to early cell phones. This format can also be used in other ways, as its simple and well defined, so its usable in things like ESPHome devices.

The service calls for a tag reader or NFCDeck can be run from the developer tools: Developer tools –> services -> esphome.device_xxxx_play_rtttl

You provide it a simple song string like the one below and it’ll play through the entire song provided.

song_str: "rick: d=4,o=5,b=200:8g,8a,8c6,8a,e6,8p,e6,8p,d6.,p,8p,8g,8a,8c6,8a,d6,8p,d6,8p,c6,8b,a.,8g,8a,8c6,8a,2c6,d6,b,a,g.,8p,g,2d6,2c6.,p,8g,8a,8c6,8a,e6,8p,e6,8p,d6.,p,8p,8g,8a,8c6,8a,2g6,b,c6.,8b,a,8g,8a,8c6,8a,2c6,d6,b,a,g.,8p,g,2d6,2c6."

Now while calling it from the developer tools is neat, things get far more interesting when you bring in automations to call the rtttl song.

Calling an RTTL Song in an Automation

Now I’m not going to give even worse ideas, like using the parallel block in an automation to call RTTTL songs (like the classic song from Rick Astly) on multiple devices, like, if you have one in every room in your house, or even in just a few key areas.

Resources

Leave a Reply