floitsch 07/17/2023 10:52 PMI finally got my Ads1115 sensors.
After a bit of testing I figured out the problem.
The constructor is setting the config
register.
It directly ors in the RATES_DR_475SPS_
constant. However, the location of the data rate is bits 5-7. So there is a shift needed:
| RATES_DR_475SPS_ << 5
Alternatively, the RATES_DR_475SPS_
constant should have the bits already shifted. (That would actually be more consistent with the rest of the code).
Once I fixed that, I also changed the sleep --ms=1
to yield
.
The driver should probably remember the samples-per-second, and then either just yield
(if it's less than 10ms), or sleep
otherwise.
With that change the driver is nicely computing new values close to the speed that it should.