🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    UnitV maixpy I2C slave Core2 v1.1 I2C bus error

    Units
    1
    1
    580
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      m5stackstage
      last edited by

      After diving deep within the mess that is the micropython port for the k210 device, core to the currently available UnitV module, it seems like it's impossible to make use of the kpu and nn model inference while communicating (as a slave) with another m5stack controller (in our case, specifically, the Core2 v1.1).

      What should be the firmware to flash onto the unitv to properly use UIFlow version 1's face detection count blocks?
      We weren't able to make that work with the stock firmwares we found. The maixpy uPy port i2c module is documented only for a very specific and quite simple use case with regards to the slave mode, while it seems that trying to set up the device to take a snapshot, infer through the nn model and transmit the face count to the core2 through i2c never works, and always results in a OSError: I2C bus error (110) (which we don't seem to be able to find any info on what's the specific error message meaning, though we suspect it could probably be a timeout error).

      We also thought of trying to set up the k210 camera device as an i2c master and the core2 as a slave only on the specific port used, but the core2, specifically with UIFlow 1, does not have a way of behaving like a slave.

      These are the programs used on the devices, k210 and core2 (generated by blocky) respectively.

      import KPU as kpu
      import sensor
      
      from machine import I2C
      from time import sleep
      
      # Init sensor and NN model
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      sensor.run(1)
      task = kpu.load(0x300000)
      anchor = (1.889, 2.5245, 2.9465, 3.94056, 3.99987, 5.3658, 5.155437, 6.92275, 6.718375, 9.01025)
      kpu.init_yolo2(task, 0.5, 0.3, 5, anchor)
      result = 0
      pause = False
      
      # I2C slave
      def on_receive(data):
          pass
      
      def on_transmit():
          global result
          return result
      
      def on_event(event):
          global pause
          if event == 2:
              pause = False
              return
          pause = True
      
      i2c = I2C(I2C.I2C0, mode=I2C.MODE_SLAVE,
                scl=34, sda=35, addr=0x23,
                on_receive=on_receive, on_transmit=on_transmit, on_event=on_event)
      
      while True:
          if not pause:
              # Detect people faces
              img = sensor.snapshot()
              result = kpu.run_yolo2(task, img)
              result = result[0].objnum() if result else 0
      
      from m5stack import *
      from m5stack_ui import *
      from uiflow import *
      import i2c_bus
      import time
      
      screen = M5Screen()
      screen.clean_screen()
      screen.set_screen_bg_color(0xFFFFFF)
      
      i2c0 = i2c_bus.easyI2C(i2c_bus.PORTA, 0x00, freq=100000)
      print(i2c0.scan())
      i2c0.addr=(0x23)
      print(i2c0.available())
      while True:
        wait_ms(198)
        print(i2c0.read_data(1, i2c_bus.UINT8BE))
        wait_ms(2)
      

      https://www.reddit.com/r/M5Stack/comments/1c4hm73/i2c_problems_with_unitv_ov7740_sku_u078c/

      1 Reply Last reply Reply Quote 0
      • First post
        Last post