0

I have an Arducam 2MP plus camera wired to a raspberry pi Pico 2040 running circuitpython, I'm trying to take and store an image onto the Pico (just one), however from what I can tell the camera takes an image but doesn't return any data back to the Pico.

The code I have is modified from the Arducam GitHub example project where mine tries to save the data not sent it over usb cdc (link for the original GitHub post: https://github.com/ArduCAM/PICO_SPI_CAM).

This is the code I have at the moment:

import time as utime
import busio
import board
from Arducam import *
from board import *

once_number=128
mode = 0
start_capture = 1
stop_flag=0
data_in=0
value_command=0
flag_command=0
buffer=bytearray(once_number)
i2c = busio.I2C(board.GP27, board.GP26)

mycam = ArducamClass(OV2640, i2c)
mycam.Camera_Detection()
mycam.Spi_Test()
mycam.Camera_Init()
utime.sleep(1)
mycam.clear_fifo_flag()

mycam.OV2640_set_JPEG_size(OV2640_800x600)
mycam.set_format(JPEG)
mycam.OV2640_set_Light_Mode(Auto)
mycam.OV2640_set_Color_Saturation(Saturation2)
mycam.OV2640_set_Brightness(Brightness2)
mycam.OV2640_set_Contrast(Contrast2)
mycam.OV2640_set_Special_effects(Normal)

def read_fifo_burst():
    count=0
    lenght=mycam.read_fifo_length()
    mycam.SPI_CS_LOW()
    mycam.set_fifo_burst()
    file = open("file.txt", 'a')  # I know this is a txt not jpeg, its so I can see what's being outputed
    while True:
        mycam.spi.readinto(buffer,start=0,end=once_number)
        file.write(buffer)
        utime.sleep(0.00015)
        count+=once_number
        if count+once_number>lenght:
            count=lenght-count
            mycam.spi.readinto(buffer,start=0,end=count)
            file.write(buffer)
            mycam.SPI_CS_HIGH()
            mycam.clear_fifo_flag()
            break
        
        
while True:
    if start_capture==1:
        mycam.flush_fifo();
        mycam.clear_fifo_flag();
        mycam.start_capture();
        start_capture=0
        print("here")
    if mycam.get_bit(ARDUCHIP_TRIG,CAP_DONE_MASK)!=0:  # this line here
        read_fifo_burst()
        print("done")`

The line labeled 'this line here' doesn't seem to turn to a value that's not 0, if I remove this line I get (this is a printed output, not from the file, that wouldn't open properly):

bytearray(b'\x80\x1b\x04tf\x02\x04\x00\x19\x00\x04\x07\xa0\x10\x18\xc1\r@\x00\x04$\x00\x80\x84\x00\x04(7T\x91\x10X\teB\x00\x00\x01\x81\x01\x18\x00\x16\x00\x00\x10\x08\x00b\x00[*\x80\x80\x00\x00D\x82\x04\x00\x87\xc2\x10\x98\x05\x00BJ\x04\x18\x90\x00\x04 @\x00\x00\t\x10\x04\x00\x0cF@\x03X"\x02f\xa0\x12\x80\x00\x00\x81@*@\x02\x80\x12\x00@\x002F\x11\t\t \x04\x00q\x06\x10\x00\x00\x01\x04\x10\x04\x08 \xc0')

which when I try to decode I get: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

Does anyone know why the camera isn't sending any image data back (unless the return above is an image?) or why the get_bit() doesnt change from 0?

Also, if anyone has a better way for this to be done please share.

Thanks!

3 Answers3

0

I suggest you to try the followings. I hope they help you:

  1. Make sure the hardware/code requirements are satisfied.
  2. Make sure the SPI is activated whenever you take a photo.
  3. Check the correct pinout and Clock configurations (for instance using STM32CubeIDE. The CAM may have a problem with high-frequency SPI lines and work fine with lower frequencies.
  4. Try to monitor SPI-related pins (MISO, MOSI, CK, NSS) by oscilloscope. It is important to have correct physical signals on the mentioned lines according to the CAM catalog.
  5. Either Pull-up (for MISO, MOSI, and NSS) or pull-down (for CK) resistors must be used with the correct values (kOhms).
Mehrdad
  • 1
  • 1
0

I tried to play the Pico 2040 recently.Your buffer is worong ,You need to cheak file type.

import imghdr

binary_data='your buffer'

def get_image_type(binary_data):
    return print(imghdr.what(None, binary_data))

get_image_type(binary_data)

If return None mean the buffer is wrong. This is a example buffer

binary_data=b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00\x00\x00\x00\x00\x00\xff\xdb\x00C\x00\x0c\x08\t\x0b\t\x08\x0c\x0b\n\x0b\x0e\r\x0c\x0e\x12\x1e\x14\x12\x11\x11\x12%\x1a\x1c\x16\x1e,&.-+&*)06E;03A4)*<R=AGJMNM/:U[TKZELMJ\xff\xdb\x00C\x01\r\x0e\x0e\x12\x10\x12#\x14\x14#J2*2JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ\xff\xc4\x00\x1f\x00\x00\x01\x05\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\xff\xc4\x00\xb5\x10\x00\x02\x01\x03\x03\x02\x04\x03\x05\x05\x04\x04\x00\x00\x01}\x01\x02\x03\x00\x04\x11\x05\x12!1A\x06\x13Qa\x07"q\x142\x81\x91\xa1\x08#B\xb1\xc1\x15R\xd1\xf0$3br\x82\t\n\x16\x17\x18\x19\x1a%&\'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz\x83\x84\x85\x86\x87\x88\x89\x8a\x92\x93\x94\x95\x96\x97\x98\x99\x9a\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xff\xc4\x00\x1f\x01\x00\x03\x01\x01\x01\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\xff\xc4\x00\xb5\x11\x00\x02\x01\x02\x04\x04\x03\x04\x07\x05\x04\x04\x00\x01\x02w\x00\x01\x02\x03\x11\x04\x05!1\x06\x12AQ\x07aq\x13"2\x81\x08\x14B\x91\xa1\xb1\xc1\t#3R\xf0\x15br\xd1\n\x16$4\xe1%\xf1\x17\x18\x19\x1a&\'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x92\x93\x94\x95\x96\x97\x98\x99\x9a\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xff\xc0\x00\x11\x08\x00\xf0\x01@\x03\x01!\x00\x02\x11\x01\x03\x11\x01\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00?\x00\xf2\xcaJ\x00(\xa4\x01E\x02\x12\x8ac\x16\x8a@\x14P\x01E0\x16\x8a@\x14P\x01E\x00\x14\x94\x00RP\x01N\xa0\x04\xa2\x80\n(\x00\xa2\x80\n(\x00\xa2\x80\n(\x10\x94\xb4\x00\xb4\x94\xc6\x14\xb4\x84\x14\x94\x0c(\xa0\x02\x8a\x00)h\x00\xa2\x80\n(\x10Q@\xc2\x934\x00RP\x01E0\np\xa4\x00i(\x00\xa5\xa0\x04\xa2\x80\n(\x10Q@\xc2\x96\x81\x05\x14\x00QL\x02\x8a@\x14\x94\x00RP1h\xa0AK@\x05\x14\xc6\x14\xb4\x80JL\xd0\x02QL\x02\x8a\x00Z)\x00Q@\x0e\xa6\xd0\x01E\x00\x14\xb4\x00\x94P!h\xc5\x03\x16\x8a\x04\x14P\x02QL\x02\x8a\x00(\xa40\xa6\xd0\x02\xd2\xd0\x01E\x02\x16\x8a\x06&i(\x01(\xa6\x02\xd1@\x05\x14\x80Z(\x00\xa2\x80\x14R\x1a\x00J(\x01h\xa0\x03\x14\xb4\xc4-\x14\x86\x14P \xa2\x98\r\xa2\x80\nZ\x00)(\x00\xa4\xa40\xa5\xa0\x05\xc5\x1d(\x013M\xa0\x02\x8a\x00Z(\x00\xa5\xa0\x02\x8a\x00(\xa0\x02\x8a\x00\x05-\x006\x96\x80\x17\x14\xb4\xc0(\xa0AK@\x05\x14\x80(\xa0\x06\xd1LaE\x02\n(\x00\xa4\xc5!\x8b\x8a3@\r\xcd%\x00\x14P\x02\xd1@\x05\x14\x00\xb4\xb4\x00\x94\xb4\x00RP\x01E\x00\x14\xea\x00JZ\x00)i\x80Q@\x0bE\x00\x14\x94\x84\x14S\x01\xb4P\x01E\x00\x14\xb4\x0c)\xbb\xa8\x013IH\x02\x8a\x00Z(\x00\xa5\xa0\x02\xa4\x111\xed@\x08\xb1\xb3\xb6\x11K\x1fjVB:\xd0\x03(\xa0\x02\x8a\x00)q@\x05\x14\x00\x94\xea`.(\xc5\x00-\x14\x80)(\x00\xa4\xa6 \xa2\x90\r\xa2\x98\xc2\x96\x90\x82\x96\x98\tQ\xd00\xa5\xa4\x01E\x00\x14\xb4\x00\xe0\xa4\xf4\xa9\x92\xd8\xff\x00\x150\xb1(X\xd2\x97}#B\r\xcc\xa7\x0b\xc5&\xd6jD\x87\x92\xc7\xb5/\xd9d\xc6x\xfc\xe9\x93a\xbeK\x0e\xd4\x9bqL\x04\xa2\x90\x05\x14\xc0Jx\xa0\x05\xa2\x81\x05%\x00\x14R\x18\x94\x94\x08(\xa0\x06\xd2\xd3\x00\xa2\x80\x16\x8a\x00QQ\x1a\x06\x14R\x01iqL\x02\x9e\xab\x9a\x00\x95\x17o\xcd\x9a\x90\x92i\x16\x85\tN\x08\x05\x03\x17\xf0\xa6\xd0\x01E\x00\x14\xda@4\xa0\xa8\x8a\xd3!\xa0\xc5\x18\xa6":r\xd0\x03\xa8\xa0\x02\x92\x81\x05%!\x85%\x00\x14P!\xb4\xb4\xc0(\xa0\x05\xa5\xa0\x05\x15\x1b\xf5\xa0\x04\xa5\xa41iqLC\x82S\xc2\xbfj\x06\x89\x96\x1f\xef\x1a\x93\x18\xe9Rh%-0\x12\x92\x81\tE\x00\x14\xda\x06\x14\xc3@\x87\x03M#\x9a\x04\xc8\xe4M\xb4\xc1\xd6\x82I)(\x00\xa2\x80\x12\x92\x80\nJ\x04\x14\x94\x00QL\x05\xa5\xa0\x02\x8a\x06=j9z\xd0!\xa2\x9c\x16\x80%X\x89\xab\xfav\x93u\xa8\xc9\xb2\xca\xda[\x86\xff\x00aj\xe3\x1b\x92\xd9\xa1{\xa2\xa6\x90\x84j\x17\t\xf6\xbe\xd6\xb0\x1d\xc4VQ\xf6\xe2\xa6E\xc1u\nZ\x83A\xb4P\x01M\xa6\x02R\xd0\x01I@\x86\xd2\x1a@ \xa54\x00\x92|\xcbU\xe9\x90\xc9\x07JZ\x00J(\x01)(\x00\xa4\xa0\x02\x92\x81\tKL\x05\xa5\xa0\x02\x92\x80$\x8e\x9b7j\x00-\xd3\xccm\xa0d\xfa\n\xeat\xbf\x04\xea\xb7\x89\xe7K\x12\xd8\xdbw\x9a\xe8\xec\x02\xb4\x8ct\xbb%\xb3A\x87\x83\xb4\x11\xfb\xd9e\xd7.\x87\xf0\xaf\xcb\x15U\xbd\xf1\xce\xa7u\x07\xd9\xec\xd6-2\xd3\xa7\x95l1JS\xbe\x8ba\xc6:\xeas\x94Vf\xc1N\xa4\x03h\xa6\x01I@\tE!\x05%0\x12\x92\x90\r\xa5\xa0\x08\xc7\xa5Fh%\x8a\xb4\xeab\nJ\x00)(\x00\xa4\xa0\x02\x8a\x00\x8e\x96\x80\x16\x96\x98\x85\xa5\xa0\x07\'ZY\xbaP\x05\xdf\x0f\xeb\x97Z\x05\xdc\x97\x16B?5\xd3f]wb\x97T\xd65\x1da\xf7\xea7\x92\xcf\xe8\x18\xf0(\x02\x9a/5=\x05 \xa2\x82\x82\x9c*F\x04RP\x03L\x80TfZ\x00o\x98i\xbb\x8d\x02\x13u&}\xe9\x883K\xb8\xd2\x01w\xd3\x81\xa0cXe\xb8\xa6=\x04\xb1\xb5%1\x05%\x00\x14\x94\x00Q@\tE\x00GE\x00\x14\xea`--\x02\x1c\xbdi\xf2\xfd\xda\x00\x85z\xd4\xd4\x0c\x92:}\x05!h\xa0aK\xbc-!\x914\xf9\xe9Q\x16&\x90\x86\xe6\x8c\xd3\x10\x94R\x00\xdai\xc2&\xf4\xa6\x02\xf9\rI\xe4\xb5\x02\x13czRr(\x01\xa0\xd3\xbbR\x01\x95"\xf4\xa6!h\xa0\x04\xa2\x90\tE\x00\x14P\x04TS\x00\xa2\x80\x1dN\xa6!i\xed\xd2\x81\x90\xf7\xa9\xc5\x00J\x83\x9a\x91\xa8\x18\x94\x84\xe2\x91DM/\xa5FO\xad\x00&i(\x10\xe1\x19\xa7\xf9T\x0cv\xc0)q@\x0bK\xba\x80\x13u&h\x013E\x02\x18@4\xdd\xb4\x80\x8c\xd0\x9dh$\x96\x92\x98\x05\x14\x80J(\x00\xa2\x80!\xa4\xaa\x00\xa5\xa4\x03\x858S\x10\xb4\xea\x00\x8b\xbdZ\x8a\x90\xc7\xe7\xe6\xa9\x1a\x99DL\xfbj\x02\xd9\xa41\xb9\xa5\nM\x02%\x11z\xd3\xf0\x05\x03\x16\x92\x80\x12\x8a\x00JJ\x00(\xa4\x02Q@\x84\xa2\x98\r#5\x1fJD\x92\x8aZ\x00J(\x00\xa2\x80\n(\x02\xb5-P\tE \x1c)\xf4\xc0)E\x004\xf5\xabj\xbb\x10f\x80@i\xd2\xc8\x02\xfb\xd0QT\x9a@\x0bR\x02e\x8b\x1djJ\x06\x14\x94\x0cJJ\x04\x14\x94\x08(\xa41(\xa6 \xa4\xa0\x02\x92\x80\nksHA\x17\xa5I@\x84\xa2\x80\n(\x00\xa5\xa0\n\xb4S\x00\xa2\x98\x05:\x80\x16\x94P\x02\x1e\xb5i\xdb1\xd2\x1a\x17?-@\xc7&\x81\x8a\xa9\xba\xa6\x03\x14\xc0\\\xd2f\x90\xc4\xa4\xa0\x02\x92\x90\x05\x14\xc0J(\x00\xa2\x81\x05% \nJ\x00J(\x01\xa3\x87\xa9\xe8$J(\x00\xa2\x80\nZ\x00\xa7E0\n)\x80S\x85\x00--\x00!\xa9cl\xa5 \x1e?\xd5\xd3Q=i\x94KI\x9a\x06\x14b\x90\x86\xd1@\xc2\x8a\x04\x14\x94\x00Q@\x05%\x00\x14P\x02Q@\tE \x1a\xdd*h\xce\xe5\xa0\x91\xd4\x94\x80(\xa6\x02\xd1@\x14ij\x80(\xa4\x01KL\x07QH\x00\xd3\xa2\xeb@\x13\xd2\xd0P\x94\xb4\xc0_\xa5%\x006\x8a@\x14P0\xa4\xa4\x01E1\x05% \n(\x01(\xa0\x04\xa4\xa0AN\x84\xe1\xb6\xd0"j)\x00\x94S\x01ih\x03>\x8a\xa0\x16\x8a\x00)E \x1dE1\x05,\x7fz\x90\xcb\x14\x0ei\x94\x14P\x01\xd6\x92\x90\x05\x14\x00RP0\xa2\x81\x05\x14\x00\x94P\x01E\x02\x12\x8a@%%\x00%\x1d\x084\xc0\xb5E!\tE\x00\x14\xb4\x01\x9fKT\x02R\xd2\x00\xa5\xa0\x05\xa2\x81\x05I\x10\xa0d\xb4\x03L\xa0\xa5\xa0A\x9am!\x85\x14\x00Q@\x05\x14\x00RP\x01E\x00%\x14\x08)(\x00\xa4\xa0\x02\x92\x80&\x84\xe5~\x95%H\x84\xa2\x98\x05-\x00g\xd1T\x01E\x00\x14\xa2\x90\x0e\xa2\x81\x05K\x1fJ\x06>\x96\x99AIHAE\x03\n(\x00\xa2\x80\nJ\x00(\xa0\x02\x8a\x00J(\x10\x94P\x01I@\x05% \x1d\x19\xc3\xfdjj\x04\x14P\x01K@\x14(\xaa\x00\xa2\x90\x0bE\x00--\x00\x15,}(\x01\xf4\x1ac\nZ\x00Zm \n(\x18Q@\tE\x00\x14P!)(\x00\xa2\x80\x12\x8a\x00(\xa0\x02\x92\x80\x12\xa7\x07"\x90\x82\x8a\x00ZZ\x00\xa5IT\x01E \x16\x96\x80\x12\x96\x80\n\x92:\x00\x92\x96\x98\xc2\x8a\x06%\x14\x84\x14P0\xa2\x81\x05\x14\x00RP\x02RP\x01I@\x05\x14\x00\xb4P\x02Q@\x05*\x1e\xd4\x08}- \x16\x96\x98\x8atP0\xa4\xa0\x05\xa5\xa0\x06\xd2\xd0\x02\xd3\x93\xad\x00MKLbQ@\xc2\x8a\x04\x14R\x00\xa2\x80\x12\x8a\x00)(\x01(\xa0\x04\xa2\x80\n(\x00\xa2\x80\n(\x10\x94{\xd0\x04\x94R\x01i\xd4\xc4U\xa4\xa0aE\x00\x14P\x02R\xd0\x02\xd2\xafZ\x00\x9a\x96\x98\xc4\xa2\x80\n(\x00\xa2\x90\x05\x14\x00Q@\tI@\x05%\x00\x14P\x01E\x00\x14P\x01E\x00%\x14\x08Q\xd2\x9dHC\xa9\xd4\xc0\xabE\x03\x12\x96\x80\nJ\x00J(\x01iGZ`L)\xd4\x0cJ(\x00\xa2\x80\n(\x00\xa2\x90\tE\x00\x14\x94\x00\x94\xb4\x00\x94P \xa2\x80\n(\x00\xa4\xa0\x02\x8a\x00^\xf4\xb4\x848S\x850+Q@\xc2\x8a\x00)\xb4\x00QL\x05\xa5\xa4\x04\xa2\x9dL\x04\xa2\x81\x85\x14\x80(\xa0\x02\x8a`\x14\x94\x80(\xa0\x04\xa2\x80\n(\x10Q@\xc2\x8a\x04%-\x00%\x14\x00S\xa8\x01i\xe2\x81\x15\xa8\xa0aI\x9a\x00J(\x00\xa2\x80\x16\x8a\x00\x95zS\xa9\x80Q@\x05\x14\x0c(\xa4 \xa2\x98\tE \n)\x80\x94R\x00\xa2\x80\n(\x00\xa2\x80\n(\x01(\xa0\x02\x94P\x03\xa9\xc2\x81\x1f\xff\xd9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

If you want to check the image show,you can do this

import io
from PIL import Image
def main(binary_data):
    image = Image.open(io.BytesIO(binary_data))
    image.show()
main(binary_data)

Your buffer is wrong because you just catch a piece of file,not all

lenght(file total size)=mycam.read_fifo_length() 
once_number(you cut)=128 

good luck

Lu_yee
  • 1
  • 1
  • Do you know what the buffer size should be? – Ginger Jackets Feb 28 '23 at 20:16
  • Thebuffer size depends on your resolution,The buffer size depends on your resolution, the higher the resolution, the larger the size. I suggest you collect the all buffer first and try exporting the image to see how it looks."check the image show" as mentioned above. file.write(buffer) might be wrong , I suggest you print(buffer) and collecting – Lu_yee Mar 16 '23 at 08:28
  • The buffer displayed at the beginning should be '\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00' for it to be correct if the type of image is jpeg. – Lu_yee Mar 16 '23 at 08:31
0

I converted this program from CircuitPython to MicroPython in order to save images to the Pico 2040.

Pin wiring

  • sck=Pin(2)
  • mosi=Pin(3)
  • miso=Pin(4)
  • cspin=Pin(5)
  • sda=Pin(8)
  • scl=Pin(9)

Here is an example code:

filename:micro_ov2640.py

from ov2640_reg import *
from machine import Pin,I2C,SPI
import time


class ov2640(object):
def __init__(self):
    
    # chip select -- active low SPI
    self.spi=SPI(id=0,baudrate=4000000,bits=8, sck=Pin(2), mosi=Pin(3), miso=Pin(4))
    self.cspin = Pin(5, Pin.OUT, value=1)
    
    # I2C
    self.I2cAddress=0x30#SENSORADDR
    self.i2c = I2C(0,scl=Pin(9), sda=Pin(8),freq=1000000)
    print(self.i2c.scan())
    
    #self.spi_write(b'\x07',b'\x80')
    #self.spi_write(b'\x07',b'\x00')
    
def Camera_Detection(self):
    self.wrSensorReg8_8(0xff,0x01)
    id_h=self.rdSensorReg8_8(0x0a)
    id_l=self.rdSensorReg8_8(0x0b)
    print("id_h",id_h,"id_l",id_l)
    
def spi_Test(self):
    self.spi_write(0x00,0x56)
    value=self.spi_read(0x00)
    if(value[0]==0x56):
        print('SPI interface OK')
    else:
        print('SPI interface Error')
        
    
def spi_write(self,address,value):
    maskbits = 0x80
    buffer=bytearray(2)
    buffer[0]=address | maskbits
    buffer[1]=value
    self.cspin(0)
    self.spi.write(buffer)
    self.cspin(1)
    
def spi_read_father(self,number,address):
    maskbits = 0x7f
    buffer=bytearray(1)
    buffer[0]=address & maskbits
    self.cspin(0)
    self.spi.write(buffer)
    val = self.spi.read(number,buffer[0])
    self.cspin(1)
    return val
    
def spi_read(self,address):
    return self.spi_read_father(1,address)
    
def spi_reads(self,number,address):
    return self.spi_read_father(number,address)
    
def iic_write(self, buffer):
    self.i2c.writeto(self.I2cAddress,buffer)
    
def iic_read(self, buffer):
    self.i2c.readfrom_into(self.I2cAddress,buffer)
    
def wrSensorReg8_8(self,address,val):
    buffer=bytearray(2)
    buffer[0]=address
    buffer[1]=val
    self.iic_write(buffer)
    
def rdSensorReg8_8(self,address):
    buffer=bytearray(1)
    buffer[0]=address
    self.iic_write(buffer)
    self.iic_read(buffer)
    return buffer[0]

def wrSensorRegs8_8(self,reg_value):
    for data in reg_value:
        addr = data[0]
        val = data[1]
        if (addr == 0xff and val == 0xff):
            return 
        self.wrSensorReg8_8(addr, val)
        
def Camera_Init(self):
    self.wrSensorReg8_8(0xff,0x01)
    self.wrSensorReg8_8(0x12,0x80)
    time.sleep(0.1)
    self.wrSensorRegs8_8(OV2640_JPEG_INIT);
    self.wrSensorRegs8_8(OV2640_YUV422);
    self.wrSensorRegs8_8(OV2640_JPEG);
    self.wrSensorReg8_8(0xff,0x01)
    self.wrSensorReg8_8(0x15,0x00)
    self.wrSensorRegs8_8(OV2640_320x240_JPEG);
    #OV2640_set_Light_Mode
    self.wrSensorReg8_8(0xff,0x00)
    self.wrSensorReg8_8(0xc7,0x40)
    self.wrSensorReg8_8(0xcc,0x52)
    self.wrSensorReg8_8(0xcd,0x41)
    self.wrSensorReg8_8(0xce,0x66)
    #OV2640_set_Color_Saturation 色度
    self.wrSensorReg8_8(0xff, 0x00)
    self.wrSensorReg8_8(0x7c, 0x00)
    self.wrSensorReg8_8(0x7d, 0x02)
    self.wrSensorReg8_8(0x7c, 0x03)
    self.wrSensorReg8_8(0x7d, 0x28)
    self.wrSensorReg8_8(0x7d, 0x28)
    #OV2640_set_Brightness 亮度
    self.wrSensorReg8_8(0xff, 0x00)
    self.wrSensorReg8_8(0x7c, 0x00)
    self.wrSensorReg8_8(0x7d, 0x04)
    self.wrSensorReg8_8(0x7c, 0x09)
    self.wrSensorReg8_8(0x7d, 0x00)
    self.wrSensorReg8_8(0x7d, 0x00)
    

    #OV2640_set_Contrast 對比
    self.wrSensorReg8_8(0xff, 0x00)
    self.wrSensorReg8_8(0x7c, 0x00)
    self.wrSensorReg8_8(0x7d, 0x04)
    self.wrSensorReg8_8(0x7c, 0x07)
    self.wrSensorReg8_8(0x7d, 0x20)
    self.wrSensorReg8_8(0x7d, 0x18)
    self.wrSensorReg8_8(0x7d, 0x34)
    self.wrSensorReg8_8(0x7d, 0x06)  
    #OV2640_set_Special_effects
    self.wrSensorReg8_8(0xff, 0x00)
    self.wrSensorReg8_8(0x7c, 0x00)
    self.wrSensorReg8_8(0x7d, 0x00)
    self.wrSensorReg8_8(0x7c, 0x05)
    self.wrSensorReg8_8(0x7d, 0x80)
    self.wrSensorReg8_8(0x7d, 0x80)

def read_fifo_length(self):
    len1=self.spi_read(0x42)[0]
    len2=self.spi_read(0x43)[0]
    len3=self.spi_read(0x44)[0]
    len3=len3 & 0x7f
    lenght=((len3<<16)|(len2<<8)|(len1))& 0x07fffff
    print(len1,len2,len3,lenght)
    return lenght

def flush_fifo(self):
    self.spi_write(0x04,0x01)
def clear_fifo_flag(self):
    self.spi_write(0x04,0x01)
def start_capture(self):
    self.spi_write(0x04,0x02)

#save to file
def appendbuf(self,fn, picbuf, howmany):
    try:
        f = open(fn, 'a')
        f.write(str(picbuf))
        f.close()
    except OSError:
        print("error writing file")
    print("write %d bytes from buffer" % howmany)
    
def read_fifo_burst(self):
    self.flush_fifo()
    self.start_capture()
    lenght=self.read_fifo_length()
    buffer = self.spi_reads(lenght,0x3d)
    print(buffer)
    self.appendbuf("789.txt", buffer, lenght)
    self.cspin(1)
    self.clear_fifo_flag()
   
def test():
    a =ov2640()        
    a.spi_Test()
    a.Camera_Init()
    a.clear_fifo_flag()
    time.sleep(0.01)
    a.read_fifo_length()
    a.read_fifo_burst()


if __name__ == '__main__' :
    test()

filename:ov2640_reg.py

OV2640_JPEG_INIT =[
  [ 0xff, 0x00 ],
  [ 0x2c, 0xff ],
  [ 0x2e, 0xdf ],
  [ 0xff, 0x01 ],
  [ 0x3c, 0x32 ],
  [ 0x11, 0x00 ],   
  [ 0x09, 0x02 ],
  [ 0x04, 0x28 ],
  [ 0x13, 0xe5 ], 
  [ 0x14, 0x48 ],
  [ 0x2c, 0x0c ],
  [ 0x33, 0x78 ],
  [ 0x3a, 0x33 ],
  [ 0x3b, 0xfB ],
  [ 0x3e, 0x00 ],
  [ 0x43, 0x11 ],
  [ 0x16, 0x10 ],
  [ 0x39, 0x92 ],
  [ 0x35, 0xda ],
  [ 0x22, 0x1a ],
  [ 0x37, 0xc3 ],
  [ 0x23, 0x00 ],
  [ 0x34, 0xc0 ],
  [ 0x36, 0x1a ],
  [ 0x06, 0x88 ],
  [ 0x07, 0xc0 ],
  [ 0x0d, 0x87 ],
  [ 0x0e, 0x41 ],
  [ 0x4c, 0x00 ],
  [ 0x48, 0x00 ],
  [ 0x5B, 0x00 ],
  [ 0x42, 0x03 ],
  [ 0x4a, 0x81 ],
  [ 0x21, 0x99 ],
  [ 0x24, 0x40 ],
  [ 0x25, 0x38 ],
  [ 0x26, 0x82 ],
  [ 0x5c, 0x00 ],
  [ 0x63, 0x00 ],
  [ 0x61, 0x70 ],
  [ 0x62, 0x80 ],
  [ 0x7c, 0x05 ],
  [ 0x20, 0x80 ],
  [ 0x28, 0x30 ],
  [ 0x6c, 0x00 ],
  [ 0x6d, 0x80 ],
  [ 0x6e, 0x00 ],
  [ 0x70, 0x02 ],
  [ 0x71, 0x94 ],
  [ 0x73, 0xc1 ],
  [ 0x12, 0x40 ],
  [ 0x17, 0x11 ],
  [ 0x18, 0x43 ],
  [ 0x19, 0x00 ],
  [ 0x1a, 0x4b ],
  [ 0x32, 0x09 ],
  [ 0x37, 0xc0 ],
  [ 0x4f, 0x60 ],
  [ 0x50, 0xa8 ],
  [ 0x6d, 0x00 ],
  [ 0x3d, 0x38 ],
  [ 0x46, 0x3f ],
  [ 0x4f, 0x60 ],
  [ 0x0c, 0x3c ],
  [ 0xff, 0x00 ],
  [ 0xe5, 0x7f ],
  [ 0xf9, 0xc0 ],
  [ 0x41, 0x24 ],
  [ 0xe0, 0x14 ],
  [ 0x76, 0xff ],
  [ 0x33, 0xa0 ],
  [ 0x42, 0x20 ],
  [ 0x43, 0x18 ],
  [ 0x4c, 0x00 ],
  [ 0x87, 0xd5 ],
  [ 0x88, 0x3f ],
  [ 0xd7, 0x03 ],
  [ 0xd9, 0x10 ],
  [ 0xd3, 0x82 ],
  [ 0xc8, 0x08 ],
  [ 0xc9, 0x80 ],
  [ 0x7c, 0x00 ],
  [ 0x7d, 0x00 ],
  [ 0x7c, 0x03 ],
  [ 0x7d, 0x48 ],
  [ 0x7d, 0x48 ],
  [ 0x7c, 0x08 ],
  [ 0x7d, 0x20 ],
  [ 0x7d, 0x10 ],
  [ 0x7d, 0x0e ],
  [ 0x90, 0x00 ],
  [ 0x91, 0x0e ],
  [ 0x91, 0x1a ],
  [ 0x91, 0x31 ],
  [ 0x91, 0x5a ],
  [ 0x91, 0x69 ],
  [ 0x91, 0x75 ],
  [ 0x91, 0x7e ],
  [ 0x91, 0x88 ],
  [ 0x91, 0x8f ],
  [ 0x91, 0x96 ],
  [ 0x91, 0xa3 ],
  [ 0x91, 0xaf ],
  [ 0x91, 0xc4 ],
  [ 0x91, 0xd7 ],
  [ 0x91, 0xe8 ],
  [ 0x91, 0x20 ],
  [ 0x92, 0x00 ],
  [ 0x93, 0x06 ],
  [ 0x93, 0xe3 ],
  [ 0x93, 0x05 ],
  [ 0x93, 0x05 ],
  [ 0x93, 0x00 ],
  [ 0x93, 0x04 ],
  [ 0x93, 0x00 ],
  [ 0x93, 0x00 ],
  [ 0x93, 0x00 ],
  [ 0x93, 0x00 ],
  [ 0x93, 0x00 ],
  [ 0x93, 0x00 ],
  [ 0x93, 0x00 ],
  [ 0x96, 0x00 ],
  [ 0x97, 0x08 ],
  [ 0x97, 0x19 ],
  [ 0x97, 0x02 ],
  [ 0x97, 0x0c ],
  [ 0x97, 0x24 ],
  [ 0x97, 0x30 ],
  [ 0x97, 0x28 ],
  [ 0x97, 0x26 ],
  [ 0x97, 0x02 ],
  [ 0x97, 0x98 ],
  [ 0x97, 0x80 ],
  [ 0x97, 0x00 ],
  [ 0x97, 0x00 ],
  [ 0xc3, 0xed ],
  [ 0xa4, 0x00 ],
  [ 0xa8, 0x00 ],
  [ 0xc5, 0x11 ],
  [ 0xc6, 0x51 ],
  [ 0xbf, 0x80 ],
  [ 0xc7, 0x10 ],
  [ 0xb6, 0x66 ],
  [ 0xb8, 0xA5 ],
  [ 0xb7, 0x64 ],
  [ 0xb9, 0x7C ],
  [ 0xb3, 0xaf ],
  [ 0xb4, 0x97 ],
  [ 0xb5, 0xFF ],
  [ 0xb0, 0xC5 ],
  [ 0xb1, 0x94 ],
  [ 0xb2, 0x0f ],
  [ 0xc4, 0x5c ],
  [ 0xc0, 0x64 ],
  [ 0xc1, 0x4B ],
  [ 0x8c, 0x00 ],
  [ 0x86, 0x3D ],
  [ 0x50, 0x00 ],
  [ 0x51, 0xC8 ],
  [ 0x52, 0x96 ],
  [ 0x53, 0x00 ],
  [ 0x54, 0x00 ],
  [ 0x55, 0x00 ],
  [ 0x5a, 0xC8 ],
  [ 0x5b, 0x96 ],
  [ 0x5c, 0x00 ],
  [ 0xd3, 0x00 ],   
  [ 0xc3, 0xed ],
  [ 0x7f, 0x00 ],
  [ 0xda, 0x00 ],
  [ 0xe5, 0x1f ],
  [ 0xe1, 0x67 ],
  [ 0xe0, 0x00 ],
  [ 0xdd, 0x7f ],
  [ 0x05, 0x00 ],
  [ 0x12, 0x40 ],
  [ 0xd3, 0x04 ],   
  [ 0xc0, 0x16 ],
  [ 0xC1, 0x12 ],
  [ 0x8c, 0x00 ],
  [ 0x86, 0x3d ],
  [ 0x50, 0x00 ],
  [ 0x51, 0x2C ],
  [ 0x52, 0x24 ],
  [ 0x53, 0x00 ],
  [ 0x54, 0x00 ],
  [ 0x55, 0x00 ],
  [ 0x5A, 0x2c ],
  [ 0x5b, 0x24 ],
  [ 0x5c, 0x00 ],
  [ 0xff, 0xff ],
]

OV2640_YUV422=[
  [ 0xFF, 0x00 ],
  [ 0x05, 0x00 ],
  [ 0xDA, 0x10 ],
  [ 0xD7, 0x03 ],
  [ 0xDF, 0x00 ],
  [ 0x33, 0x80 ],
  [ 0x3C, 0x40 ],
  [ 0xe1, 0x77 ],
  [ 0x00, 0x00 ],
  [ 0xff, 0xff ],
]

OV2640_JPEG= [
  [ 0xe0, 0x14 ],
  [ 0xe1, 0x77 ],
  [ 0xe5, 0x1f ],
  [ 0xd7, 0x03 ],
  [ 0xda, 0x10 ],
  [ 0xe0, 0x00 ],
  [ 0xFF, 0x01 ],
  [ 0x04, 0x08 ],
  [ 0xff, 0xff ],
]




OV2640_160x120_JPEG = [
  [ 0xff, 0x01 ],
  [ 0x12, 0x40 ],
  [ 0x17, 0x11 ],
  [ 0x18, 0x43 ],
  [ 0x19, 0x00 ],
  [ 0x1a, 0x4b ],
  [ 0x32, 0x09 ],
  [ 0x4f, 0xca ],
  [ 0x50, 0xa8 ],
  [ 0x5a, 0x23 ],
  [ 0x6d, 0x00 ],
  [ 0x39, 0x12 ],
  [ 0x35, 0xda ],
  [ 0x22, 0x1a ],
  [ 0x37, 0xc3 ],
  [ 0x23, 0x00 ],
  [ 0x34, 0xc0 ],
  [ 0x36, 0x1a ],
  [ 0x06, 0x88 ],
  [ 0x07, 0xc0 ],
  [ 0x0d, 0x87 ],
  [ 0x0e, 0x41 ],
  [ 0x4c, 0x00 ],
  [ 0xff, 0x00 ],
  [ 0xe0, 0x04 ],
  [ 0xc0, 0x64 ],
  [ 0xc1, 0x4b ],
  [ 0x86, 0x35 ],
  [ 0x50, 0x92 ],
  [ 0x51, 0xc8 ],
  [ 0x52, 0x96 ],
  [ 0x53, 0x00 ],
  [ 0x54, 0x00 ],
  [ 0x55, 0x00 ],
  [ 0x57, 0x00 ],
  [ 0x5a, 0x28 ],
  [ 0x5b, 0x1e ],
  [ 0x5c, 0x00 ],
  [ 0xe0, 0x00 ],
  [ 0xff, 0xff ],
]

OV2640_176x144_JPEG=[
  [ 0xff, 0x01 ],
  [ 0x12, 0x40 ],
  [ 0x17, 0x11 ],
  [ 0x18, 0x43 ],
  [ 0x19, 0x00 ],
  [ 0x1a, 0x4b ],
  [ 0x32, 0x09 ],
  [ 0x4f, 0xca ],
  [ 0x50, 0xa8 ],
  [ 0x5a, 0x23 ],
  [ 0x6d, 0x00 ],
  [ 0x39, 0x12 ],
  [ 0x35, 0xda ],
  [ 0x22, 0x1a ],
  [ 0x37, 0xc3 ],
  [ 0x23, 0x00 ],
  [ 0x34, 0xc0 ],
  [ 0x36, 0x1a ],
  [ 0x06, 0x88 ],
  [ 0x07, 0xc0 ],
  [ 0x0d, 0x87 ],
  [ 0x0e, 0x41 ],
  [ 0x4c, 0x00 ],
  [ 0xff, 0x00 ],
  [ 0xe0, 0x04 ],
  [ 0xc0, 0x64 ],
  [ 0xc1, 0x4b ],
  [ 0x86, 0x35 ],
  [ 0x50, 0x92 ],
  [ 0x51, 0xc8 ],
  [ 0x52, 0x96 ],
  [ 0x53, 0x00 ],
  [ 0x54, 0x00 ],
  [ 0x55, 0x00 ],
  [ 0x57, 0x00 ],
  [ 0x5a, 0x2c ],
  [ 0x5b, 0x24 ],
  [ 0x5c, 0x00 ],
  [ 0xe0, 0x00 ],
  [ 0xff, 0xff ],
]

OV2640_320x240_JPEG=[
  [ 0xff, 0x01 ],
  [ 0x12, 0x40 ],
  [ 0x17, 0x11 ],
  [ 0x18, 0x43 ],
  [ 0x19, 0x00 ],
  [ 0x1a, 0x4b ],
  [ 0x32, 0x09 ],
  [ 0x4f, 0xca ],
  [ 0x50, 0xa8 ],
  [ 0x5a, 0x23 ],
  [ 0x6d, 0x00 ],
  [ 0x39, 0x12 ],
  [ 0x35, 0xda ],
  [ 0x22, 0x1a ],
  [ 0x37, 0xc3 ],
  [ 0x23, 0x00 ],
  [ 0x34, 0xc0 ],
  [ 0x36, 0x1a ],
  [ 0x06, 0x88 ],
  [ 0x07, 0xc0 ],
  [ 0x0d, 0x87 ],
  [ 0x0e, 0x41 ],
  [ 0x4c, 0x00 ],
  [ 0xff, 0x00 ],
  [ 0xe0, 0x04 ],
  [ 0xc0, 0x64 ],
  [ 0xc1, 0x4b ],
  [ 0x86, 0x35 ],
  [ 0x50, 0x89 ],
  [ 0x51, 0xc8 ],
  [ 0x52, 0x96 ],
  [ 0x53, 0x00 ],
  [ 0x54, 0x00 ],
  [ 0x55, 0x00 ],
  [ 0x57, 0x00 ],
  [ 0x5a, 0x50 ],
  [ 0x5b, 0x3c ],
  [ 0x5c, 0x00 ],
  [ 0xe0, 0x00 ],
  [ 0xff, 0xff ],
]

OV2640_352x288_JPEG=[
  [ 0xff, 0x01 ],
  [ 0x12, 0x40 ],
  [ 0x17, 0x11 ],
  [ 0x18, 0x43 ],
  [ 0x19, 0x00 ],
  [ 0x1a, 0x4b ],
  [ 0x32, 0x09 ],
  [ 0x4f, 0xca ],
  [ 0x50, 0xa8 ],
  [ 0x5a, 0x23 ],
  [ 0x6d, 0x00 ],
  [ 0x39, 0x12 ],
  [ 0x35, 0xda ],
  [ 0x22, 0x1a ],
  [ 0x37, 0xc3 ],
  [ 0x23, 0x00 ],
  [ 0x34, 0xc0 ],
  [ 0x36, 0x1a ],
  [ 0x06, 0x88 ],
  [ 0x07, 0xc0 ],
  [ 0x0d, 0x87 ],
  [ 0x0e, 0x41 ],
  [ 0x4c, 0x00 ],
  [ 0xff, 0x00 ],
  [ 0xe0, 0x04 ],
  [ 0xc0, 0x64 ],
  [ 0xc1, 0x4b ],
  [ 0x86, 0x35 ],
  [ 0x50, 0x89 ],
  [ 0x51, 0xc8 ],
  [ 0x52, 0x96 ],
  [ 0x53, 0x00 ],
  [ 0x54, 0x00 ],
  [ 0x55, 0x00 ],
  [ 0x57, 0x00 ],
  [ 0x5a, 0x58 ],
  [ 0x5b, 0x48 ],
  [ 0x5c, 0x00 ],
  [ 0xe0, 0x00 ],  
  [ 0xff, 0xff ],
]

OV2640_640x480_JPEG=[
    [0xff, 0x01],
    [0x11, 0x01],
    [0x12, 0x00],
    [0x17, 0x11], 
    [0x18, 0x75], 
    [0x32, 0x36], 
    [0x19, 0x01], 
    [0x1a, 0x97], 
    [0x03, 0x0f], 
    [0x37, 0x40],
    [0x4f, 0xbb],
    [0x50, 0x9c],
    [0x5a, 0x57],
    [0x6d, 0x80],
    [0x3d, 0x34],
    [0x39, 0x02],
    [0x35, 0x88],
    [0x22, 0x0a],
    [0x37, 0x40],
    [0x34, 0xa0],
    [0x06, 0x02],
    [0x0d, 0xb7],
    [0x0e, 0x01],   
    [0xff, 0x00],             
    [0xe0, 0x04],       
    [0xc0, 0xc8],       
    [0xc1, 0x96],       
    [0x86, 0x3d],       
    [0x50, 0x89],       
    [0x51, 0x90],       
    [0x52, 0x2c],       
    [0x53, 0x00],       
    [0x54, 0x00],       
    [0x55, 0x88],       
    [0x57, 0x00],       
    [0x5a, 0xa0],       
    [0x5b, 0x78],       
    [0x5c, 0x00],       
    [0xd3, 0x04],       
    [0xe0, 0x00],                             
    [0xff, 0xff],
]     
    
OV2640_800x600_JPEG=[
    [0xff, 0x01],
    [0x11, 0x01],
    [0x12, 0x00], 
    [0x17, 0x11], 
    [0x18, 0x75], 
    [0x32, 0x36],
    [0x19, 0x01],
    [0x1a, 0x97], 
    [0x03, 0x0f], 
    [0x37, 0x40],
    [0x4f, 0xbb],
    [0x50, 0x9c],
    [0x5a, 0x57],
    [0x6d, 0x80],
    [0x3d, 0x34],
    [0x39, 0x02],
    [0x35, 0x88],
    [0x22, 0x0a],
    [0x37, 0x40],
    [0x34, 0xa0],
    [0x06, 0x02],
    [0x0d, 0xb7],
    [0x0e, 0x01],   
    [0xff, 0x00],
    [0xe0, 0x04],
    [0xc0, 0xc8],
    [0xc1, 0x96],
    [0x86, 0x35],
    [0x50, 0x89],
    [0x51, 0x90],
    [0x52, 0x2c],
    [0x53, 0x00],
    [0x54, 0x00],
    [0x55, 0x88],
    [0x57, 0x00],
    [0x5a, 0xc8],
    [0x5b, 0x96],
    [0x5c, 0x00],
    [0xd3, 0x02],
    [0xe0, 0x00],                      
    [0xff, 0xff],
]     
       
OV2640_1024x768_JPEG=[
    [0xff, 0x01],
    [0x11, 0x01],
    [0x12, 0x00],
    [0x17, 0x11], 
    [0x18, 0x75], 
    [0x32, 0x36], 
    [0x19, 0x01], 
    [0x1a, 0x97],
    [0x03, 0x0f], 
    [0x37, 0x40],
    [0x4f, 0xbb],
    [0x50, 0x9c],
    [0x5a, 0x57],
    [0x6d, 0x80],
    [0x3d, 0x34],
    [0x39, 0x02],
    [0x35, 0x88],
    [0x22, 0x0a],
    [0x37, 0x40],
    [0x34, 0xa0],
    [0x06, 0x02],
    [0x0d, 0xb7],
    [0x0e, 0x01],   
    [0xff, 0x00],         
    [0xc0, 0xC8],          
    [0xc1, 0x96],          
    [0x8c, 0x00],          
    [0x86, 0x3D],          
    [0x50, 0x00],          
    [0x51, 0x90],          
    [0x52, 0x2C],          
    [0x53, 0x00],          
    [0x54, 0x00],          
    [0x55, 0x88],          
    [0x5a, 0x00],          
    [0x5b, 0xC0],          
    [0x5c, 0x01],          
    [0xd3, 0x02],                                
    [0xff, 0xff],
]  


OV2640_1280x1024_JPEG=[
    [0xff, 0x01],
    [0x11, 0x01],
    [0x12, 0x00], 
    [0x17, 0x11], 
    [0x18, 0x75], 
    [0x32, 0x36], 
    [0x19, 0x01], 
    [0x1a, 0x97], 
    [0x03, 0x0f], 
    [0x37, 0x40],
    [0x4f, 0xbb],
    [0x50, 0x9c],
    [0x5a, 0x57],
    [0x6d, 0x80],
    [0x3d, 0x34],
    [0x39, 0x02],
    [0x35, 0x88],
    [0x22, 0x0a],
    [0x37, 0x40],
    [0x34, 0xa0],
    [0x06, 0x02],
    [0x0d, 0xb7],
    [0x0e, 0x01],   
    [0xff, 0x00],                 
    [0xe0, 0x04],           
    [0xc0, 0xc8],           
    [0xc1, 0x96],           
    [0x86, 0x3d],           
    [0x50, 0x00],           
    [0x51, 0x90],           
    [0x52, 0x2c],           
    [0x53, 0x00],           
    [0x54, 0x00],           
    [0x55, 0x88],           
    [0x57, 0x00],           
    [0x5a, 0x40],           
    [0x5b, 0xf0],           
    [0x5c, 0x01],           
    [0xd3, 0x02],           
    [0xe0, 0x00],                                 
    [0xff, 0xff],
]         
       

OV2640_1600x1200_JPEG=[
    [0xff, 0x01],
    [0x11, 0x01],
    [0x12, 0x00], 
    [0x17, 0x11], 
    [0x18, 0x75], 
    [0x32, 0x36], 
    [0x19, 0x01], 
    [0x1a, 0x97], 
    [0x03, 0x0f], 
    [0x37, 0x40],
    [0x4f, 0xbb],
    [0x50, 0x9c],
    [0x5a, 0x57],
    [0x6d, 0x80],
    [0x3d, 0x34],
    [0x39, 0x02],
    [0x35, 0x88],
    [0x22, 0x0a],
    [0x37, 0x40],
    [0x34, 0xa0],
    [0x06, 0x02],
    [0x0d, 0xb7],
    [0x0e, 0x01],
    [0xff, 0x00],                                     
    [0xe0, 0x04],                                   
    [0xc0, 0xc8],                                   
    [0xc1, 0x96],                                   
    [0x86, 0x3d],                                   
    [0x50, 0x00],                                   
    [0x51, 0x90],                                   
    [0x52, 0x2c],                                   
    [0x53, 0x00],                                   
    [0x54, 0x00],                                   
    [0x55, 0x88],                                   
    [0x57, 0x00],                                   
    [0x5a, 0x90],                                   
    [0x5b, 0x2C],                                   
    [0x5c, 0x05],              
    [0xd3, 0x02],                                   
    [0xe0, 0x00],                                                         
    [0xff, 0xff], 
]  

you could test this.

Lu_yee
  • 1
  • 1