Close
0%
0%

Camera Shield for S2 Mini

OV2640 shield for the S2 Mini ESP32-S2 board.

Similar projects worth following

With CircuitPython now supporting a camera, it would be nice to have a camera shield to use with my robot #Fluffbug. The OV2640 camera module is pretty powerful (it can create JPEG data to stream), and the S2 Mini has enough pins to drive it, so the only inconvenience left are three voltages need for powering the camera. The shield takes care of that.

Zip Archive - 26.45 kB - 10/26/2021 at 13:05

Download

s2-mini-cam-v1.fzz

fritzing design

x-fritzing-fzz - 46.30 kB - 10/26/2021 at 13:04

Download

  • 1 × VVS-8225N-v1.0 OV2640 Camera with a matching socket
  • 1 × AP7365-15WG-7 1.5V LDO
  • 1 × AP7365-28WG-7 2.8V LDO
  • 2 × 1µF Capacitor
  • 1 × 14pF Capacitor

View all 6 components

  • Testing

    deʃhipu3 days ago 0 comments

    The PCBs finally arrived, but turns out there was a mistake at the fab, and all holes that were supposed to be 0.9mm are 0.6m instead. I managed to solder pin headers to them anyways, so let's do some testing!

    For the test, I decided it would be the easiest to do it with a display. So I wired an ILI9341 to the pins that are not used by the shield, and... it didn't work. Great, displays were supposed to be a solved problem. After some poking around and testing, it turns out that the silkscreen on the Lolin S2 Mini I have is wrong, and it has pins 12 and 13 swapped. After swapping the pins, it works. Great, so now time to try the test code. Based on Adafruit examples, I came up with this:

    import board
    import terminalio
    import displayio
    import adafruit_ili9341
    import busio
    import adafruit_ov2640
    
    
    displayio.release_displays()
    display_bus = displayio.FourWire(
        busio.SPI(clock=board.IO7, MOSI=board.IO5),
        command=board.IO9,
        chip_select=board.IO12,
        reset=board.IO11,
        baudrate=80_000_000,
    )
    display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)
    
    
    i2c = busio.I2C(scl=board.IO39, sda=board.IO40)
    cam = adafruit_ov2640.OV2640(
        i2c,
        data_pins=(board.IO21, board.IO17, board.IO16, board.IO18, board.IO33,
                   board.IO34, board.IO35, board.IO36),
        clock=board.IO14,
        vsync=board.IO38,
        href=board.IO37,
        mclk=board.IO13,
        mclk_frequency=20_000_000,
        size=adafruit_ov2640.OV2640_SIZE_QVGA,
    )
    
    cam.flip_x = False
    cam.flip_y = True
    pid = cam.product_id
    ver = cam.product_version
    print(f"Detected pid={pid:x} ver={ver:x}")
    # cam.test_pattern = True
    
    g = displayio.Group(scale=1)
    bitmap = displayio.Bitmap(320, 240, 65536)
    tg = displayio.TileGrid(
        bitmap,
        pixel_shader=displayio.ColorConverter(
            input_colorspace=displayio.Colorspace.BGR565_SWAPPED
        ),
    )
    g.append(tg)
    display.show(g)
    
    display.auto_refresh = False
    while True:
        cam.capture(bitmap)
        bitmap.dirty()
        display.refresh(minimum_frames_per_second=0)
    
    cam.deinit()

     And... nothing. It seems to hang on the cam.capture(bitmap) line. The good news is that the i2c communication seems to work, as it reports the pid and version correctly. I will need to investigate this further.

  • Pinout

    deʃhipu10/29/2021 at 11:17 0 comments

    Just to make my life a little bit easier in the future, here is the current pinout of the shield:

    PinSignalNote
    D16D4Data
    D17D3Data
    D18D5Data
    D21D2Data
    D33D6Data
    D34D7Data
    D35D8Data
    D36D9Data
    D37HS (HREF)Horizontal Sync
    D38VSyncVertical Sync
    D39SIO_CI2C SCL
    D40SIO_DI2C SDA
    ENRSTReset
    D14PCLKClock
    D13MCLKClock

  • Camera in CircuitPython

    deʃhipu10/29/2021 at 11:05 0 comments

    There is ongoing work being done by Jeff Epler to bring the cameras to CircuitPython. There is an excellent tutorial available here: https://learn.adafruit.com/capturing-camera-images-with-circuitpython

    But this is not all. Right now Jeff is working on a way to produce animated GIF images directly from the camera, and save them to the SD card.

    There is also a way to stream the video: https://learn.adafruit.com/circuitpython-webcam-with-ov2640

    So I'm confident that even if my own software experiments fail, the shield will still prove useful.

  • What is this for?

    deʃhipu10/26/2021 at 13:57 0 comments

    A bit of explanation is needed here. Obviously an ESP32-S2 is not going to be able to do much with a camera, lacking the processing power and memory. I hope to make it stream low-resolution video over WiFi, and maybe, if in the right light conditions, find color blobs at one frame per 10 seconds.

    Oh, of course I want to put it on my robot, here's a mockup:

    Since both the robot and the shield are waiting for the PCBs, I used the previous version of the robot and some random shield I had lying around, but you get the idea.

    Ideally, if I have a lot of time, and can understand enough of the code, I might be able to port the Apriltags code from OpenMV and use it with the robot — that would be an awesome thing to do, but I doubt if my skills are sufficient.

  • Version 1 PCB

    deʃhipu10/25/2021 at 21:34 0 comments

    This is the first attempt at this shield, and it's mostly based on guesswork, datasheet, schematic for the ESP32 Cam board, and some bad quality images of the pinouts I found online. I have absolutely no idea if it will work, but I can try. The design is pretty dense:

    I didn't feel like fixing the angles of all the traces, so you will have to suffer. The render doesn't look bad:

    There are two voltage regulators, each with its own capacitor, two resistors for I2C pull-ups, a resistor to pull-down the enable pin on the camera, and a 14pF capacitor on the PCLK line, no idea why, but ESP32 Cam had it, so I copied it. And of course the camera socket itself, which is a fun 0.5mm-pitch footprint.

View all 5 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates