0

members

Easy Raspberry basics: Project 29e Raspberry PI 3 model B, ESP32-CAM Development Board and Home Assistan

of Acoptex.com in Raspberry Pi 3

Raspberry basics: Project 29e

Project name: Raspberry PI 3 model B, ESP32-CAM Development Board and Home assistant

Tags: Raspberry, Raspberry PI 3 model B board, vers 1.1, v 1.1, Home assistant, home assistant version 0.95.4, ESP32-CAM Development Board, Ai-Thinker, ESP32-CAM, Development Board with camera, OV2640, OV7670, seeedstudio, Web Server, camera web server, FTDI programmer, ESP32CAM, ESP32 Camera Module with Face Recognition

Attachments:  sketchcopy_configuration.yaml

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1.Raspberry PI 3 model B 1 pc

2. Micro SD card and SD card adapter 2 pcs

3. Micro USB power supply (2.1 A, max 2.5 A) 1 pc

4. USB keyboard 1 pc

5. USB mouse 1 pc

6. TV or PC monitor 1 pc

7. HDMI cable 1 pc

8. Jumper cables F-F

9. ESP32-CAM Development Board with camera 1 set

10. Arduino IDE ( you can download it from here  )

11. USB to TTL/Serial adaptor/converter 1 pc

12. WiFi AntennaCompact Internal WiFi Antenna with U.FL connector and 5.9 inch cable 1 pc (optional)

General

We will learn how to use the Ai-Thinker ESP32-CAM Development Board as Camera Web Server in Home Assistant on Raspberry Pi.

There were some ESP32 camera boards launched previously such as ESP32-PICO-tinyCAM, but most seem to have been phased out. Seeed Studio had AI Thinker ESP32-CAM development board with a 2MP camera for $9.90. This development board can be programmed with ESP-IDF as explained in details in Github or in Arduino IDE. The demo code takes a QR code, and outputs it as ASCII code in the serial console. Another option - M5Stack ESP32 camera (ESP32CAM) board sold for $13.90 shipped on Banggood. The latter features the same OV2640 camera module, does not come with a micro SD card, but includes a USB port, and a grove connector, as well as pads for soldering MPU6050 & BME280 sensors. Another advantage is support LiPo battery via IP5306 charger chip.

We will learn in this project about the ESP32-CAM Development Board with camera (for more details please check seeedstudio.com website), how to connect it with USB to TTL converter or Arduino Uno to your PC/laptop.

Understanding the USB to TTL converter

You can read more about them here.

Understanding the ESP32-CAM Development Board with camera

The ESP32-CAM has a very competitive small-size camera module that can operate independently as a minimum system with a footprint of only 27*40.5*4.5mm and a deep sleep current of up to 6mA.

ESP-32CAM can be widely used in various IoT applications. It is suitable for home smart devices, industrial wireless control, wireless monitoring, QR wireless identification, wireless positioning system signals and other IoT applications. It is an ideal solution for IoT applications.

ESP-32CAM adopts DIP package and can be directly inserted into the backplane to realize rapid production of products, providing customers with high-reliability connection mode, which is convenient for application in various IoT hardware terminals.

The ESP32-CAM Development Board with camera doesn’t come with a USB connector, so you need an USB to TTL/Serial adaptor/converter to upload code through the  serial pins (U0R and U0T pins).

Features:

  • The smallest 802.11b/g/n Wi-Fi BT SoC Module
  • Low power 32-bit CPU,can also serve the application processor
  • Up to 160MHz clock speed,Summary computing power up to 600 DMIPS
  • Built-in 520 KB SRAM, external 4MPSRAM
  • Supports UART/SPI/I2C/PWM/ADC/DAC
  • Support OV2640 and OV7670 cameras,Built-in Flash lamp.
  • Support image WiFI upload
  • Support TF card
  • Supports multiple sleep modes.
  • Embedded Lwip and FreeRTOS
  • Supports STA/AP/STA+AP operation mode
  • Support Smart Config/AirKiss technology
  • Support for serial port local and remote firmware upgrades (FOTA)

