UNO Q: Exploring Custom Bricks and App Lab Service Containers

Hello everyone,

I have been experimenting with the new custom bricks feature introduced in Arduino App Lab 0.7.0 on UNO Q.

Starting from my previous Web Radio project:
:backhand_index_pointing_right: GitHub - philippe86220/UNO-Q--WebRadio · GitHub

I created a local custom brick (WebRadio) in order to:

  • encapsulate the radio logic,
  • simplify the Python application structure,
  • expose a cleaner API,
  • and separate the WebUI from the backend implementation.

The brick now provides methods such as:

radio.play("info")
radio.set_volume(50)
radio.stop()

instead of directly handling HTTP requests inside main.py.

I also experimented with brick_compose.yaml in order to better understand how App Lab service containers behave.

As part of these tests, I created an additional container using:

services:
  player:
    image: debian:bookworm-slim
    command: bash -c "ls -l /dev/snd || true; sleep infinity"

The container was correctly created and started alongside the main App Lab container.

However, in my tests, ALSA audio devices were not exposed inside the service container:

docker exec -it copy-of-brique-player-1 ls -l /dev/snd

returned:

ls: cannot access '/dev/snd': No such file or directory

Because of this, I was not able to containerize audio playback (mpg123 / ALSA / USB audio) using brick_compose.yaml.

At the moment, the most reliable architecture I found is therefore:

App Lab (WebUI + custom brick)
    ↓ HTTP
Linux host-side service (systemd)
    ↓
mpg123 + ALSA + USB audio

I documented the exploration and tests here:

:backhand_index_pointing_right: GitHub - philippe86220/UNO-Q-Custom-Brick-Exploration-WebUI · GitHub

Thanks to the Arduino team for introducing custom bricks in App Lab. They provide a very interesting way to better structure applications and encapsulate logic.

This is expected. The reason is that access to any resources on the host machine must be granted to the container explicitly. You haven't done so for the files on the host that are under /dev/snd, so it is expected that this directory won't exist in the container.

In the case where you want to provide the container access to a device, you can do this via the devices key of the Docker Compose file:

https://docs.docker.com/reference/compose-file/services/#devices

Try it with this brick_compose.yaml file content:

services:
  player:
    image: debian:bookworm-slim
    command: sh -c "ls -l /dev/snd || true; sleep infinity"
    devices:
      - /dev/snd

Thank you for the suggestion regarding devices:.

It worked perfectly.
I was able to expose /dev/snd inside the service container and successfully run mpg123 with USB audio playback directly from the custom brick container.

I will clean up the project and publish the custom brick implementation and repository as soon as possible.

This new version is based on the previous WebRadio project, but now uses a fully containerized audio service through brick_compose.yaml.

I updated the project and significantly reworked the architecture.

The WebRadio logic is now encapsulated inside a real custom App Lab brick with its own containerized audio backend.

Main changes:

  • custom WebRadio brick
  • containerized Linux audio service via brick_compose.yaml
  • ALSA access from inside the container using /dev/snd
  • MP3 streaming with mpg123
  • cleaner Python API
  • simplified main.py
  • WebUI integration through exposed App Lab APIs

Example usage:

from webradio import WebRadio

radio = WebRadio()

radio.play("info")
radio.set_volume(50)
radio.stop()

The project now demonstrates:

  • custom App Lab bricks
  • containerized services
  • ALSA audio playback
  • HTTP communication between components
  • modular architecture on UNO Q

Repository:

A first startup delay (~30–60 seconds) can occur on a fresh installation because the container dynamically installs required Debian packages before the radio backend becomes operational.

I also updated the documentation to clarify the architecture and startup behavior.

The current version still uses predefined radio station names (info, rtl, inter, etc.) because the project initially focused on validating the overall architecture.

Now that the containerized ALSA backend is working correctly, the next step will probably be to evolve the brick into a more generic audio player API.

The idea would be to provide something simpler and more reusable such as:

from audio import AudioPlayer

player = AudioPlayer()

player.play("https://example.com/stream.mp3")
player.stop()
player.set_volume(50)

This would make the brick independent from predefined radio stations and allow playback of arbitrary audio streams.

I think this approach is ultimately more coherent and closer to what a generic App Lab audio brick could look like on UNO Q.

I will start working on this evolution as soon as possible.

Very cool! I'm glad you were able to utilize the new custom Bricks feature.

Yes, after experimenting with them more deeply, I now better understand how powerful custom bricks can become on UNO Q.

They really help separate:

  • application logic
  • backend services
  • hardware access
  • and reusable APIs

The AudioPlayer experiment evolved much further than my original WebRadio prototype thanks to this architecture.