0

I know the problem has been treated many times...but I'm not able to resolve it...

I have a Raspberry with Python script to communicate with a custom board in I2C and I always have this Errno 121

In the terminal I tried sudo i2cdetect -y 1 and the custom board is detected in 0x70. I tried deleting the I2C pull up from my custom board, only keeping the pullup of the raspberry, same error. I don't know what to do -_-

Here the I2C_Keyboard.py

import smbus
import threading
import time

I2CAddress = 0x60
Request = 0x03
HardwareReferenceRequest = [0x05, 0x03, 0x01, 0x00, 0x00]

class I2C_Commmunication(threading.Thread):
    def _init_(self)
       threading.Thread._init(self)
       self.terminated = False

    def run(self):
       I2C = smbus.SMBus(1)
       time.sleep(1)

       while 1:
          try:
              I2C.write_i2c_block_data(I2CAddress, Request, HardwareReferenceRequest)
              print("I2C OK")
          except:
             print("I2C failed")

          time.sleep(0.1)

    def stop(self):
       self.Terminated = True

Here Startup.py

from I2C_Keyboard import I2C_Communication
I2C_CommunicationThread = I2C_Communication()
I2C_CommunicationThread.setName("I2C_Communication")
I2C_CommunicationThread.start()

while True:
   time.sleep(1)

The script have to send a frame every 100ms (if not the custom board reboots after 1s).

If someone have an idea

SamPirate
  • 11
  • 3

0 Answers0