Registration of devices upon installation

Hello,
we are looking for a robust way to register devices when they are installed in a facility. Background: We will deliver a batch of hardware with balenaOS installed to a customer and let the customer install the devices in different locations. When the device is installed each device will send sensor data to the cloud. We need to associate the data received in the cloud with the location of the device. Before the installation there is no safe way to assign a certain device with a installation location.

One idea would be to put serial numbers (not the uuid) on the devices as barcode stickers. Whoever installs the device in the facility needs to scan the barcode upon installation and add the location information manually (for example a facility id) using a smartphone and a webapp we provide.
The question here: How could we make the serial number available for the device so it can be used to label the data we send to the cloud? Entering it as a variable in balenaCloud after bootstrapping seems error-prone. Perhaps we could connect a barcode reader to the device when we bootstrap it and use it to scan the barcode but how would we implement that on the device?

Background: We are using hardware that is based on Raspberry CM3 modules.

Any ideas or best practices welcome.
Thanks
Bruno

Hey @bvetter

The scenario you describe is one of the reasons why we built the balenaFin to have this information accessible via a barcode physically on the device and accessible via software; the same information from the barcode is also held on an EEPROM on-board the device which you could read and use to tag your sensor data. If you’re building your own custom hardware, you could consider doing the same?

I can’t quite think through the entire process, but there’s also the possibility that you can add the variables to balenaCloud programmatically via the API at the point the device is scanned. This would depend on you having some way to map that serial number barcode to the balenaCloud device.

I hope this helps!

Thanks for your reply, @chrisys. I think it’s a very good feature of the balenaFin and there is a good chance we will give it a test drive. Although we are using the CM3, we are not building the hardware ourselves. We might talk to the manufacturer about that feature.

When our devices are installed, they are already cased and there would not be a chance to scan the code on the pcb. I wonder if we could assign all our new devices to an application that I would call ‘registration’. It would contain an application container that waits for a user input via keyboard (actually it would be a usb barcode scanner). When the barcode is scanned, the application would need to persist it serial number somehow, either somwhere in the filesystem or as a device variable via the balena api. After registration I would move the device to the final application which would mean the registration application is removed and replaced by the final productive application.

The application would then have access to the devices serial number and could tag all data sent into the cloud with it.

Does that sound like reasonable approach?

Hi, have you considered preregistering a device? In this case you will know device information like uuid and name which you can include in the barcode which you’ll stick on this device. More about preregistering: https://github.com/balena-io-projects/balena-cli-advanced-masterclass#52-preregistering-a-device

Cool.

  1. Get barcode stickers with ids that conform to the balena uuid schema (32 character hex)
  2. Apply stickers to devices
  3. For each device run a script to:
    a. Scan barcode
    b. preregister device
    c. create config.json
    d. configure os image
    e. flash the image
  4. boot devices to finish registration

Correct?

Yes and on place of installation someone will scan the device barcode and associate it to location by sending data to cloud like: :. Do I get it correctly?

Correct. Thanks much.

Sorry for formatting, I meant device_uuid - locatioin mapping. I’m glad I could help.