Raspberry Pi Device - Play mp3 file without opening dashboard


I want to add multiple Raspberry Pi devices to my cloud FlowFuse application and be able to play audio through their audio jack port without openening the dashboard in the browser. My question is, what nodes can I use to do this?
I am also open to other/better alternatives that enables me to play different audio on multiple different speakers without opening the browswer/dashboard.

Best regards,


I’ve not tried this myself but by the looks of it there are various CLI tools which can play from a library of audio files. You can call that CLI tool using the Exec node in Node-RED Raspberry Pi Command Line Audio - Raspberry Pi Spy

Please let us know how you get on with this, it’s an interesting project.

Hi Rob,

Thhank you for answering, not a bad idea at all! I will let you know when I move on with the project.


So I just realised that Flowfuse has disabled the Exec node on the cloud instance. Any idea for a work around anyone?

Hi Magnus, you can actually use “Developer Mode” and “Remote Access” for this, via FlowFuse.

If you select the device within FlowFuse, enable Developer Mode, then on the “Developer Mode” tab, enable Remote Access.

You can then build your flow through FlowFuse, and it will live update and run on the device itself.

When ready, create a Snapshot from the Device directly. This will then be available on your Instance, you can set it as target, and consequently, it will be sent to all other devices assigned to that Instance.

I see, thank you. However, I now encoutered other issues.

I want to play a mp3 file located on a raspberry pi. I am able to do it succesfully when entering this is in the command line on the raspberry pi:

mpg321 /home/room1/bubbling_water_1.mp3

However, when I try to run the command from the Exec I see this erro:
“Can’t find a suitable libao driver. (Is device in use?)”

This is the my very simple Node-RED flow to test:

[{"id":"db360345465fde74","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"d5d416bdfc3349dc","type":"inject","z":"db360345465fde74","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":120,"wires":[["9ee9f413e5ac8144"]]},{"id":"5ebd0de5.aad5ac","type":"inject","z":"db360345465fde74","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"/home/room1/Downloads/titanium-170190.mp3","payloadType":"str","x":230,"y":740,"wires":[["63e287d0.aafcdc"]]},{"id":"63e287d0.aafcdc","type":"exec","z":"db360345465fde74","command":"/home/room1/play_audio.sh","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":440,"y":740,"wires":[["0144b43be522dd3e"],["0144b43be522dd3e"],["0144b43be522dd3e"]]},{"id":"0144b43be522dd3e","type":"debug","z":"db360345465fde74","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1220,"y":720,"wires":[]},{"id":"2d72a83ee7f97bbb","type":"exec queue","z":"db360345465fde74","name":"","currentLine":{"row":5,"column":2},"command":"/home/room1/play_audio.sh","debugMode":false,"outputs":1,"useSpawn":"false","field":"payload","fieldType":"msg","format":"javascript","template":"console.log(`\n{\n\t\"value\": \"exec queue\",\n\t\"purpose\":\"putting the ideas from the exec, template and queue nodes together\"\n}\n`)","output":"str","outputEmpty":false,"vimMode":false,"queue":1,"addpayCB":false,"splitLine":false,"cleanQueue":true,"x":730,"y":840,"wires":[["0e827de7d55489ed"]]},{"id":"745d296831e27365","type":"inject","z":"db360345465fde74","name":"","props":[{"p":"payload","v":"/home/room1/Downloads/titanium-170190.mp3","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":570,"y":840,"wires":[["2d72a83ee7f97bbb"]]},{"id":"0e827de7d55489ed","type":"debug","z":"db360345465fde74","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1060,"y":840,"wires":[]},{"id":"6d82c617fdaf4b8e","type":"play_audio_file","z":"db360345465fde74","filename":"/home/room1/Downloads/titanium-170190.mp3","x":480,"y":960,"wires":[["ee1187ac9ebcf3e6"]]},{"id":"a22637674d799b88","type":"inject","z":"db360345465fde74","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":940,"wires":[["6d82c617fdaf4b8e"]]},{"id":"ee1187ac9ebcf3e6","type":"debug","z":"db360345465fde74","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":1020,"wires":[]},{"id":"9ee9f413e5ac8144","type":"exec","z":"db360345465fde74","command":"mpg321 /home/room1/bubbling_water_1.mp3","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":430,"y":120,"wires":[["aebe34da8acfa77d"],["aebe34da8acfa77d"],["aebe34da8acfa77d"]]},{"id":"aebe34da8acfa77d","type":"debug","z":"db360345465fde74","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":120,"wires":[]}]

