DigitalShoestringSolutions / PowerMonitoring

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

Adds config files for Grove Hat #31

Closed Greg-Hawkridge closed 2 days ago

Greg-Hawkridge commented 1 week ago

fixes #15

tobyaharris commented 1 week ago

What's the thinking behind the default ADC channels? For BCR it's always 0 (then 2,4 for 3pu). For Grove it's 3 for single clamps then 0,2,4 for 3pu. For Grove 3pu that makes sense as the physical channels are in pairs which are hard to share. For BCR I'd be tempted to make it 0,1,2 for ease of memory, even if 0,4,7 (what SMDH does) is easier to assemble

Greg-Hawkridge commented 1 week ago

Those were probably just what I used last time I tested. They don't really matter since they're overwritten in user config.

tobyaharris commented 1 week ago

If you have some clamp amplifiers, we can test this

tobyaharris commented 1 week ago

Where does the Grove I2C address get defined? It looks like it's in https://github.com/DigitalShoestringSolutions/PowerMonitoring/blob/0f2f966b62966fb770fc80df925fda6a1b72e545/current_sensing/code/core/device_modules/adc_grove.py#L12 I presume these HATs are not stackable / there is no way to configure the address.

tobyaharris commented 1 week ago

Tested on a pi4 4gb with BCR. Build time 459s. First start time 149s. 1p, 3pb, 3pu all behave as expected.

Tested on a pi4 2gb Grove. Build time 496s. Start time 158s. Didn't work, dismissing my pre-emptive earlier approval.

tobyaharris commented 1 week ago
current-sensing-1      | ERROR:core.sensing_stack:Error during sampling: Traceback (most recent call last):
current-sensing-1      |   File "/app/core/sensing_stack.py", line 25, in execute
current-sensing-1      |     sample_resp = self.device.sample()
current-sensing-1      |   File "/app/core/device_modules/adc_grove.py", line 42, in sample
current-sensing-1      |     raise e
current-sensing-1      |   File "/app/core/device_modules/adc_grove.py", line 35, in sample
current-sensing-1      |     readings = self.i2c.read_register(self.i2c_address,register_addr, 2,stop=True)
current-sensing-1      |   File "/app/core/interface_modules/i2c.py", line 20, in read_register
current-sensing-1      |     write_reg_addr = Msg.write(address,[register])
current-sensing-1      |   File "/usr/local/lib/python3.9/site-packages/smbus2/smbus2.py", line 228, in write
current-sensing-1      |     return i2c_msg(
current-sensing-1      | TypeError: an integer is required (got type str)
tobyaharris commented 1 week ago

soon to be tested again

tobyaharris commented 1 week ago

Still nope. I know the datasheets says 0x04 all over it, but 0x08 is the address that works. image

tobyaharris commented 1 week ago

This works at last. All grove configs (pm_b_1p_grove.toml, pm_b_3pb_grove.toml, pm_b_3pu_grove.toml) work as expected. The values are scaled correctly. The removal of old power calculations has not affected the deployment with the BCR ADC.

tobyaharris commented 1 week ago

Since some files were created and some copied, I've made the presence of execution bits consistent, by removing them all. I don't see why any of these config files need any. Restested on BCR 3pu, unaffected.