IOT

Arducam | Interfacing 5MP SPI Camera with Arduino UNO

In this tutorial, we will interface the Arducam Mega Camera, a 5MP SPI camera, with the Arduino UNO. The OV7670 Camera with an I2C interface is one of the older camera modules still used on Arduino boards. However, the camera has a communication issue that makes it difficult and slow, which significantly slows down image capture and video streaming. Additionally, the majority of camera projects rely on the pricey ESP32 CAM Module.

Arducam recently unveiled a renowned camera solution that makes it easy to link one or more cameras to any microcontroller. It is aimed primarily at embedded machine vision, artificial intelligence, and IoT devices that run on batteries. With a single industry-standard SPI interface, the Arducam Mega Camera can communicate with any microcontroller. For frame buffers or register settings, RAM is not needed. The fact that it works flawlessly with 3.3V and 5V systems is its strongest feature.

As part of this project, we will connect a 5-megapixel Arducam Mega Camera to an Arduino UNO Board and perform a variety of tasks, including as image capture at different pixel resolutions. Additionally, we’ll stream several videos solely using an 8-bit Arduino board. For the Arducam Mega camera, Arducam has published Arducam Mega SDK, which greatly simplifies programming. So let’s take a closer look at this camera and how it works.

Arducam Mega Camera

One or more cameras can be connected to any microcontroller using the renowned Arducam Mega Camera with little to no effort. It primarily targets battery-powered IoT devices, embedded machine vision, and applications utilising artificial intelligence.

Arducam Mega SPI Camera

Any microcontroller with a single, industry-standard SPI interface can be used with Arducam Mega. VCC and GND are not necessary; only 4 GPIOs are needed. For frame buffers or register settings, RAM is not needed. It works perfectly with 3.3V and 5V systems. With Arduino, STM8/STM32, ESP8266/ESP32, MSP430, Nordic, Renesas, and other MCU systems, the camera can be utilised directly.

The camera was created specifically for energy-saving uses. When your MCU is asleep, you may totally turn off the camera without worrying about loading lengthy register settings because it does this for you fast (in less than 100 ms) and automatically. Arducam Mega cameras come in two variations, one with 3MP (fixed focus) and the other with 5MP (autofocus). You may easily put it wherever you wish because it comes with a default enclosure.

Arducam Mega Camera

The camera’s ability to use more than 4 camera modules simultaneously for still photos and output in a sequential manner is its strongest feature.

The SDK’s thorough architecture and complete open-source design make it simple to add a new MCU. Through the API functions, you can control the camera as if you were using a DSLR camera by pressing buttons. You can worry-free use our SDK source code into your own code thanks to the MIT licence.

Specifications & Features

Arducam Mega – 3MPArducam Mega – 5MP-AF
InterfaceSPI (4-wire)SPI (4-wire)
Speed8Mhz8Mhz
Optical Size1/4″1/4″
Shutter TypeRollingRolling
Sensor Resolution2048×15362592×1944
Still Resolution320×240640×4801280×7201600×12001920×10802048×1536320×240640×4801280×7201600×12001920×10802592×1944
Power Supply3.3V/5V3.3V/5V
Power Consumption≤750 mW≤1W
Wake-Up Time42ms94ms
Focus60cm~INF8cm~INF (Autofocus)
Focal ratio (F-Stop)F2.8F2.0
Focal length3.3mm3.3mm
View Angle68.75 Degrees (Diagonal)68.75 Degrees (Diagonal)
Output FormatRGB/YUV/JPEGRGB/YUV/JPEG
Dimensions33x33x17 mm33x33x17 mm

Pinouts

Any Microcontroller with a single standard SPI interface can be used with the Arducam Mega (either native or mimic one).

Arducam Mega Camera Pinout

Only four pins (GPIOs) are required excluding VCC and GND.

Brief of Arducam Mega SDK

For the Arducam Mega camera, Arducam has published Arducam Mega SDK. The Arducam Mega API SDK is a C and C++ package that includes useful classes and functions to aid with the majority of daily operations. Both C++ API and C API are supported. The HAL layer, Arducam Mega Cam protocol layer, and API are all included in the SDK.

SDK framework Arducam SDK library provides C API and C++ API. Regarding API’s function, Users can get details from C API Reference and C++ API Reference.

To interface with the SPI camera, the Arducam Mega Cam protocol layer is employed. The HAL layer’s functionality is utilised to support a variety of systems. The SDK currently supports the Arduino UNO, Arduino Mega2560, ESP32, ESP8266, STM32, MSP430, PICO, and RPI platforms. A particular hardware platform is communicated with via the Platform specific SPI bus driver. Users should alter both this layer and the HAL layer if they want to customize the SDK for their particular platform.

Interfacing 5MP Arducam Mega Camera with Arduino UNO

Let’s now examine how to connect the Arducam Mega, a 5-megapixel SPI camera, to an Arduino board. As seen in the graphic below, the connection diagram is quite straightforward.

Interfacing SPI Camera Arduino

The 5MP Arducam Mega Camera with Arduino UNO Board connection is shown below.

Camera PinArduino UNO Board
VCC5V
GNDGND
SCK13
MISO12
MOSI11
CS7

You can directly connect the Camera with Arduino Board using the jumper wires.

Arducam Arduino

Arducam Mega Library Installation

The library for Arduino Boards and other microcontrollers has been made available by Arducam. The Arduino IDE is used to configure the environment and use it.

Library Link: https://github.com/ArduCAM/Arducam_Mega.git

Downloaded the library file & copy the extracted folder to the Arduino library folder.

Source Code/Program

You can test the Camera using the sample code from the Arduino library example after adding the library to the Arduino Library folder.

We will test the camera using one of the many examples available for this project named full featured.

Choose the Arduino UNO Board from the Board list after choosing the example, and then click the upload button to upload the code to the board.

Testing the Camera

We need GUI visualization software to test the camera’s functionality. So click on the following link to download the Arducam program.

https://github.com/ArduCAM/Arducam_Mega/releases/download/v1.0.0/ArducamMegaSetup_Windows_x64.exe

Install the software on your computer after downloading it.

After installation, choose the Arduino UNO port number and click “open.” The baud rate is 921600.

  • The Camera is now connected to the software for visualisation. So that you can view everything on the GUI Screen, you can move the camera in different directions.
  • To snap a picture, press the image button. The display window can be closed by clicking the close button. Additionally, you have a resolution and format choice.
  • To enable the video button’s default 320×240 resolution video streaming option, click it. In order to turn off video streaming mode, click the close button.
  • By default, auto exposure is turned on. Turning off automatic exposure is necessary when utilizing manual exposure.
  • By default, the auto gain is turned on. You must disable automatic gain in order to use manual gain.

The program has controls for adjusting the brightness, contrast, EV, saturation, special effects, white balance, and focus.

The 5MP Arducam Mega Camera has an autofocus control. You can choose to use or not use this feature. You can choose to enable or disable the continuous focus feature; by default, it is turned off.

ParameterFunction
OpenEnable the focus function
SingleTimeEnable single focus
PersistentEnable continuous focus
StopPause autofocus
CloseTurn off focus

Conclusion

I hope all of you have understood the basics of Interfacing 5MP SPI Camera with Arduino UNO. We MATHA ELECTRONICS will be back soon with more informative blogs soon.

Leave a Reply

Your email address will not be published.