The NORVI AI Optic camera module stands out as a versatile device designed for various imaging applications. Featuring a built-in display, users can easily preview captured images in real-time. Equipped with the Camera, this module delivers high-quality images, making it suitable for computer vision.
Additionally, its microSD card support allows for convenient storage and transfer of captured media files, ensuring ample storage space for extended usage. With an external trigger feature, users can synchronize image capture with external events or signals, expanding its utility in diverse scenarios.
The inclusion of a C type USB Port serves a dual purpose, facilitating both battery charging and programming tasks, making the NORVI AI Optic camera module a comprehensive solution for computer vision applications.
Board | ESP32-S3 Dev Module |
Flash Size | 16 |
Flash mode | QIO 80MHz |
USB CDC on Boot | Enabled |
USB firmware MSC on boot | Disabled |
USB DFU on boot | Disabled |
Upload mode | UART0 / Hardware CDC |
PSRAM | OPI PSRAM |
Programming Port | C type USB |
DEVICE POWER UP AND POWER DOWN #
The POWER UP and POWER DOWN mechanism is controlled by the battery managing system and its totally independent from the user program on the device.
Power Up #
Push the rotary switch for about 5 seconds and release then the device will power ON.
Power Down #
Push and release the rotary switch for about 15 seconds and the device will power down.
ROTARY SWITCH #
The rotary switch allows users to adjust the parameters or build a UI with UP / DOWN and Push Actions of the switch.
Functions of the switch,
- Push : Acts as a push button, used to power on and off the device.
- Rotation: Detects the direction and amount of rotation, used to navigate the settings of the device.
GPIOs for Rotary Switch #
Button_up | Connected to GPIO0. Can be used for adjusting parameters or a custom menu. This pin detects when the rotary switch is rotated upwards. |
Push | Connected to Battery manager, facilitates power ON and Power OFF, by long press. Short press sends a pulse to the ESP32-S3 through the GPIO 46. |
Button_down | This pin detects when the rotary switch is rotated downwards. Via PCA9536DGKR – P2 SCL2 – GPIO14 SDA2 – GPIO1 |
USB PORT #
The USB port on this device uses a USB Type-C connector. The device has a rechargeable battery, and the USB port can be used to charge the battery. This is used for programming the ESP32-S3 chip and its connected to the USB port of the ESP32-S3.
GPIOs for USB Port #
DP1/DP2 (GPIO20) | These pins are used for the positive data lines of the USB differential pair, carrying data to and from the device. |
DN1/DN2 (GPIO19) | These pins are used for the negative data lines of the USB differential pair, completing the data transmission circuit. |
MICROSD CARD SUPPORT #
The MEM2067 microSD card module provides storage capabilities to the camera. This module supports microSD cards and uses the Serial Peripheral Interface (SPI) for communication.
GPIOs for Micro SD Card #
CMD (GPIO38): | This pin is used for sending commands to the microSD card. |
CLK (GPIO39) | This pin provides the clock signal necessary for synchronizing the data transfer between the microcontroller and the microSD card. |
DATA (GPIO40) | This pin is used for data transmission between the microSD card and the microcontroller. |
LED FLASHLIGHTS #
NORVI AI Optic has high-power LEDs designed to provide bright, white light with high efficiency. The Flash Lights are controlled via the IO Expander PCA9536DGKR. The communication with the IO Expander is done using the I2C protocol.
LED_FLASH (LED FlashLight) | Via PCA9536DGKR – P1 |
TRIGGER BUTTON AND RESET #
These buttons are used to control the operating conditions of the device, the reset button is used to reset the system and the trigger button is used to take photos.
Press and Hold: Press and hold the reset button for a few seconds until the device resets.
Press and Hold: The trigger button allows taking photos by pressing and holding it.
DIGITAL INPUT (EXTERNAL TRIGGER) #
This product is a compact camera module with an internal trigger and an external trigger for capturing photos. The internal trigger allows pictures to be taken using an onboard button. Additionally, the module supports digital inputs for an external trigger.
An external sensor can be connected to the digital input terminal and photos can be taken without having to use the internal trigger button.
SETTING ESP32 S3 TO BOOT MODE #
If unable to upload code Connect the device to a computer via a USB Type-C cable, set the device to boot mode, by pressing the reset button while holding the joystick switch up .
UNDERSTANDING THE PROGRAM #
This code is designed for the ESP32-S3 microcontroller to initialize and control a camera module, display images on a TFT screen, and manage various parameters and hardware components via I2C devices.
The code integrates camera control, image display, and various hardware management functionalities. It initializes components, captures and displays images, and provides a user interface for adjusting camera settings. The loop function ensures continuous operation, updating settings, reading status, and controlling peripherals as needed.
Step into the example program by clicking here.
Include Libraries:
Various libraries are included, such as esp_camera, SPI, TFT_eSPI, TJpg_Decoder, Wire, PCA9536D, and Adafruit_ADS1X15.
Download the required libraries from here.
Defined variables and I2C detection:
The I2C devices connected to the system are detected and their addresses are printed out and Included structures for storing parameters, flags, and pin assignments.
#define BQ25180_ADDR 0x6A // I2C address of the bq25180
#define CGCTRL_REG_ADDR 0x4
#define IC_CTRL 0x7
#define SHIP_RST 0x9
#define SYS_REG 0xA
#define TMR_ILIM 0x8
#define IO_TRIGGER 0
#define IO_LED_FLASH 1
#define IO_BUTTON_DOWN 2
#define IO_BUTTON_UP 0
#define IO_SWITCH 46
Parameter Initialization:
Initial values for different camera parameters are set within an array.
Adafruit_ADS1115 ads;
PCA9536 io;
TFT_eSPI tft = TFT_eSPI();
OV5640 ov5640 = OV5640();
Parameter Structure:
A structure called Parameter is defined as a main menu to store the label, value, minimum, and maximum values for camera parameters.
unsigned int menu_index=0;unsigned int value_change_flag=0;
struct Parameter {
const char* label;
int value;
int minValue;
int maxValue;};
Parameter parameters[] = {...};
Array of Parameters:
An array of Parameter structures where each element represents a specific parameter. Each element of the array consists of a label (name), current value, minimum allowed value, and maximum allowed value for the corresponding parameter.
Parameter parameters[] = {
{"Brightness", 0, -2, 2},
{"Contrast", 2, -2, 2},
{"Saturation", 0, -2, 2},
{"Special Effect", 0, 0, 6},
{"White Balance", 1, 0, 1},
{"AWB Gain", 1, 0, 1},
{"WB Mode", 0, 0, 4},
{"Exposure Control", 0, 0, 1},
{"AEC2", 1, 0, 1},
{"AE Level", 2, -2, 2},
{"AEC Value", 800, 0, 1200},
{"Gain Control", 1, 0, 1},
{"AGC Gain", 0, 0, 30},
{"Gain Ceiling", 6, 0, 6},
{"BPC", 1, 0, 1},
{"WPC", 1, 0, 1},
{"RAW GMA", 1, 0, 1},
{"LENC", 1, 0, 1},
{"H-Mirror", 1, 0, 1},
{"V-Flip", 0, 0, 1},
{"DCW", 1, 0, 1},
{"Color Bar", 0, 0, 1},
{"Flash", 0, 0, 2},
{"SYSTEM", 0, 0, 2}
};
Integer variable representing the saturation parameters and the AEC (Automatic Exposure Control) parameters.
int param_saturation=0,param_saturation_max=2,param_saturation_min=-2;
int param_aec=0,param_aec_max=1200,param_aec_min=0;
Variables used for various triggers and switches.
unsigned int TRIGGER, SWITCH, B_UP, B_DOWN, TRIGGER_S, SWITCH_S, B_UP_S, B_DOWN_S;
unsigned int V_DELAY;
volatile int count = 0;
An Interrupt Service Routine (ISR) triggered by the joystick switch push. This is used to scroll through the parameters of the menu.
void IRAM_ATTR handleInterrupt() {
// Increase the count when interrupt occurs
menu_index++;
if(menu_index>23)menu_index=0;
}
TFT LCD DISPLAY #
Display Driver | ST7789 |
Display Type | TFT LCD Display |
Display Size | 2.1 inches |
Resolution | 240×320 Pixels |
GPIO for the TFT Display #
SCL (GPIO14) | Serial Clock Line |
SDA (GPIO1) | Serial Data Line |
DSP_CS (GPIO36) | Activates the display for communication. |
RS (GPIO37) | Differentiates between command and data registers. |
DSP_RST (GPIO48) | Resets the display to a known state. |
MOSI (GPIO47) | Used in SPI communication. |
SCLK (GPIO21) | Provides the clock signal for SPI communication. |
Programming the TFT Display #
This code initializes the display and JPEG decoder, sets up a callback for image rendering, and defines a function to display menu information and sensor readings on the TFT display.
displayInit Function
Initializes a TFT display and configures the JPEG decoder. It starts by initializing the display hardware and setting the rotation to landscape mode. Then, it fills the screen with a white background and configures the decoder to display JPEG images at their original size. Additionally, it adjusts the byte order for correct image rendering and sets a callback function to handle displaying decoded images on the screen.
void displayInit(){
tft.begin();
tft.setRotation(1);
tft.fillScreen(TFT_WHITE);
TJpgDec.setJpgScale(1);
TJpgDec.setSwapBytes(true);
TJpgDec.setCallback(tft_output);
}
tft_output Function
The “tft_output” function is a callback for the JPEG decoder, used to display JPEG images on a TFT display. It checks if the y-coordinate is within the display height; if not, it returns 0. Otherwise, it draws the image at the specified coordinates using the provided image data and returns 1 to signify successful rendering.
bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t* bitmap){
if( y>= tft.height()) return 0;
tft.pushImage(x, y, w, h, bitmap);
return 1;
}
display_menu Function
The “display_menu” function updates the TFT display to show a menu at the bottom along with additional information. It first draws a black rectangle at the bottom to serve as the menu background. Then, it sets the cursor position and text properties for displaying menu items. It prints the label and value of the current menu item within the rectangle. Additionally, it sets the cursor to the top left corner and prints a voltage value calculated from a