M5Stack Unit Cam with ESPHome

Any chance anyone has made the M5Stack “Unit Cam” work with ESPHome?

Looks like M5 Unit Cam only uses high-speed UART communication to control camera settings or receive camera data. It uses normal OV2640, like many other cams. But most other ESP32 cams connect with lots of GPIO’s for communication. Basically Unit Cam is treated like a peripheral, not like a microcontroller.

M5Stack has some sample code to talk to the thing. So it’s obviously do-able with some sort of coding. But I haven’t seen anything (esp w ESPHome) that talks to a camera with UART. It does seem that UART communication with cam may be same as, or very similar to “SCCB” protocol - Serial Camera Control Bus.

Anyway, that would be a cool device to support. Very cheap camera (under $20), in a case, attached via Grove connector/cable. And it comes with two different cameras/optics: 60 degree and fish-eye. It’s actually got an ESP32 inside, but connects externally with high-speed UART.

But am guessing it’s too far outside the beaten path.

These should work reasonably well, I use a bunch of them as camera. I wouldn’t use them for 24/7 monitoring, but for the occasional peek, they are holding up. They do have a slight overheating problem, so it’s advised to put a small heatsink on the metal shield.

I use them as a standalone device. The ESP is on the unit itself, and the groove connector is used to supply power and/or connect different sensors. I haven’t connected them to any other ESP and read out the images over UART.

boards/m5stack_unitcam.yaml:

esp32:
  board: m5stack-timer-cam

esp32_camera:
  external_clock:
    pin: GPIO27
    frequency: 20MHz
  i2c_pins:
    sda: GPIO25
    scl: GPIO23
  data_pins: [GPIO32, GPIO35, GPIO34, GPIO5, GPIO39, GPIO18, GPIO36, GPIO19]
  vsync_pin: GPIO22
  href_pin: GPIO26
  pixel_clock_pin: GPIO21
  reset_pin: GPIO15

devices/unitcamera.yaml:

packages:
  status: !include ../common/status.yaml
  board: !include ../boards/m5stack_unitcam.yaml

esp32_camera:
  max_framerate: 2.0 fps
  idle_framerate: 0.05 fps
  resolution: 640x480
  name: "${device_verbose_name}"

esp32_camera_web_server:
  - port: 8080
    mode: stream

cameraone.yaml:

substitutions:
  static_ip: "x.x.x.x"
  device_name: "cameraone"
  device_verbose_name: "Camera One"

packages:
  wifi: !include includes/common/wifi.yaml
  device: !include includes/devices/unitcamera.yaml
1 Like

Oh wow, thanks very much. I had been thinking I had to use the thing as a peripheral (via UART), but yeah, just use the GPIO pins to flash ESPHome into the ESP32 that’s inside.

Thanks so much for that advice, & for the YAML code. Much appreciated!

1 Like

Hey, trying to setup M5stack diy unit cam. No succes so far.
In your yaml’s above, if I make one yaml it should start with : ?

esphome:
name: chicken-house
platform: ESP32
board: m5stack-timer-cam

Hi Wim, did you get this to work? I was thinking to use the M5stack set-up for a camera (next to my traditional doorbell). Thanks

Hi Kenneth, do you have your m5 camera always active or does it turn on for a set period when it needs to etc (eg when it or something else detects motion)? I’m thinking of setting mine up in HA via PoE but I’m worried even with the heat sink, it could overheat and crash/die

I don’t use them anymore (quality of ESP32-based cameras isn’t great), but I had them “on” for 24/7, but they only would be watched manually, so they didn’t stream any image data when I wasn’t looking.

1 Like