I2C gives OSError: [Errno 110] ETIMEDOUT

Discussion related to "under the hood" OpenMV topics.
ngattuso
Posts: 23
Joined: Thu Dec 27, 2018 8:29 pm

I2C gives OSError: [Errno 110] ETIMEDOUT

Postby ngattuso » Sun Feb 03, 2019 3:42 pm

Hello,

I'm trying to connect the openMV to an Atmega 328 using I2C. Every time I try to send, I get an ETIMEDOUT error.

Does that mean that the openMV didn't receive an ACK?

Code: Select all

i2c = I2C(2) # The i2c bus must always be 2.
i2c.init(I2C.MASTER, baudrate=400000) # init as a master
time.sleep(2000)

print("begin")
while(True):
    print("scanning")
    #slaves = i2c.scan()
    #print(slaves)
    i2c.send('1',0x0A)
    time.sleep(5000)
Note: I'm using the following I2C logic Level Shifter https://www.electronicgeek.ca/products/ ... or-arduino
And, made sure that the proper SDA and SCL are connected
User avatar
kwagyeman
Posts: 2713
Joined: Sun May 24, 2015 2:10 pm

Re: I2C gives OSError: [Errno 110] ETIMEDOUT

Postby kwagyeman » Sun Feb 03, 2019 6:40 pm

Yeah, that's what it means. The Arduino can't do I2C slave mode as far as I know. Please use the UART on the mega and on the OpenMV Cam to communicate. It's way easier.
Nyamekye,
ngattuso
Posts: 23
Joined: Thu Dec 27, 2018 8:29 pm

Re: I2C gives OSError: [Errno 110] ETIMEDOUT

Postby ngattuso » Sun Feb 03, 2019 8:01 pm

Hello,

Thanks for your reply.

I have the Atmega328 programmed as a slave. I used an arduino as master to test it and it works. Additionally, I can't use a UART because I have another device on the Atmega using it.

Lastly, I ran a test yesterday with openMV as master to a slave arduino and it was receiving the data byte. However, when I go directly to the Atmega, it's giving me the timeout.

Thanks
User avatar
kwagyeman
Posts: 2713
Joined: Sun May 24, 2015 2:10 pm

Re: I2C gives OSError: [Errno 110] ETIMEDOUT

Postby kwagyeman » Sun Feb 03, 2019 8:36 pm

Have you heard of software serial on the Arduino? It's let's you make a low speed uart on the I/O pins that support interrupts. Pins 2 and 3. Using that library you can have another serial port.
Nyamekye,
ngattuso
Posts: 23
Joined: Thu Dec 27, 2018 8:29 pm

Re: I2C gives OSError: [Errno 110] ETIMEDOUT

Postby ngattuso » Mon Feb 04, 2019 12:46 pm

I just took a look at it. It's an interesting application and can definitely be useful. However, I'm not using an Arduino and would rather not create my own implementation of this on the Atmega328.

I'll take a look bit more into to see if AVR has anything already to create a second UART.


But, what's the issue with the I2C? I've been able to scan the device and discover its address. It doesn't happen successfully all the time but a bit more work and debugging can probably produce a reliable communication.


Thank you,
Nicholas
User avatar
kwagyeman
Posts: 2713
Joined: Sun May 24, 2015 2:10 pm

Re: I2C gives OSError: [Errno 110] ETIMEDOUT

Postby kwagyeman » Tue Feb 05, 2019 12:48 pm

Ah, the Arduino can be an I2C slave. I didn't know this was possible: https://www.arduino.cc/en/Tutorial/MasterWriter - so, just make the OpenMV Cam act like the master Arduino in this example.
Nyamekye,
ngattuso
Posts: 23
Joined: Thu Dec 27, 2018 8:29 pm

Re: I2C gives OSError: [Errno 110] ETIMEDOUT

Postby ngattuso » Thu Feb 07, 2019 7:59 pm

Yeah that's what I'm trying. I'm writing to the register for the baudrate on the Atmega328 so that it matches with the openMV. I think that's where my issue was.

Thanks!
ngattuso
Posts: 23
Joined: Thu Dec 27, 2018 8:29 pm

Re: I2C gives OSError: [Errno 110] ETIMEDOUT

Postby ngattuso » Fri Feb 15, 2019 5:37 pm

Hello,

I continued trying to get an I2C communication with the openMV but still have no luck.

This time, I tried to get the communication between the M7 and H7. Programmed a simple Slave that tries to receive 3 bytes on the H7 and a Master that scans and sends a byte on the M7. I also connected a pull-up resistor on the SCL and SDA lines.
User avatar
kwagyeman
Posts: 2713
Joined: Sun May 24, 2015 2:10 pm

Re: I2C gives OSError: [Errno 110] ETIMEDOUT

Postby kwagyeman » Sat Feb 16, 2019 4:15 pm

Hi, which device is having the error? The H7 or the M7? Note that you have to generally catch exceptions when you can get timeouts and etc. The MicroPython HAL throws exceptions on any error.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests