Skip to content

Commit fb5383a

Browse files
8bitkickfacchinm
authored andcommitted
Create ConnectionTest.ino
Takes snaphot of test pattern to verify its integrity
1 parent 54370aa commit fb5383a

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
OV767X - ConnectionTest.ino
3+
4+
Test that the connection between your Arduino and Camera is able to transfer data correctly at the given speed
5+
6+
Circuit:
7+
- Arduino Nano 33 BLE board
8+
- OV7670 camera module:
9+
- 3.3 connected to 3.3
10+
- GND connected GND
11+
- SIOC connected to A5
12+
- SIOD connected to A4
13+
- VSYNC connected to 8
14+
- HREF connected to A1
15+
- PCLK connected to A0
16+
- XCLK connected to 9
17+
- D7 connected to 4
18+
- D6 connected to 6
19+
- D5 connected to 5
20+
- D4 connected to 3
21+
- D3 connected to 2
22+
- D2 connected to 0 / RX
23+
- D1 connected to 1 / TX
24+
- D0 connected to 10
25+
26+
This example code is in the public domain.
27+
28+
*/
29+
30+
#include <Arduino_OV767X.h>
31+
#include <Arduino_CRC32.h>
32+
33+
int bytesPerFrame;
34+
int errors = 0;
35+
int count = 0;
36+
long timer = 0;
37+
Arduino_CRC32 crc32;
38+
39+
const bool error_checking = true;
40+
41+
byte data[176 * 144 * 2]; // QCIF at 2 bytes per pixel
42+
43+
void setup() {
44+
Serial.begin(9600);
45+
while (!Serial);
46+
47+
if (!Camera.begin(QCIF, RGB565, 5)) {
48+
Serial.println("Failed to initialize camera!");
49+
while (1);
50+
}
51+
52+
bytesPerFrame = Camera.width() * Camera.height() * Camera.bytesPerPixel();
53+
54+
// Enable the test pattern so we have a fixed image to run a checksum against
55+
Camera.testPattern();
56+
}
57+
58+
void loop() {
59+
60+
// benchmarking
61+
timer = millis();
62+
Camera.readFrame(data);
63+
timer = millis() - timer;
64+
Serial.print(timer);
65+
Serial.println("ms ");
66+
67+
// error checking
68+
if (error_checking) {
69+
uint32_t const crc32_res = crc32.calc(data, bytesPerFrame);
70+
71+
Serial.print("0x");
72+
Serial.print(crc32_res, HEX);
73+
74+
// Test against known checksum values (minor pixel variations at the start but were visually confirmed to be a good test pattern)
75+
if (crc32_res != 0x15AB2939 && crc32_res != 0xD3EC95E && crc32_res != 0xB9C43ED9) {
76+
errors++;
77+
};
78+
79+
count++;
80+
Serial.print(" errors:");
81+
Serial.print(errors);
82+
Serial.print("/");
83+
Serial.println(count);
84+
}
85+
86+
}

0 commit comments

Comments
 (0)