Hi, I would like to send data from a raspberry pi to a openMV H7 Hand cam plus using the raspberry as a master and the hand cam as a slave. I am currently using this pair of codes
Master:
import rpc
import serial
# Initialize the connection to OpenMV via USB (VCP)
# Change the port to match your OpenMV camera's USB serial port (e.g., /dev/ttyACM0)
usb_port = "/dev/ttyACM0"
# Create an RPC client over USB VCP
client = rpc.rpc_usb_vcp_master(port=usb_port)
while True:
# Call the 'hello_world' function on OpenMV and get the response
result = client.call("hello_world")
# Print the response from OpenMV
if result is not None:
print("Response from OpenMV:", result)
else:
print("No response from OpenMV.")
Slave:
import rpc
import pyb
red_led = pyb.LED(1)
# Initialize the RPC interface (USB Virtual COM Port)
pyb.LED.on(red_led)
pyb.delay(500)
pyb.LED.off(red_led)
pyb.delay(500)
interface = rpc.rpc_usb_vcp_slave() # For UART use rpc_uart_slave()
pyb.LED.on(red_led)
pyb.delay(500)
pyb.LED.off(red_led)
pyb.delay(500)
## Define a simple function to respond with a message
def hello_world(data):
return "Hello from OpenMV!"
## Register the hello_world function to be called over RPC
interface.register_callback(hello_world)
## Main loop to keep the RPC server running
pyb.LED.on(red_led)
pyb.delay(500)
pyb.LED.off(red_led)
pyb.delay(500)
interface.loop() # Continuously listen for RPC commands
I used the red led to troubleshoot sections of the code and it is working fine. However, when running the code on the master side of things I can’t seem to get a response
This is the output recieved
No response from OpenMV.
No response from OpenMV.
No response from OpenMV.
Please help me with this problem and thank you in advance.
Many thanks,
Unscythe