🛠 Capturer une image avec la caméra GC2145 (DCMI)

Arduino Nicla Vision · intermediaire · Schéma : IMG-nicla-vision-intermediaire-1-niclavision-capture-camera.svg — Nicla Vision avec la caméra GC2145 reliée au bus parallèle DCMI du STM32H747, une image QVGA transitant vers le port USB

Objectives

Initialize the embedded 2 Mpx GalaxyCore GC2145 color camera, capture QVGA 320×240 images in RGB565 format via the STM32H747 parallel DCMI bus, and stream them over USB.

Hardware

Complete code

// Adapte de l'exemple officiel CameraCaptureRawBytes (ArduinoCore-mbed)
#include "camera.h"
#include "gc2145.h"

GC2145 galaxyCore;          // capteur couleur 2MP embarque
Camera cam(galaxyCore);     // API Camera commune
#define IMAGE_MODE CAMERA_RGB565

FrameBuffer fb;             // tampon par defaut 320x240x2

void blinkLED(uint32_t count) {
  pinMode(LED_BUILTIN, OUTPUT);
  while (count--) { digitalWrite(LED_BUILTIN, LOW);  delay(50);
                    digitalWrite(LED_BUILTIN, HIGH); delay(50); }
}

void setup {
  // QVGA 30 FPS ; clignotement infini si le capteur ne repond pas
  if (!cam.begin(CAMERA_R320x240, IMAGE_MODE, 30)) blinkLED(0xFFFFFFFF);
  blinkLED(5);              // 5 clignotements = camera OK
}

void loop {
  if (!Serial) { Serial.begin(115200); while (!Serial); }
  if (cam.grabFrame(fb, 3000) == 0)                 // timeout 3 s
    Serial.write(fb.getBuffer, cam.frameSize);  // frame RGB565 brute
  else
    blinkLED(20);                                   // erreur de capture
}

Expected verification

Upon upload, 5 flashes of the green LED confirm the GC2145 initialization. The viewer (Processing, RGB565 320×240 mode) displays a smooth stream. Infinite blinking from setup = the sensor is not responding on the bus (check that the core is up to date).

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials