ESP32-CAM: ESP32 with camera and SD card slot
The name says it all: the ESP32-CAM is a WiFi / Bluetooth development board with both an ESP32 microcontroller and a camera. There are also a number of GPIOs available and there is a connection for an external antenna. With that, the board looks a bit like the TTGO T-Journal from Lilygo, but there are also a number of important differences.
|USB to serial||No||CP2104|
|Antenna||PCB + U.FL||SMA + U.FL|
This board has no USB-to-serial interface. Programming must, therefore, be done via an external interface. This also means no power can be supplied via USB. Furthermore, a battery management circuit and an OLED display are missing. In contrast, this board does have an SD card slot and LED flashlight, and it is a lot more compact. This board was again supplied by VNGsystems from Gouda.
As mentioned above, a USB connection is missing. The board must, therefore, be powered via the 5V pin and GND pin. I use a breadboard supply for this, set to 5V.
External antenna or PCB
The ESP32-S module has an antenna on the PCB, but also a U.FL connection for an external antenna. You can activate the desired antenna by the correct placement of a zero-ohm resistor (bridge). The upper position activates the antenna on the PCB, the lower one activates the U.FL connection. The external connection was activated on my board, see photo.
ESP32-CAM programming: serial interface
The board does not have a serial interface, so you need an external interface to program it. I use an FTDI clone here. Note that the interface must operate at 3V: the RX / TX pins on the ESP32 are not 5V tolerant.
To put the ESP32 in programming mode, pin IO0 must be connected to GND. After programming, this connection can be broken again. Connect everything as follows:
- FTDI interface: RX to U0T and TX to U0R on the ESP32-CAM
- Power supply: GND to the FTDI interface, GND and 5V to the ESP32-CAM
- ESP32-CAM: IO0 to GND (remove after programming)
|FTDI (3V)||ESP32-CAM||POWER (5V)|
Programming ESP32-CAM: Arduino IDE
When you have connected the board and the serial interface you can program it with the good old Arduino IDE. First of all, you must, of course, have the IDE installed, along with the ESP32 core. If you have not done that yet, first read ESP32 with Arduino IDE on Linux and Windows.
First, choose the correct ESP32 module:
Tools > Board: > “ESP32 Wrover module”
Choose the correct partition scheme:
Tools > Partition Scheme: > “Huge APP (3MB No OTA)”
Choose the correct USB port:
Tools > Port: > the port to which the serial interface is connected
The Arduino IDE is now ready for use with the board.
Example sketch: CameraWebServer
To test the ESP32-CAM you can upload the sample camera “CameraWebServer” to the board.
The sample sketch can be found here in the Arduino IDE:
File > Examples > ESP32 > Camera > CameraWebServer
Before you can upload the sketch to your board, you must first make two changes to the code:
- change the definition of the ESP32 module
- enter the SSID plus password of your WiFi network
Change the #define statement from #define CAMERA_MODEL_WROVER_KIT
// Select camera model #define CAMERA_MODEL_WROVER_KIT //#define CAMERA_MODEL_ESP_EYE //#define CAMERA_MODEL_M5STACK_PSRAM //#define CAMERA_MODEL_M5STACK_WIDE //#define CAMERA_MODEL_AI_THINKER
to #define CAMERA_MODEL_AI_THINKER
// Select camera model //#define CAMERA_MODEL_WROVER_KIT //#define CAMERA_MODEL_ESP_EYE //#define CAMERA_MODEL_M5STACK_PSRAM //#define CAMERA_MODEL_M5STACK_WIDE #define CAMERA_MODEL_AI_THINKER
Enter the SSID and password of your WiFi network:
const char* ssid = "*********"; const char* password = "*********";
You can now compile the sketch and upload it to the board. When the upload is complete, remove the connection between pin IO0 of the ESP32-CAM and GND of the power supply.
Then restart the board and open the serial monitor of the Arduino IDE. When the WiFi connection between the ESP32-CAM and the network is successful, the IP address of the board appears in the serial monitor.
Copy this IP address to the address bar of your browser. You now enter the CameraWebServer interface where you can experiment with all kinds of settings.
Scroll all the way down and click the Start stream button. If all went well you will now see a live video stream from the OV2640 camera.
To be continued
The following also applies to this board: to be continued. Because just trying out an example ketch is of course not very exciting. What can we do with the SD card reader and GPIOs? What fun projects can we all do with the ESP32-CAM? There is still plenty to discover and experiment with, so keep an eye on this blog for more articles about this board!
Camera: OV2640 2 megapixel
WIFI: 802.11 b / g / n / e / i (up to 150 Mbps)
Bluetooth: v4.2BR / EDR and BLE standard
MicroSD card: Maximum 4 GB
Supply voltage: 5V
Programming voltage: 3.3V
Dimensions: 40.5mm x27mm x4.5mm
To be able to show and test of ESP32, we have chosen two Modbus devices: A temperature/humidity sensor and a 4-port relay card. Using an USB-to-RS485 adapter connected to a Windows PC, using some free Modbus control software, first the slave addresses of the devices need to be changed – they come with 1 as default, and at least one of the devices need to be set to a different address.