Using multiple identical sensors // adding sensor drivers

Hello everybody,
first off I’d like to thank everybody that made balena sense possible.
Its a great tool and saved me a lot of time. <3

I’m using a Raspberry Pi Zero 2 with a SparkFun Qwiic HAT to which I added three Adafruit Sensirion SHTC3. I know these are not supported, so I have three Adafruit BME280 on my shopping list. I already set up everything, and it works fine, except of the sensors of course.
Im using this setup to monitor the temperature and humidity in a cigar cabinet.

  • How can I make three BME280s work, regarding their L2C addresses?
    I know two can work if you leave out one of the sensor cables from the second BME280, causing it to change the address to 0x76, but what about a third sensor?

  • I found a forum post on here from may 21 stating this could be changed in sensors.py, but after the update to V2 this is no longer the case, right?

  • And regarding the previous question: Is it possible to add the driver for the Adafruit SHTC3?
    As far as I understand, the drivers hostet on GitHub should make it possible. But how do I add them?

  • Lastly: Is it possible to make an output on a SparkFun 20x4 SerLCD with Grafana?

Hi,

I haven’t used balenaSense yet, so I can’t comment (yet) on how to specify which drivers/devices can be used.

Regarding the I2C addressing: the device uses a 7-bit address, 6 of these are fixed and one bit is controlled by a pin. As a single bit can only be set to 0 or 1, you cannot setup a third board with a unique address.

You might however be able to get these boards to work with the SPI interface instead of I2C.
In that case, you won’t be using the I2C addresses anymore, but every board will get its own Chip Select line. Only the board with an active Chip Select will be reading and writing from/to the SPI interface.
There’s nothing really stopping you from using 20 wires to use 20 boards this way.

Unfortunately SPI interface is not supported by balena sense.
At least I couldn’t find it mentioned in the documentation.

What I found in the blog post is

Many of these sensors now include a simple, solderless connector known as Stemma QT or SparkFun Qwiic. They allow you to daisy-chain multiple connectors together on the same device.

unfortunately without further explanaitions on how to address L2C address issues.

Hi,

Looking at the schematic of one of those boards, Qwiic only forwards SDA (serial data), SCL (serial clock) and Power (+3.3V, GND).
So the daisy-chaining is purely for the I2C bus and power.
Addresses are configured separately from the Qwiic connector, in this example through a jumper (JP2) or the other (6-pin) connector J3.

I will look into Balena Sense this weekend to see if I can find out more, but it sounds like you’re out of luck when it comes to using more than 2 of these specific modules per I2C bus.
The only way to get more, would be to add another I2C bus, for example by using a bitbang driver with GPIO pins.

What I think could work is using a Adafruit TCA9548A 1-to-8 I2C Multiplexer Breakout, unfortunately I’m not savvy enough to implement this (writing the code)

Hi,

Sorry for the delayed response.
I did some digging through sensor block.
From what I saw, using multiple or even other than the default I2C buses isn’t (properly) supported at the moment.

Maybe @alanb128 or @phil-d-wilson can offer some insight on this as they contributed to that block?

Regarding the Multiplexer, you can hook up a I2C bus to the input (SDA/SCL) and up to 8 to the output (SC0-7/SD0-7).
You can then select which output to connect to your input, by setting the inputs A0-2 (000 connects SC0/SD0, 111 connects SC7/SD7).

Note that the sensor block will simply scan and use the single input bus, so you would need to make some pretty hefty changes for it to work with this.

1 Like

I’ll defer to @alanb128 here - since he’s had FAR more experience of the sensor block and sensors in general, than I. :slight_smile:

I’ll give him a nudge. :wink:

1 Like

Hello, just jumping in here - without modifying the sensor block, you can only connect two BME280 sensors at one time. The easiest way to add a third sensor would be to add a supported one that uses a different address such as the HTU21 or the (untested) HDC1000. Another option would be to use an additional Pi Zero/Zero 2 and feed its data into your balenaSense instance via MQTT. Since the sensor block uses sensor drivers built into the kernel, adding new sensors is not straightforward.

Some early work on using alternate I2C busses has been done (see Detect and load sensors from all busses · Issue #5 · balenablocks/sensor · GitHub) but it needs more testing and likely tweaks. I agree with @tjvv (thanks for your help here) that modification would be necessary to use the multiplexer.

Regarding the SparkFun 20x4 SerLCD, it would not work natively with Grafana. You could write a small amount of python code to display values directly from the sensor block, but graphing on the LCD would be very complex.

Thank you Alan, I’ll use one of the tested sensors with a different address then.