Specifications:

  • Dimensions 40.5mm x27mm x4.5mm
  • Weight G.W 20g
  • Battery Exclude
  • Package DIP-16
  • SPI Flash Default 32Mbit
  • RAM 520KB SRAM +4M PSRAM
  • Bluetooth Bluetooth 4.2 BR/EDR and BLE standards
  • Wi-Fi 802.11 b/g/n/
  • Support interface UART,SPI,I2C,PWM
  • Support TF card Maximum support 4G
  • IO port 9
  • UART Baudrate Default 115200 bps
  • Image Output Format JPEG( OV2640 support only ), BMP,GRAYSCALE
  • Spectrum Range 2412 ~2484MHz
  • Antenna Onboard PCB antenna, gain 2dBi
  • Transmit Power 802.11b: 17±2 dBm (@11Mbps); 802.11g: 14±2 dBm (@54Mbps); 802.11n: 13±2 dBm (@MCS7)
  • Receiving Sensitivity CCK, 1 Mbps : -90dBm; CCK, 11 Mbps: -85dBm; 6 Mbps (1/2 BPSK): -88dBm; 54 Mbps (3/4 64-QAM): -70dBm; MCS7 (65 Mbps, 72.2 Mbps): -67dBm
  • Power Dissipation Turn off the flash lamp:180mA@5V; Turn on the  flash lamp and turn on the brightness to the maximum:310mA@5V; Deep-sleep: Minimum power consumption can be achieved 6mA@5V; Moderm-sleep: Minimum up to 20mA@5V; Light-sleep: Minimum up to 6.7mA@5V
  • Security WPA/WPA2/WPA2-Enterprise/WPS
  • Power Supply Range 5V
  • Operating Temperature -20 ℃ ~ 85 ℃
  • Storage Environment -40 ℃ ~ 90 ℃ , < 90%RH

In the package you will get 1 x ESP32-CAM Development Board, 1x camera Module-OV2640-FPC-24P-0.5mm-21mm- 2 Megapixel and 2x headers-2.54mm-1x8pin.

This product has been discontinued at Seeed Studio.  They highly recommend to try & choose Sipeed series products: Starts from $7.9,The 1st RISC-V 64 AI modules/boards for Edge computing, machine vision, speech recognition.

Make AI embeded to any IoT device possible! The new released Maixduino was designed in an Arduino Uno form factor, with a ESP32 module on board together with the MAIX AI module. The support of arduino compatible interface as well as Arduino IDE enable you update your arduino projects from IoT to AIoT easily without any additional cost! The maixduino kit provides an OV2640 camera module and a 2.4 inch TFT LCD for quick start machine vision projects, and onboard MEMS microphone for experiencing speech recognition promptly.

On-Board vs IPEX Antenna

ESP32-CAM Development Board with camera can be with the antenna jumper set for an external antenna or for the on-board antenna. You can see the two different settings below:

If you have a low frame rate or poor reception this might be the problem. You can either move the jumper with a bit of very careful soldering or buy an IPEX WiFi antenna which will improve the signal.

Applications:

  • We can easily build a simple camera with this board and save the photos in an SD card using the embedded SD card slot the board offers.
  • We can then modify this project to detect humans and save an image when one is detected.
  • We can recognize human faces and act accordingly.
  • We can build a surveillance camera with the ESP32 Cam board.
  • We can also stream video using this board.

You can find the ESP32-CAM schematic here, ESP32-CAM development board specification is here, camera specification is here.

Understanding the Home Assistant

You can read more about it here.

Understanding the Raspberry PI 3 model B

The Raspberry Pi 3 is the third-generation Raspberry Pi. It replaced the Raspberry Pi 2 Model B in February 2016.

Specification:

  • Quad Core 1.2GHz Broadcom BCM2837 64bit CPU
  • 1GB RAM
  • BCM43438 wireless LAN and Bluetooth Low Energy (BLE) on board
  • 40-pin extended GPIO
  • 4 USB 2 ports
  • 4 Pole stereo output and composite video port
  • Full size HDMI
  • CSI camera port for connecting a Raspberry Pi camera
  • DSI display port for connecting a Raspberry Pi touchscreen display
  • Micro SD port for loading your operating system and storing data
  • Upgraded switched Micro USB power source up to 2.5A

Signals and connections of the ESP32-CAM Development Board with camera

ESP32-CAM pinout:

GND - ground pin. Connected to Arduino board GND pin.

5V - external power supply pin 5VDC 2A

VCC - power supply pin. Connected to 5V pin.

3V3 - power supply pin. Connected to 3V3 pin.

U0TXD, U0RXD - Serial pins. You need these pins to upload code to your board.

GPIO 0 - pin which determines whether the ESP32 is in flashing mode or not. When GPIO 0 connected to GND, the ESP32 is in flashing mode.

The following pins are internally connected to the Micro SD card reader:

  • GPIO 14: CLK
  • GPIO 15: CMD
  • GPIO 2: Data 0
  • GPIO 4: Data 1 (also connected to the on-board LED)
  • GPIO 12: Data 2
  • GPIO 13: Data 3

Signals and connections of the Raspberry PI 3 model B


Wiring

Step by Step instruction

We recommend using a high-performance SD card for increased stability as well as plugging your device into an external display to see the default application booting up.

