ADS1115 16 bit ADC on ESP8266?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
weldeng
Posts: 31
Joined: Thu Sep 15, 2016 12:47 am

ADS1115 16 bit ADC on ESP8266?

Post by weldeng » Tue Nov 29, 2016 5:43 pm

I was wondering if anyone has this working yet? Tips on how to get up and running would be appreciated. Adafruit appears to be hosting a driver under development.

http://micropython-ads1015.readthedocs.io/

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: ADS1115 16 bit ADC on ESP8266?

Post by deshipu » Tue Nov 29, 2016 9:55 pm

Since I wrote that driver, I can tell you that I tested it and confirm that it works.

weldeng
Posts: 31
Joined: Thu Sep 15, 2016 12:47 am

Re: ADS1115 16 bit ADC on ESP8266?

Post by weldeng » Tue Nov 29, 2016 11:21 pm

deshipu wrote:Since I wrote that driver, I can tell you that I tested it and confirm that it works.

Great, I loaded ads1x15.py to the ESP8266. I have an OLED and the ADC connected. Tried a few lines of Code as follows:

>>> import machine
>>> i2c = machine.I2C(machine.Pin(5), machine.Pin(4))
>>> i2c.scan()
[60, 72]
>>> import ads1x15
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ads1x15.py", line 5

Where do I go from here?

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: ADS1115 16 bit ADC on ESP8266?

Post by deshipu » Wed Nov 30, 2016 8:06 pm

How did you load it?

weldeng
Posts: 31
Joined: Thu Sep 15, 2016 12:47 am

Re: ADS1115 16 bit ADC on ESP8266?

Post by weldeng » Wed Nov 30, 2016 11:03 pm

deshipu wrote:How did you load it?
I copied the file ads1x15.py using WebRepl to the ESP8266.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: ADS1115 16 bit ADC on ESP8266?

Post by deshipu » Thu Dec 01, 2016 8:28 am

Can you verify it copied correctly by reading it out?

Code: Select all

with open("ads1x15.py") as f:
    print(f.read())

weldeng
Posts: 31
Joined: Thu Sep 15, 2016 12:47 am

Re: ADS1115 16 bit ADC on ESP8266?

Post by weldeng » Thu Dec 01, 2016 3:09 pm

deshipu wrote:Can you verify it copied correctly by reading it out?

Code: Select all

with open("ads1x15.py") as f:
    print(f.read())
Thanks, here is the result.

WebREPL connected
>>> with open("ads1x15.py") as f:
... print(f.read())
...

Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "<stdin>", line 2, in <module>
MemoryError: memory allocation failed, allocating 15616 bytes
>>>

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: ADS1115 16 bit ADC on ESP8266?

Post by pythoncoder » Thu Dec 01, 2016 5:52 pm

Try reading line by line:

Code: Select all

with open('ads1x15.py') as f:
    for line in f:
        print(line, end='')
Peter Hinch
Index to my micropython libraries.

weldeng
Posts: 31
Joined: Thu Sep 15, 2016 12:47 am

Re: ADS1115 16 bit ADC on ESP8266?

Post by weldeng » Thu Dec 01, 2016 11:45 pm

pythoncoder wrote:Try reading line by line:

Code: Select all

with open('ads1x15.py') as f:
    for line in f:
        print(line, end='')
Oops!

The file is in HTML. Copied the micropython file over and it seems to be working fine. I put a solar cell on channel 0 and it reads 13541. Actual voltage is 2.561 Volts. Hooked up channel 2 to VDD (3.3V) and it reads 17571

The gain does not appear to correspond to any of the settings from the ADS1X15 docs.

Thanks to all for the help.

weldeng
Posts: 31
Joined: Thu Sep 15, 2016 12:47 am

Re: ADS1115 16 bit ADC on ESP8266?

Post by weldeng » Fri Dec 02, 2016 12:40 am

deshipu - Nice driver! I have a few questions:

1. After trying various gains it appears the max value when reading a channel is 32767 not 65535?
2. Does the driver support use of more than one ADS 1115 module? I have a single module on address 0x49. I could add up to three more using addresses 0x48 (1001000), 0x4A (1001010), and 0x4B (1001011).
3. Is it possible to set a separate gain for each channel.

Post Reply