DC inline current sensing using Adafruit ADS1015 & RP2040

I am trying to use an Adafruit ADS1015 instead of the ADC pins onboard the Raspberry Pi Pico to measure the voltage across a shunt resistor to calculate total current flow. I am encountering difficulty in taking the values from the ADS1015 and passing them to the current_sense function to calculate the current. Any suggestions?

Hi @Whaley ,

I do not have experience with ADS1015, but if you post the code that are using maybe some can spot the issue you are having.

Regards !!!

I suspect @Whaley is able to read current with ADS1015 (perhaps over i2c) but doesn’t know how to inject these currents into the driver.

I don’t have much knowledge in this area, but I suspect you want to do something like the following (which probably isn’t supported yet):

ADS1015CurrentSense current_sense = ADS1015CurrentSense(i2c...params);
// init the current sense
current_sense.skip_align = true;

Are you are asking for advice in how you would go about writing a new ADS1015CurrentSense.cpp that implements some interface/class in order for the driver to use it?

Hi @Whaley ,

Please take a look at the GenericCurrentSense class. Using this it should be possible to do what you need, at least for inline sensing. Low-Side sensing would be more of a challenge.

You can initialise a GenericCurrentSense and pass it two callback functions for initCallback and readCallback. Use initCallback to do any initialisation, if needed.
In the readCallback you implement getting the values from the ADS1015.

You link the GenericCurrentSense to the motor and use it as for the other current sense classes.

It might be a bumpy road because I am not sure how well tested this code is, but in theory this would be the way to do it.

1 Like