Replies: 2 comments 1 reply
-
This happens because you are driving the same MCP2221 chip with two instances of the EasyMCP2221 library. One from ADS1x15 and the other from your own To prevent this you have two options:
The easiest in this case is B. # No Need to import EasyMCP2221
import ADS1x15
# Initializing ADS1x15 will also initialize EasyMCP2221
ADS = ADS1x15.ADS1115(1, 0x48)
# Get the EasyMCP2221.Device object to reuse it
mcp = ADS.i2c.mcp
# Operate as usual
mcp.set_pin_function(gp2 = "GPIO_OUT") Check the example ads1115_with_gpio.py. Is there a good reason you want to use an external I2C ADC? It may be easier for you to start with the internal MCP2221's ADC instead of an ADS1115. Check level_meter.py. |
Beta Was this translation helpful? Give feedback.
-
I've just added a feature to prevent this double initialization. Not released yet. But feel free to checkout the repository and try it if you wish. Documented in this hint. |
Beta Was this translation helpful? Give feedback.
-
@electronicayciencia : I saw in the EasyMCP library that you have recently added examples of python code that even collects data at rate of 167 Samples per second. Amazing !
I tried to use your code in an example which you can find below. In this example, I would like to blink a LED on GPIO pin 2 of the MCP2221 when the bit value of de ADC is below 10000. Unfortunately, I get an error.
Here is the python code:
This is a quite straight forward program. But it does not work. I have the feeling that the I2C read-out sequence is disturbed when I use the GPIO pins of the MCP2221 breakout board. Anyway, I got the following error :
Is there a solution for this problem or can I not use the SDA and SCL lines in combination with the GPIO pins on the MCP2221 breakout board simultaneously ?
Beta Was this translation helpful? Give feedback.
All reactions