After using Raspberry Pis and Home Assistant for some time, I started thinking that I should explore smaller cheaper microcontrollers for connecting sensors etc. Years back I programmed in machine code and assembler, but these days prefer not to fiddle at that level of detail “reinventing the wheel”. I have avoided Arduino so far, and then discovered ESPhome.
I purchased a ESP32-CAM thinking it would be a good learning exercise, but got side-tracked until fairly recently.
ESP32-CAM now connects to Wi-Fi, but I am not getting any result from it.
I copied and pasted the Ai-Thinker Camera Example configuration entry (and have since checked against other tutorials). I have since pasted additional code which does work to turn the ESP32-CAM’s LED on and off, so it is definitely communicating correctly.
#
# This is the ESP32-CAM board (DFRobot0602) with an AI Thinker ESP32-S module built-in.
#
substitutions:
# Modify variables based on your settings
hostname: "esp32-cam"
devicename: esp32-cam
esphome:
name: $devicename
esp32:
board: esp32cam
framework:
type: arduino
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: none
# Optional manual IP (quicker to reconnect - don't wait for router to issue DHCP address)
manual_ip:
static_ip: 192.168.1.163
gateway: 192.168.1.1
subnet: 255.255.255.0
dns1: 192.168.1.1
fast_connect: true
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "$devicename Fallback Hotspot"
password: "RiYYkI0mWCkc"
# Enable Home Assistant API
api:
password: ""
ota:
password: ""
# Enable logging
logger:
captive_portal:
# Ai-Thinker Camera - Example configuration entry
#
esp32_camera:
name: $devicename
external_clock:
pin: GPIO0
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
pixel_clock_pin: GPIO22
power_down_pin: GPIO32
vertical_flip: false
horizontal_mirror: false
# resolution: 400x296
# max_framerate: 12 fps
#
# Flashlight
output:
- platform: gpio
pin: GPIO4
id: gpio_4
light:
- platform: binary
output: gpio_4
name: $devicename light
id: camera_flash
I am powering the ESP32-CAM from a USB FTDI board connected to a PC USB3 port. A USB chargerDoctor reports 4.8V and about 0.17A. Also tried a phone charger which reports 5.02V 0.17A
I am able to update OTA from the Home Assistant ESPHome add-on:
INFO Reading configuration /config/esphome/esp32-cam.yaml...
WARNING GPIO0 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Generating C++ source...
INFO Compiling app...
Processing esp32-cam (board: esp32cam; framework: arduino; platform: platformio/espressif32 @ 3.5.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- <AsyncTCP-esphome> 1.2.2
|-- <WiFi> 1.0
|-- <FS> 1.0
|-- <Update> 1.0
|-- <ESPAsyncWebServer-esphome> 2.1.0
| |-- <AsyncTCP-esphome> 1.2.2
|-- <DNSServer> 1.1.0
|-- <ESPmDNS> 1.0
Compiling /data/esp32-cam/.pioenvs/esp32-cam/src/main.cpp.o
Linking /data/esp32-cam/.pioenvs/esp32-cam/firmware.elf
RAM: [= ] 14.2% (used 46592 bytes from 327680 bytes)
Flash: [====== ] 58.3% (used 1070242 bytes from 1835008 bytes)
Building /data/esp32-cam/.pioenvs/esp32-cam/firmware.bin
esp32_create_combined_bin(["/data/esp32-cam/.pioenvs/esp32-cam/firmware.bin"], ["/data/esp32-cam/.pioenvs/esp32-cam/firmware.elf"])
Wrote 0x115510 bytes to file /data/esp32-cam/.pioenvs/esp32-cam/firmware-factory.bin, ready to flash to offset 0x0
========================= [SUCCESS] Took 39.55 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.1.163
INFO Uploading /data/esp32-cam/.pioenvs/esp32-cam/firmware.bin (1070352 bytes)
Uploading: [============================================================] 100% Done...
INFO Waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.1.163 using esphome API
INFO Successfully connected to 192.168.1.163
[12:14:03][I][app:102]: ESPHome version 2022.5.1 compiled on Jun 5 2022, 12:13:01
[12:14:03][C][wifi:491]: WiFi:
[12:14:03][C][wifi:353]: Local MAC: A4:E5:7C:D5:4A:14
[12:14:03][C][wifi:354]: SSID: [redacted]
[12:14:03][C][wifi:355]: IP Address: 192.168.1.163
[12:14:03][C][wifi:357]: BSSID: [redacted]
[12:14:03][C][wifi:358]: Hostname: 'esp32-cam'
[12:14:03][C][wifi:360]: Signal strength: -34 dB ▂▄▆█
[12:14:03][C][wifi:364]: Channel: 1
[12:14:03][C][wifi:365]: Subnet: 255.255.255.0
[12:14:03][C][wifi:366]: Gateway: 192.168.1.1
[12:14:03][C][wifi:367]: DNS1: 192.168.1.1
[12:14:03][C][wifi:368]: DNS2: 0.0.0.0
[12:14:04][C][logger:274]: Logger:
[12:14:04][C][logger:275]: Level: DEBUG
[12:14:04][C][logger:276]: Log Baud Rate: 115200
[12:14:04][C][logger:277]: Hardware UART: UART0
[12:14:04][C][gpio.output:010]: GPIO Binary Output:
[12:14:04][C][gpio.output:011]: Pin: GPIO4
[12:14:04][C][light:104]: Light 'esp32-cam light'
[12:14:04][C][esp32_camera:048]: ESP32 Camera:
[12:14:04][C][esp32_camera:049]: Name: esp32-cam
[12:14:04][C][esp32_camera:050]: Internal: NO
[12:14:04][C][esp32_camera:052]: Data Pins: D0:5 D1:18 D2:19 D3:21 D4:36 D5:39 D6:34 D7:35
[12:14:04][C][esp32_camera:053]: VSYNC Pin: 25
[12:14:04][C][esp32_camera:054]: HREF Pin: 23
[12:14:04][C][esp32_camera:055]: Pixel Clock Pin: 22
[12:14:04][C][esp32_camera:056]: External Clock: Pin:0 Frequency:20000000
[12:14:04][C][esp32_camera:057]: I2C Pins: SDA:26 SCL:27
[12:14:04][C][esp32_camera:058]: Reset Pin: -1
[12:14:04][C][esp32_camera:076]: Resolution: 640x480 (VGA)
[12:14:04][C][esp32_camera:101]: JPEG Quality: 10
[12:14:04][C][esp32_camera:103]: Contrast: 0
[12:14:04][C][esp32_camera:104]: Brightness: 0
[12:14:04][C][esp32_camera:105]: Saturation: 0
[12:14:04][C][esp32_camera:106]: Vertical Flip: OFF
[12:14:04][C][esp32_camera:107]: Horizontal Mirror: OFF
[12:14:04][C][esp32_camera:108]: Special Effect: 0
[12:14:04][C][esp32_camera:109]: White Balance Mode: 0
[12:14:04][C][esp32_camera:112]: Auto Exposure Control: 1
[12:14:04][C][esp32_camera:113]: Auto Exposure Control 2: 0
[12:14:04][C][esp32_camera:114]: Auto Exposure Level: 0
[12:14:04][C][esp32_camera:115]: Auto Exposure Value: 300
[12:14:04][C][esp32_camera:116]: AGC: 1
[12:14:04][C][esp32_camera:117]: AGC Gain: 0
[12:14:04][C][esp32_camera:118]: Gain Ceiling: 0
[12:14:04][C][esp32_camera:124]: Test Pattern: NO
[12:14:04][C][psram:020]: PSRAM:
[12:14:04][C][psram:021]: Available: YES
[12:14:04][C][captive_portal:088]: Captive Portal:
[12:14:04][C][mdns:084]: mDNS:
[12:14:04][C][mdns:085]: Hostname: esp32-cam
[12:14:04][C][ota:085]: Over-The-Air Updates:
[12:14:04][C][ota:086]: Address: 192.168.1.163:3232
[12:14:04][C][api:138]: API Server:
[12:14:04][C][api:139]: Address: 192.168.1.163:6053
[12:14:04][C][api:143]: Using noise encryption: NO
[12:14:05][W][esp32_camera:162]: Got invalid frame from camera!
[12:14:09][W][esp32_camera:162]: Got invalid frame from camera!
[12:14:13][W][esp32_camera:162]: Got invalid frame from camera!
[12:14:17][W][esp32_camera:162]: Got invalid frame from camera!
[12:14:21][W][esp32_camera:162]: Got invalid frame from camera!
In HA Settings > Integrations, under ESPHome I have esp32-cam, which looks like
As mentioned, the light switch does turn the ESP32-CAM’s LED on and off; but only “idle” or “unavailable” from the camera.
Other references I have found on google suggest that the camera hardware may be faulty - but wondering if there is anything else i can try before attempting to return the camera I bought back in October.
I appreciate all suggestions.