uart request / response snapshot

I am using an adafruit M4 express Cortex M4 core running at 120 MHz, 512 KB flash, 192 KB RAM

For now I want to use the m7 as a camera that can take a picture on demand from an arduino serial port.

Is it possible and do you know of any sample code for both arduino & openmv to

  1. Request (from the arduino) the openmv to take a picture (This is cleaner in my case than using an external pin trigger)
  2. Receive from the openmv a picture (binary data is fine, once the arduino receives it will be posted to a server)

Thanks!

Yes you’ll find so many examples for this if you search the forums:

http://forums.openmv.io/search.php?keywords=arduino+uart+serial

http://forums.openmv.io/search.php?keywords=arduino%2Buart&terms=all&author=&sc=1&sf=titleonly&sr=topics&sk=t&sd=d&st=0&ch=300&t=0&submit=Search

They don’t do exactly what you want to do, but you can put something together form the examples and then let me know if you need more help.

Hi, I can’t really give you all the code you need but I can point you to the right direction.

import pyb, sensor, image
sensor.reset()
sensor.set_frame_size(sensor.QVGA)
sensor.set_pixformat(sensor.RGB565)
uart = pyb.UART(3, 115200, timeout_char=1000)
while true:
    if uart.any():
        if uart.read(1) == 'p':
            img = sensor.snapshot().compress(quality=80)
            uart.write(img.size())
            uart.write(img)

When the camera receives ‘p’ on the uart it will send the jpeg stream.

As for the Arduino size of things, the first 4 bytes are the image size followed by the jpeg data which you want to write to disk. The data is kinda going to come back to back… so, you need to be able to handle the burst speed.

This is great. Thank you both for the fast replies!