DigitalShoestringSolutions / PowerMonitoring

GNU General Public License v3.0
0 stars 1 forks source link

Grove ADC v1.0 and v1.1 have different I2C addresses #39

Open tobyaharris opened 2 months ago

tobyaharris commented 2 months ago

According to sudo i2cdetect -y -a 1 0x03 0x77,

the Grove Base HAT for Raspberry Pi v1.0 07/23/2018 can be found at 0x08 whereas the Grove Base HAT for Raspberry Pi v1.1 04/06/2022 can be found at 0x04

This address is baked into our core code: https://github.com/DigitalShoestringSolutions/PowerMonitoring/blob/f1f96bd940d401e32c35603c831148bc7ae105d4/current_sensing/code/core/device_modules/adc_grove.py#L12 This i2c_address is not usually overwritten in stock configurations.

As a workaround it can be overwritten in user_config: add

device.adc_0.config.i2c_address = 0x04

to the end of user_config.toml

How can we handle the incompatible hardware automatically? Must the user check the vnumber on the pcb and add this line if necessary? Could the code call i2cdetect on the fly and parse the output, selecting the ADC as required? By extention, if this works to autoselect different grove HATs, why not autoselect BC Robotics as well?

tobyaharris commented 4 days ago

Greg: current plan is to duplicate all the grove config files

tobyaharris commented 4 days ago

^ which I have done, as it is a quick and easy option.