We assume that you have Windows 7 64 bit OS installed on your PC and empty micro SD card 32 GB with SD card adapter.

1. Do wiring

2. Adding ESP32 platform to Arduino IDE

The Arduino environment has to be set up to make it compatible with the ESP32 module. 

If you previously installed the hardware libraries for the ESP32 using the old method you need to delete them. Find the folder where your Arduino libraries are kept by opening File -> Preferences in the Arduino IDE. See the sketchbook location field. Click on Browsebutton. Inside Arduino folder open the hardware folder and find and delete either the esp32 folder or espressiffolder.

  1. Download and install the latest Arduino IDE version Windows Installer. You can download it here.
  2. Open Arduino IDE. 
  3. Open the Preferences window from the Arduino IDE. Go to File -> Preferences.
  4. Paste the following line into the Additional Boards Manager URLs field: https://dl.espressif.com/dl/package_esp32_index.json
  5. If you have entries in this field already then add the new line before them but separate them with a comma.
  6. Go to Tools -> Board -> Board Manager...

  7. Type ESP32, point with mouse cursor on record line found (ESP32 by ...) and click on Install button to install the new hardware libraries.

  8. When installation done, close and open your Arduino IDE again.
  9. You will be able to find all the ESP32 boards in the Arduino IDE’s board selector.

2. Uploading the sketch to the ESP32-CAM Development Board with camera using FTDI programmer

  1. Do wiring. Very important: GPIO 0 (IO 0) must be connected to GND otherwise you will not be able to upload code.
  2. Attach WiFi antenna (optional). It will help you to increase WiFi range.
  3. Attach OV2640 camera.
  4. Plug your FTDI programmer into your PC USB port.
  5. Open Arduino IDE.
  6. Open sketch, modify with your local network data (SSID, password).
  7. Make sure you select the right camera module. In this project we use the AI-THINKER ESP32-CAM Development Board with camera. 
  8. Go to Tools -> Board, select ESP32 Wrover Module.
  9. Go to Tools -> Port and select the COM port the ESP32-CAM Development Board connected to (we have COM10).
  10. Go to Tools -> Partition Scheme, select Huge APP (3MB No OTA).
  11. Press the ESP32-CAM Development Board on-board RST (RESET) button.
  12. Click the upload button in Arduino IDE to upload the sketch.
  13. When uploading completed disconnect GPIO 0 from GND.
  14. Open the Serial Monitor of Arduino IDE (Tools -> Serial Monitor) at the baud rate of 115200. Press the ESP32-CAM Development board on-board RST (RESET) button.
  15. The ESP32-CAM Development board IP address should be printed in the Serial Monitor (We have 192.168.1.103).
  16. You can access your camera streaming server on your local network. Open any internet browser (IE,Google Chrome,..) and type the ESP32-CAM Development board IP address (we have http://192.168.1.103). 

3. Installing Hass.io

It was explained in Raspberry basics: Project 29a Raspberry PI 3 model B board - Home assistant for beginners

4. Adding new card in Home assistant

  1. Go to Overview.
  2. Click on dots in top right corner. Select Configure UI.
  3. Click on plus in orange circle to ADD CARD.
  4. Click on PICTURE.
  5. Type your ESP32-CAM IP address in the Image URL field. We have http://192.168.1.103.
  6. In you click on TOGGLE EDITOR you will see what you need to add if you’re using the configuration file.
  7. Click on SAVE to return to the main dashboard. 
  8. If you want to EDIT the card click on EDIT. If you want to go back to normal mode click on X. Congrats! Home Assistant can display the ESP32-CAM video streaming now.

Code

Before uploading the code, you need to insert your local network credentials in the following variables:const char* ssid = "ssid";const char* password = "password";

Make sure you select the right camera module. In this project we use the AI-THINKER ESP32-CAM Development Board with camera. Comment all the other models and uncomment this one: #define CAMERA_MODEL_AI_THINKER

Summary

We have learnt how to use the Ai-Thinker ESP32-CAM Development Board as Camera Web Server in Home Assistant on Raspberry Pi.

Libraries in use

  • None

Resources

  • See on the begining of this project


Other projects of Acoptex.com
Medium Basics: Project 083w Sipeed Maixduino board - Using PlatformIO IDE of Acoptex.com in Sipeed Maixduino 08-08-2019
Medium Basics: Project 083e Sipeed Maixduino board - Uploading MaixPy of Acoptex.com in Sipeed Maixduino 04-08-2019
Medium Basics: Project 083f Sipeed Maixduino board - Using MycroPython of Acoptex.com in Sipeed Maixduino 04-08-2019

Published at 10-07-2019
Viewed: 16587 times