Hi,
I have problems to get two I2C devices in my code to work.
my setup:
feather M0 basic
ADS1115
128x32 OLED
Target is to measure analog values with ADS1115 and to show on the OLED display
Adafruit example programs do work for single devices, I2C scan is showing both addresses (0x3C, 0x48)
but as soon as I try to use both devices in the code, I get an out of memory error.
I'm sure that this is my mistake and I'm sorry if this has been posted already, but I could not find anything.
Greetings Norbert
I2C issue for devices
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: I2C issue for devices
If you post the code you are using we can take a look. Press the
Code: Select all
button and paste your code between the [code] tags.
- ZwoWe
- Posts: 7
- Joined: Sat Apr 06, 2019 4:57 am
Re: I2C issue for devices
thx a lot for the response
I meanwhile changed the board to the M0 express, and dumped the complete lib on the board to avoid any dependencies conflicts
setup is now
Adafruit CircuitPython 3.1.2 on 2019-01-07;
Adafruit Feather M0 Express with samd21g18
ADS1115
128x32 OLED
I have commented out the ADS1115 part for testing purposes
no memory error anymore but,
code.py output:
Traceback (most recent call last):
File "code.py", line 13, in <module>
TypeError: function missing 1 required positional arguments
13 oled = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
CODE:
#made from adafruit example code https://learn.adafruit.com
import board
import busio
# Create the I2C bus
i2c = busio.I2C(board.SCL, board.SDA)
#import adafruit_ads1x15.ads1115 as ADS
#from adafruit_ads1x15.analog_in import AnalogIn
import adafruit_ssd1306
# Create the SSD1306 OLED class
oled = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
# is the display working?
oled.fill(1)
oled.show()
# Create the ADC object using the I2C bus
#ads = ADS.ADS1115(i2c, 1, 64)
# Create single-ended input on channel 0
#chan = AnalogIn(ads, ADS.P0)
#print("{:>5}\t{:>5}".format('raw', 'v'))
#while True:
# print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
# time.sleep(0.5)
I meanwhile changed the board to the M0 express, and dumped the complete lib on the board to avoid any dependencies conflicts
setup is now
Adafruit CircuitPython 3.1.2 on 2019-01-07;
Adafruit Feather M0 Express with samd21g18
ADS1115
128x32 OLED
I have commented out the ADS1115 part for testing purposes
no memory error anymore but,
code.py output:
Traceback (most recent call last):
File "code.py", line 13, in <module>
TypeError: function missing 1 required positional arguments
13 oled = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
CODE:
#made from adafruit example code https://learn.adafruit.com
import board
import busio
# Create the I2C bus
i2c = busio.I2C(board.SCL, board.SDA)
#import adafruit_ads1x15.ads1115 as ADS
#from adafruit_ads1x15.analog_in import AnalogIn
import adafruit_ssd1306
# Create the SSD1306 OLED class
oled = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
# is the display working?
oled.fill(1)
oled.show()
# Create the ADC object using the I2C bus
#ads = ADS.ADS1115(i2c, 1, 64)
# Create single-ended input on channel 0
#chan = AnalogIn(ads, ADS.P0)
#print("{:>5}\t{:>5}".format('raw', 'v'))
#while True:
# print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
# time.sleep(0.5)
- ZwoWe
- Posts: 7
- Joined: Sat Apr 06, 2019 4:57 am
Re: I2C issue for devices
Code: Select all
#made from adafruit example code https://learn.adafruit.com
import board
import busio
# Create the I2C bus
i2c = busio.I2C(board.SCL, board.SDA)
#import adafruit_ads1x15.ads1115 as ADS
#from adafruit_ads1x15.analog_in import AnalogIn
import adafruit_ssd1306
# Create the SSD1306 OLED class
oled = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
# is the display working?
oled.fill(1)
oled.show()
# Create the ADC object using the I2C bus
#ads = ADS.ADS1115(i2c, 1, 64)
# Create single-ended input on channel 0
#chan = AnalogIn(ads, ADS.P0)
#print("{:>5}\t{:>5}".format('raw', 'v'))
#while True:
# print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
# time.sleep(0.5)
- ZwoWe
- Posts: 7
- Joined: Sat Apr 06, 2019 4:57 am
Re: I2C issue for devices
coming back to the memory error in
feather M0 basic
ADS1115
128x32 OLED
configuration
error message:
code.py output:
Traceback (most recent call last):
File "code.py", line 9, in <module>
File "adafruit_ssd1306.py", line 38, in <module>
File "adafruit_framebuf.py", line 52, in <module>
MemoryError: memory allocation failed, allocating 64 bytes
feather M0 basic
ADS1115
128x32 OLED
configuration
error message:
code.py output:
Traceback (most recent call last):
File "code.py", line 9, in <module>
File "adafruit_ssd1306.py", line 38, in <module>
File "adafruit_framebuf.py", line 52, in <module>
MemoryError: memory allocation failed, allocating 64 bytes
Code: Select all
import time
import board
import busio
# Create the I2C bus
i2c = busio.I2C(board.SCL, board.SDA)
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
import adafruit_ssd1306
# Create the SSD1306 OLED class
oled = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
# is the display working?
oled.fill(1)
oled.show()
time.sleep(0.2)
oled.fill(0)
oled.show()
# Create the ADC object using the I2C bus
#ads = ADS.ADS1115(i2c, 1, 64)
# Create single-ended input on channel 0
chan = AnalogIn(ads, ADS.P0)
print("{:>5}\t{:>5}".format('raw', 'v'))
while True:
print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
time.sleep(0.5)
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: I2C issue for devices
Hmmm. Looks like you have commented out everything but the SSD1306 code.
Are you able to run the basic example as published in the library?
Are you able to run the basic example as published in the library?
Code: Select all
# Basic example of clearing and drawing pixels on a SSD1306 OLED display.
# This example and library is meant to work with Adafruit CircuitPython API.
# Author: Tony DiCola
# License: Public Domain
# Import all board pins.
from board import SCL, SDA
import busio
# Import the SSD1306 module.
import adafruit_ssd1306
# Create the I2C interface.
i2c = busio.I2C(SCL, SDA)
# Create the SSD1306 OLED class.
# The first two parameters are the pixel width and pixel height. Change these
# to the right size for your display!
display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
# Alternatively you can change the I2C address of the device with an addr parameter:
#display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x31)
# Clear the display. Always call show after changing pixels to make the display
# update visible!
display.fill(0)
display.show()
# Set a pixel in the origin 0,0 position.
display.pixel(0, 0, 1)
# Set a pixel in the middle 64, 16 position.
display.pixel(64, 16, 1)
# Set a pixel in the opposite 127, 31 position.
display.pixel(127, 31, 1)
display.show()
- ZwoWe
- Posts: 7
- Joined: Sat Apr 06, 2019 4:57 am
Re: I2C issue for devices
Yes, sample code works for
feather M0 basic
ADS1115
128x32 OLED
configuration
thx
feather M0 basic
ADS1115
128x32 OLED
configuration
thx
- AnneBarela
- Learn User Page
- Posts: 757
- Joined: Sat Mar 24, 2012 8:56 pm
Re: I2C issue for devices
4.0 has some garbage collection on library import. I know it means loading a new version and the new corresponding libraries but it's worth a shot if it is truly memory vs. a programmatic issue
- adafruit2
- Posts: 22200
- Joined: Fri Mar 11, 2005 7:36 pm
Re: I2C issue for devices
for all those libraries, you'll need to stick with Arduino or update to an M4 most likely!
- ZwoWe
- Posts: 7
- Joined: Sat Apr 06, 2019 4:57 am
Re: I2C issue for devices
Hi,
ok, I will test version 4 and let you know.
thx Norbert
ok, I will test version 4 and let you know.
thx Norbert
- ZwoWe
- Posts: 7
- Joined: Sat Apr 06, 2019 4:57 am
Re: I2C issue for devices
just a quick update,
since I had to finish the my project, measuring a length position sensor with the ADS1115 and displaying on the feather-oled, I switched back to Arduino code and everything worked as a charm.
I'm loving the featherwing and it's dimension and the concept of Circuitpython, so I will definitely give M4 a test, as you recommended earlier
Have a great weekend!
since I had to finish the my project, measuring a length position sensor with the ADS1115 and displaying on the feather-oled, I switched back to Arduino code and everything worked as a charm.
I'm loving the featherwing and it's dimension and the concept of Circuitpython, so I will definitely give M4 a test, as you recommended earlier
Have a great weekend!
- briandbrady
- Posts: 21
- Joined: Mon Oct 02, 2017 5:00 pm
Re: I2C issue for devices
I am having the same issue with my M4 Feather. I updated the bootloader to the latest 3.x CircuitPython and same with the libraries. I get the error:
File "code.py", line 20, in <module>
TypeError: function missing 1 required positional arguments
I am using the OLED Featherwing with the M4 Feather. None of the examples I find work with this pairing. I use it when I teach a class in the spring and it worked fine last year. It seems to be a v3.x problem.
File "code.py", line 20, in <module>
TypeError: function missing 1 required positional arguments
I am using the OLED Featherwing with the M4 Feather. None of the examples I find work with this pairing. I use it when I teach a class in the spring and it worked fine last year. It seems to be a v3.x problem.
adafruit_support_bill wrote:Hmmm. Looks like you have commented out everything but the SSD1306 code.
Are you able to run the basic example as published in the library?Code: Select all
# Basic example of clearing and drawing pixels on a SSD1306 OLED display. # This example and library is meant to work with Adafruit CircuitPython API. # Author: Tony DiCola # License: Public Domain # Import all board pins. from board import SCL, SDA import busio # Import the SSD1306 module. import adafruit_ssd1306 # Create the I2C interface. i2c = busio.I2C(SCL, SDA) # Create the SSD1306 OLED class. # The first two parameters are the pixel width and pixel height. Change these # to the right size for your display! display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c) # Alternatively you can change the I2C address of the device with an addr parameter: #display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x31) # Clear the display. Always call show after changing pixels to make the display # update visible! display.fill(0) display.show() # Set a pixel in the origin 0,0 position. display.pixel(0, 0, 1) # Set a pixel in the middle 64, 16 position. display.pixel(64, 16, 1) # Set a pixel in the opposite 127, 31 position. display.pixel(127, 31, 1) display.show()
- Ido_Alpha_Omega
- Posts: 1
- Joined: Sun Dec 09, 2018 3:59 am
Re: I2C issue for devices
On the Charlieplex PWM LED Matrix Driver https://www.adafruit.com/product/2946, I have had several failed attempts to utilize the 0x75 address through soldering the jumpers. 0x76, 0x77 work as well as the default 0x74, so I don't think it's a poor soldering job on my part. This has occurred on a few boards. They won't activate on function calls and object methods when jumped to 0x75. They fail to show up when conducting an I2C sweep as well. Furthermore, they tend to freeze the microcontroller at times.
Please be positive and constructive with your questions and comments.