robert-hh / ads1x15

Micropython driver for ADS1115 and ADS1015
90 stars 25 forks source link

Actual voltage output and typos #1

Closed dafvid closed 6 years ago

dafvid commented 6 years ago

Changed output from read() to be actual voltage instead of raw value

gain should default to 0

fixed typo in alert_start

robert-hh commented 6 years ago

Hello Dafvid. Thank you for your comments. They are very helpful. There were, it seems, some part of the code which I did no test. Some remarks:

robert-hh commented 6 years ago
robert-hh commented 6 years ago

Another thought: when doing a raw_to_v conversion of the ADS1015 class, division is not required, because the range is the same, but just with a reduced resolution.

dafvid commented 6 years ago

I'm a bit lost in the git branches atm. Was trying to only add the conversion function. =/ But adding a simple conversion helper function would be great. And maybe add something to the docs regarding what the returned value from read() represents and how to use it. I was a bit confused at first. My use case is I'm using a MCP9700 to measure temperature and it's 10 mV / degrees Celcius. Maybe other implementations are fine with only the binary value.

robert-hh commented 6 years ago

I have added the conversion function now based on your input. I did not test it yet, but I'll do. After that, I will publish it. Thank you for you contribution. I adapted that module for an application measuring conductivity, where like yours the voltage itself was not sufficient anyhow. Unless you use the voltage directly, a conversion has to be applied anyhow, including the tranfer function of your circuitry. So dealing with raw values is OK.

robert-hh commented 6 years ago

@dafvid: I tested the raw_to_v function and it worked as expected. It is now added as separate method to the class. The ADS1015 variant copes for the lower granularity of the raw values. What I did not change is the order of the parameters, even if I understand the reason. I have existing code that I do not want to change.