0

ADS1015 or ADS1115
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

ADS1015 or ADS1115

by ginzer on Wed Feb 10, 2016 6:04 am

Hey,

I have a general question to this 2 Modules

https://www.adafruit.com/products/1083

and

https://www.adafruit.com/products/1085

I want to measure the voltage of a Battery in range of arround 3 and 4.2 Volts. which Module should I use?

The difference is only the resolution?

and is it possible to get the status of the Battery displayed on the Raspberry?

Many thanks in advance

ginzer
 
Posts: 31
Joined: Tue Jan 05, 2016 7:57 am

Re: ADS1015 or ADS1115

by adafruit_support_bill on Wed Feb 10, 2016 7:21 am

which Module should I use?

Either one would work for that application. The primary difference between them is the resolution.
is it possible to get the status of the Battery displayed on the Raspberry?

You could measure the battery voltage and display that. It is easy to tell when the battery is full or nearing empty. Calculating a precise battery level during the middle of the discharge cycle is not so easy, since the curve is nearly flat for most of the discharge cycle.

adafruit_support_bill
 
Posts: 72774
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS1015 or ADS1115

by ginzer on Mon Feb 22, 2016 11:31 am

hey I just managed to download the libraries and I can run the example codes.....

is it also possible to use the library with python3 on the raspi?

ginzer
 
Posts: 31
Joined: Tue Jan 05, 2016 7:57 am

Re: ADS1015 or ADS1115

by adafruit2 on Mon Feb 22, 2016 12:32 pm

the underlying i2c library is not python3 compatible, so we are working on alternative py3 support but for now we only suggest py2.7

adafruit2
Site Admin
 
Posts: 18327
Joined: Fri Mar 11, 2005 7:36 pm

Re: ADS1015 or ADS1115

by ginzer on Tue Feb 23, 2016 8:08 am

ok. but I can read the values of the ADS1015 without your Library no?
can you give me some advice?
I just need one channel and want to meassure a Battery Voltage from 3.2 to 4.2 Volts

ginzer
 
Posts: 31
Joined: Tue Jan 05, 2016 7:57 am

Re: ADS1015 or ADS1115

by adafruit_support_bill on Tue Feb 23, 2016 8:14 am

The library is really your best reference. It is just a series if i2c writes and reads of the ADS1015 registers.

If you prefer C++, there is the Arduino version of the library also. https://github.com/adafruit/Adafruit_ADS1X15

adafruit_support_bill
 
Posts: 72774
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS1015 or ADS1115

by ginzer on Tue Feb 23, 2016 10:16 am

ok.

I tried the following Skript on my Raspi:

import smbus
import time
bus=smbus.SMBus(1)
add=0x48

def read(reg):
value=bus.read_byte_data(add, reg)
return value

adc_channel1=0

while True:
adc_channel1=read(0)
print(adc_channel1)
time.sleep(0.3)

and i connected a 1 kOhm Poti between 3.3 gnd and channel A0 (middle leg of Poti to Channel A0).
But I always get the same value (127) back. >Even when I turn the poti.....

ginzer
 
Posts: 31
Joined: Tue Jan 05, 2016 7:57 am

Re: ADS1015 or ADS1115

by adafruit_support_bill on Tue Feb 23, 2016 10:22 am

The library is really your best reference. If you look at the code you will see that it is more than just reading a single byte from a single register. You need to write a few bytes of configuration before reading the results.

adafruit_support_bill
 
Posts: 72774
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS1015 or ADS1115

by ginzer on Tue Feb 23, 2016 10:38 am

thanks. I looked up the library but im not really getting it. could you help me alittle bit more? what do I have to make?

ginzer
 
Posts: 31
Joined: Tue Jan 05, 2016 7:57 am

Re: ADS1015 or ADS1115

by adafruit_support_bill on Tue Feb 23, 2016 10:48 am

You need to set up the configuration register for the type of reading you want to make. Then you need to read the result from the conversion register. These are described starting on page 15 of the data sheet.
https://www.adafruit.com/datasheets/ads1015.pdf

We currently only support this in Python version 2.7. If you want to work with a tested library, you will need to use Py2.7.

adafruit_support_bill
 
Posts: 72774
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS1015 or ADS1115

by ginzer on Tue Feb 23, 2016 11:37 am

ok. So would you recommend the MCP3008 for my needs because its more easy to implement?

ginzer
 
Posts: 31
Joined: Tue Jan 05, 2016 7:57 am

Re: ADS1015 or ADS1115

by adafruit_support_bill on Tue Feb 23, 2016 12:52 pm

Yes. That should work for you.

adafruit_support_bill
 
Posts: 72774
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS1015 or ADS1115

by ginzer on Wed Feb 24, 2016 9:43 am

I gave it a try to write to the ADS1015 changing my code with the red line.

so now i get Byte values back from the ADS when i turn the Poti (Poti is connected to GND and 5V). I get Values from 0 to 104 max. Do I have to calculate with the %V as VCC or with the range of the ads which is +6.144?


import smbus
import time
bus=smbus.SMBus(1)
add=0x48

bus.write_word_data(add, 0x1, 0x03c0)


def read(reg):
value=bus.read_byte_data(add, reg)
return value

adc_channel1=0

while True:
adc_channel1=read(0)
print(adc_channel1)
time.sleep(0.3)

ginzer
 
Posts: 31
Joined: Tue Jan 05, 2016 7:57 am

Re: ADS1015 or ADS1115

by adafruit_support_bill on Wed Feb 24, 2016 10:01 am

It is a 12 bit ADC and you are only reading back 1 byte (8 bits). You need to read both bytes of the conversion register.

adafruit_support_bill
 
Posts: 72774
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS1015 or ADS1115

by ginzer on Wed Feb 24, 2016 10:11 am

ok. how can I make that?
because when I write a third argument to the

value=bus.read_byte_data(add, reg)

it prints out an error (only 2 arguments allowed)

or do I have to read 2 times?

do i have to get the values back in word or bytes?

thanks a lot

ginzer
 
Posts: 31
Joined: Tue Jan 05, 2016 7:57 am

Please be positive and constructive with your questions and comments.