OpenMV USB Powering

Hello!

I have 2 OpenMV H7 Plus that I am supposed to use on a robot, so they need to be powered by something else than computer. I have an powerbank, that seems that powers my OpenMV (i have a current of about 0.4A when both plugged). However, it seems that my SPI communication is not working when I power using powerbank, while working when OpenMV plugged to PC.

This is the OpenMV code in case you need it:

import sensor
import time
import gc
import machine
import omv
import select
import struct
import time
import sensor
import time
import image
import pyb
from machine import LED

led = LED("LED_RED")

class spi_slave:
    def __init__(self, cs_pin="P3", clk_polarity=1, clk_phase=0, spi_bus=2):  # private
        import pyb
        self.__pin = pyb.Pin(cs_pin, pyb.Pin.IN)
        self.__polarity = clk_polarity
        self.__clk_phase = clk_phase
        self._put_short_timeout_reset = 50
        self.__spi = pyb.SPI(spi_bus)

    def put_bytes(self, data, timeout_ms):  # protected
        import pyb
        start = pyb.millis()
        while self.__pin.value():
            if pyb.elapsed_millis(start) >= self._put_short_timeout_reset:
                return
        self.__spi.init(pyb.SPI.SLAVE, polarity=self.__polarity, phase=self.__clk_phase)
        try:
            self.__spi.send(data, timeout=timeout_ms)
        except OSError:
            pass
        self.__spi.deinit()

# Initialize the sensor
sensor.reset()
sensor.set_contrast(3)
sensor.set_auto_gain(True)      # Enable automatic gain
sensor.set_auto_exposure(True)  # Enable automatic exposure
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.HQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
face_cascade = image.HaarCascade("frontalface", stages=25)
clock = time.clock()

# SPI Slave interface
interface = spi_slave(cs_pin="P3", clk_polarity=1, clk_phase=0, spi_bus=2)

# Shared state
ready_to_send = False
send_buffer = bytearray(4)

# Interrupt sets the flag
def nss_callback(line):
    global ready_to_send
    ready_to_send = True

pyb.ExtInt(pyb.Pin("P3"), pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_UP, nss_callback)

# Main loop
while True:
    clock.tick()
    img = sensor.snapshot()

    # Detect faces
    objects = img.find_features(face_cascade, threshold=0.75, scale_factor=1.25)
    for r in objects:
        # send_buffer = list(r)
        img.draw_rectangle(r)

    # Example data packing based on face count
    num_faces = min(len(objects), 255)
    if(num_faces == 1):
        led.toggle()
        send_buffer[0] = 85
        send_buffer[1] = objects[0][0]
        send_buffer[2] = objects[0][1]
        send_buffer[3] = 0x10
    else:
        send_buffer[0] = 86  # Header byte
        send_buffer[1] = 0xAA
        send_buffer[2] = 0xFF  # Just for demo: send FPS as third byte
        send_buffer[3] = 0x10
    # SPI send logic (non-blocking during interrupt)
    if ready_to_send:
        try:
            interface.put_bytes(send_buffer, 1000)
            # print("Sent:", list(send_buffer))
        except Exception as e:
            continue
        ready_to_send = False

Is there a shared ground between the devices?

These 2 OpenMV are connected to the same powerbank. There are no aditional GND connection between these 2 boards or between them and the master device. Both OpenMV boards are set as being slave on comunicate on the same SPI channel with an STM32

You need to have a shared ground between all the devices. If USB was present previously it would have provided that.