2 different services under same application on separate hardwares

Hi all,
I have checked in the forum and on internet but I couldn’t find the answer to my dilemma:
I have 2 RPi3B with different sensors but under the same application and I thought to use multiple container configuration in order to manage them but then I realised that I don’t know how to tell docker with which package belong to which RPi.
Now I’m wondering if it’s possible or not.
Any suggestion, idea?

Hey @davide welcome to the forums!

There are a few environment variables available that allow you to get the device UUID along with other information that can be used to help you identify the device: https://www.balena.io/docs/learn/develop/runtime/

It would also help if you were able to share your application code so we can get a bit more context of what you’re trying to do. I would recommend looking into running the same code on all devices and then detecting within your code what sensors are available at that point, otherwise you’ll be creating different cases for each devices which won’t scale well.

Hi Chrisys,
many thanks for your reply; I’m going to have a look at.

For giving a bit of more context, one of the sensorsis using sense-hat and it’s working fine because it was the only one.
Now i’m adding a new RPI3 with bm280 but I haven’t written the code yet; I’m creating the environment first.
Basically I’m playing with sensors and at the same time learning how to use docker and its functionalities and in a second phase I’ll find the right setting for a proper scale up for the solution/architecture
Keep you posted with my results; even if I know already my next problem: enabling SPI instead of I2C via docker/Python


@davide sounds great! In that case what you could do is look at detecting the different devices on the I2C bus via their different addresses to work out what code you should run or what modules to include.

You should find that both I2C and SPI are enabled by default at the device level; check Device configuration in the dashboard, but of course post here if you need any more help when you get to that part!