Hello, does the command work when you input it directly on the command line rather than via the Exec node? If not the problem is not Node-RED related. I’d look up what the error ‘Can’t find a suitable libao driver’ tells you.

Hi, yes it works when I input it directly on the command line on the Raspberry Pi. However, not when I run it through the Exec node. I have tried with these two commands commands:

mpg321 /home/room1/bubbling_water_1.mp3
cvlc /home/room1/bubbling_water_1.mp3

The first one results in the above descriped error. The second one outputs nothing to the debugg node and also does not play the audio file.

I also tried to with this node that also results in an error:
Error playing back file /home/room1/bubbling_water_1.mp3: 1

I also tried to see if there was anything wrong with permissions which it does not at first at least seems like. This is a short resume of what I have tried in relation to this provided by chatgpt:

  1. Checked /dev/dsp and /dev/snd/* permissions:
  • Checked the permissions of /dev/dsp and /dev/snd/* to ensure read and write access.
  1. User permissions:
  • Verified that the user running Node-RED (in this case, “room1”) had the necessary permissions to access audio devices.
  1. Running Node-RED as the correct user:
  • Checked that Node-RED is being executed under the “room1” user by running the ps command.
  1. Used alternative audio players:
  • Attempted to use different audio players, such as cvlc (VLC media player), to play audio files, providing an alternative to mpg321.

Are you running the device agent in Docker?

Can you try running this command via EXEC and tell me what happens…

ls /home/room1/

I am running the device agent on a Raspberry Pi. This is what I got out of the debug node:

Please let me know if any of you find a solution to this problem! I’ve not been able to solve it yet on my own and I would really like to find a solution within this week.

Hi Magnus, I’ve not had time to replicate your set up so I don’t have any further suggestions at this time.

This sort of project is really interesting to me but not something that I can work on as part of my Node-RED job. If I get time to take a look at this and have any useful feedback I will let know. From your comments I think you have as good of an understanding of Linux as me, you probably know more.

Generally, when working with the Exec node I’ve never found a command which I can run on the CLI which doesn’t work in Exec so I don’t think you are wasting your time in this approach but I don’t have any more suggestions at this time.

I understand, thanks for looking into it anyway. The Exec node not working never happened to me either which made me thank this was related to Flowfuse and not Node-red directly. Let me know if you figure something out!

Can you try something for me

If you are starting the device agent on the CLI stop it (ctrl-c) then run the following command and start it again:


if you are running it as a service add the following line after the existing Environment line to the /etc/systemd/system/flowforge-device-agent.service file


You will need to run systemctl daemon-reload and then restart the service with service flowforge-device-agent restart

Then start the device agent again and test the commands once more.


Thank you, Ben!. This works (i start the agent manually on the CLI btw)! Do you have any idea why this resolves the issue?

We found a bug in the device agent late on Friday to do with what environment variables get passed through from the host to the Node-RED instance.

This flag passes all env vars.

There will be a new Device Agent release this week that includes the fix.

1 Like

Hmm, I now wanted to run the agent as a service. I editet the service file to include Environment=FORGE_EXPOSE_HOST_ENV=true, however, I now get this issue when trying to run the command through the Exec node: High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2, and 3. Version 0.3.2-1 (2012/03/25). Written and copyrights by Joe Drew, now maintained by Nanakos Chrysostomos and others. Uses code from various people. See 'README' for more! THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK! tcgetattr(): Inappropriate ioctl for device /home/room1/bubbling_water_1.mp3: Permission denied

That is likely to be a file permissions thing. Check that the user listed in the service can read those files

I see, forgot to provide the right permissions. However, now that I solved this the same thing happens as before resulting in the original error

Can’t find a suitable libao driver. (Is device in use?)

. This was previously fixed when I started the agent manually and ran the ocmmand


Although as I mentioned I now want to run the agent as a service. My modified service file looks like this, did I make any mistakes?

# systemd service file to start FlowForge

Description=FlowForge Device Agent

# Run as normal pi user - change to the user name you wish to run FlowForge Device as

# Use SIGINT to stop
# Auto restart on crash
# Tag things in the log


Run ps -efc | grep node-red from that find the process id (pid) of the node-red instance

Then show us the content of the file /proc/<pid>/environ