Thanks for the quick answer! Yes, the i2c connection is not working although i checked it with Arduino IDE and there it works fine.
For the record:
The boards are connected as follows
MCP4728 Breakout Board |
Nicla Vision |
VCC |
VDDIO_EXT |
GND |
GND |
SCL |
SCL |
SDA |
SDA |
Nicla is connected to the pc through usb.
MCP4728 has two 10k pull-up resistors available for i2c.
I am trying to use this code to test i2c communication using openMV micropython environment.
First I wanted to scan for available devices, but the mcp4728 is not listed in the feed.
import pyb
# Initialize I2C bus
i2c = pyb.I2C(2, pyb.I2C.MASTER, baudrate=400000)
def scan_i2c():
devices = i2c.scan()
if not devices:
print("No I2C devices found.")
else:
print("I2C devices found:", [hex(device) for device in devices])
# Scan for I2C devices
scan_i2c()
Returns: >>> I2C devices found: ['0x8', '0x29', '0x36']
Then I thought that maybe the address is different by a chance and tested it when the mcp4728 board were unplugged, still the same devices were found.
Then I wanted to specify the device, by default the mcp4728 address is 0x60, with this code:
import pyb
import time
# MCP4728 I2C address
MCP4728_ADDR = 0x60
# Initialize I2C bus
i2c = pyb.I2C(2, pyb.I2C.MASTER, baudrate=400000)
def test_i2c_connection():
return MCP4728_ADDR in i2c.scan()
def main():
if test_i2c_connection():
try:
i2c.send(bytes([0x58, 0x00, 0x00]), MCP4728_ADDR) # Example write
time.sleep(0.1)
data = i2c.recv(12, MCP4728_ADDR) # Example read
print("Data received:", data)
except OSError as e:
print("I2C communication error:", e)
else:
print("MCP4728 not found on I2C bus.")
main()
It returns: >>> MCP4728 not found on I2C bus.
Any ideas?