Wednesday, August 18, 2021

ov7670/ov2640 + ST7789 (IPS Display) on Raspberry Pi Pico/CircuitPython 7.0.0 alpha 6

This post show how to connect OV7670/OV2640 0.3-Megapixel Camera Module to Raspberry Pi Pico (in CircuitPython 7.0.0 alpha 6), display on ST7789 SPI IPS screen; running example ov2640_jpeg_sd_pico_st7789_2in.py.

ov7670:


It's library named adafruit_ov7670.mpy and example named ov7670_displayio_pico_st7789_2in.py in CircuitPython Bundle Libraries. I tried to run it on Pico with current stable CircuitPython 6.3.0. But fail with error of:

ImportError: cannot import name Colorspace


Then I tried on CircuitPython 7.0.0 alpha 6.

The connection between Pico and ov7670 camera module and st7789 SPI IPS display follow the ov7670_displayio_pico_st7789_2in.py example. But I have to add reset pin for display.


Connection:
Connection between Pico and ov7670 cam module
=============================================
	+-----------+
3V3	|3V3	DGND|	GND
GP9	|SCL	SDA |	GP8
GP7	|VS	HS  |	GP21
GP11	|PLK	XLK |	GP20
GP19	|D7	D6  |	GP18
GP17	|D5	D4  |	GP16
GP15	|D3	D2  |	GP14
GP13	|D1	D0  |	GP12
GP10	|RET	PWDN|
	+-----------+
		
*SCL/SDA are I2C control pin, pull-up resistors are needed.
 I use 2K ohm resistor for it.
		
Connection between Pico and ST7789 SPI IPS
==========================================
3V3		BLK
GP1		CS
GP0		DC
GP4		RES
GP3		SDA
GP2		SCL
3V3		VCC
GND		GND

Makesure Raspberry Pi Pico is installed with CircuitPython 7.0.0 alpha 6, download the matched bundle libraries 7.x. Copy adafruit_st7789.mpy and adafruit_ov7670.mpy from lib folder to Pico CIRCUITPY lib folder. Modify ov7670_displayio_pico_st7789_2in.py from examples folder to add reset pin to GP4, as shown in above screenshot.

remark:
In my test, once the program ran and stopped, to re-run it, have to disconnect and reconnect USB to Pico.



ov2640:


My ov2640 module have same pin assignment in ov7670, aligned to top with D0/D1 opened.

Connection:
Connection between Pico and ov2640 cam module
=============================================
	+-----------+
3V3	|3V3	GND |	GND
GP9	|SIOC	SIOD|	GP8
GP7	|VSYNC	HREF|	GP21
GP11	|PCLK	XCLK|	GP20
GP19	|D9	D8  |	GP18
GP17	|D7	D6  |	GP16
GP15	|D5	D4  |	GP14
GP13	|D3	D2  |	GP12
GP10	|RESET	PWDN|
	|D1	D0  |
	+-----------+
		
Library:
Copy adafruit_ov2640.mpy and adafruit_st7789.mpy from CircuitPython bundle 7.x lib to CIRCUITPY lib folder.

Example:

Locate and edit ov2640_displayio_pico_st7789_2in.py from CircuitPython bundle 7.x examples, as shown in this video:


No comments: