Smart skrzynka na listy z ESP32-CAM i PoE, czyli jak wyslopować IoT do swojego domu

UWAGA NA SLOP

Nic mądrego tu nie odkryjesz, udostępniam swój proces żeby pokazać jak w <2h klikania zrobiłem “smart skrzynkę na listy PoE” za <150zł (plus warsztat), nie wysilając umysłu.

Use case

Od kiedy wprowadzono eDoręczenia, listy na swój adres dostaję bardzo sporadycznie i już raz udało mi się nie odebrać poleconego. W ramach uzbrojenia działki puściłem peszel do otworu w skrzynce na listy w slupie.

Wybrany sprzęt

Podczas zakupów najtańszym wariantem ESP32 z PoE i wejściem kamery było:

Zamówione bezpośrednio u Prokybera na Allegro(!) za 100zł/szt z dostawą. Od tego momentu chyba już zwinął interes.

Do tego kamera 120 stopni z AliExpress, w marcu 2026 za całe 30zł z dostawą:

I membrana PTFE do regulacji ciśnienia (w stylu Amazon.pl - obecna cena jest beznadziejna).

Do tego kawałek akrylu gr. 5mm, frezarka CNC, obudowa wydrukowana z ASA, sznur EPDM 5mm, śrubki i skrzynka na listy:

Slop

Mając absolutnie zero czasu na bawienie się w modelowanie 3D, uznałem że zrobię całość przy użyciu Opusa 5.5 i MCP. Jako że płytka jest publicznie udokumentowana, jako pierwszy prompt pobrałem footprint, model 3D i opisałem w plan mode podstawowe założenia, każąc zacząć od configu ESPHome.

# Kamera w skrzynce na listy – obudowa zaprojektowana z Claude Code i Fusion 360
Kamera pod sufitem metalowej skrzynki na listy. Okresowo zapala diody, robi zdjęcie, model ML ocenia, czy w skrzynce jest poczta.
Model 3D obudowy powstał w Fusion 360. Projektował go Claude Code, sterując Fusionem przez MCP.

## Sprzęt
- Płytka: Prokyber AI-On-The-Edge-Cam v2.1.0 (ESP32-S3, PoE, microSD, kamera OV2640 na taśmie FPC 60 mm, 4 diody LED).
- Zasilanie i sieć: PoE, jeden kabel.
- Firmware: ESPHome.

## Proces
1. Specyfikacja dla agenta modelującego (`CASE-HANDOFF.md`): wymiary płytki, DXF z obrysem, STL producenta, schematy, wymagania.
2. Generator w Pythonie (`build_case.py`) uruchamiany w Fusionie przez MCP:

  • wymiary jako parametry użytkownika w dokumencie,
  • generowanie brył (tacka, front, uchwyt kamery, okucia),
  • sprawdzanie kolizji,
  • zrzuty ekranu i przekroje,
  • eksport STEP, 3MF oraz DXF do frezowania frontu.
    3. Iteracje: przegląd przekrojów, zmiana parametrów lub logiki skryptu, przebudowa modelu.

## Konstrukcja
- Wymiary: front 165,5 × 61,2 mm, wysokość 31,5 mm.
- Montaż na suficie skrzynki, frontem w dół. 6 magnesów Gridfinity Ø6×2 mm wklejonych na epoksyd w dno tacki.
- Tacka: druk 3D, PETG lub ASA.
- Front: akryl 5 mm frezowany na Carvera C1 (frezy 1/8″ i 2 mm). Kształt bez ostrych narożników wewnętrznych.
- Uszczelnienie: sznur EPDM porowaty Ø5 mm w rowku 6,2 × 3,6 mm wokół krawędzi tacki, ściśnięcie ok. 28%, ograniczone twardymi oparciami.
- Mocowanie frontu: 6 × M3×10 we wtapiane inserty Voron, w uszach na poszerzonym kołnierzu. Wszystkie śruby poza obszarem uszczelnionym, bez podkładek uszczelniających.
- Wejście kabla: dławnica LAPP SKINTOP ST-M 16×1,5 wkręcana w gwint nacięty gwintownikiem w ścianie 8,6 mm (otwór drukowany Ø14,5), bez nakrętki. Gniazdo RJ45 w komorze wewnątrz obudowy.
- Odpowietrzenie: membrana PTFE (MykoNex 20 mm) nad otworem Ø3 we froncie, przy komorze RJ45.
- Kamera: 56–67 mm od diod LED, odbicia w akrylu pod kątem ok. 73–75°, poza polem widzenia. Ścianka osłaniająca przy trzech diodach statusowych. Pierścień z pianki między obiektywem a frontem.
- Taśma FPC: styki jednostronne, taśma zginana bez skręcania. Jedno zagięcie pod siedziskiem kamery, powrót nad płytką, wejście do złącza pionowo z góry. Wykorzystane 59 z 60 mm.
- Uchwyt kamery: druk, przykręcony do trzech otworów płytki (2 × M3×10, 1 × M3×14 przez ramię nad blokiem PoE). Optyka kamery nierozbieralna, moduł leży w siedzisku uchwytu.

## Lista części
- tacka (druk, PETG/ASA)
- uchwyt kamery + 3 tulejki dystansowe (druk)
- front: akryl 5 mm, frezowany z DXF
- sznur EPDM porowaty Ø5 mm, ok. 376 mm, łączony na styk klejem CA z primerem
- 6 × M3×10 (front), 2 × M3×10 + 1 × M3×14 (uchwyt), inserty Voron M3
- 6 × magnes Ø6×2 mm (Gridfinity)
- LAPP SKINTOP ST-M 16×1,5
- membrana PTFE MykoNex 20 mm

Rezultat:
Fusion360_tDKn1SBAIc

Jedynie wyklikałem ręcznie wycinanie frontu 7x bore / 1x contour with tabs w Fusionie. Frez 2mm na Carvera C1.

Konfiguracja ESPHome

---
# Prokyber AI-On-The-Edge-Cam v2.1.0 (ESP32-S3-WROOM-1 N16R8 + W5500 PoE + OV2640/OV5640 + SD + battery)
# Shop:      https://e-shop.prokyber.com/product/ai-on-the-edge-cam-esp32-s3-with-poe-sd-camera/
# Schematic: https://github.com/prokyber/ai-on-the-edge-cam-hw-description (Schematic_ai-on-the-edge-cam_2025-08-27.pdf)
# Refs:      https://github.com/adafruit/circuitpython/tree/main/ports/espressif/boards/prokyber_ai_on_the_edge_cam
#            https://github.com/nliaudat/meter-reader/blob/main/esphome/AI-On-The-Edge-Cam_Esp32-S3.yaml
#
# Hardware summary
#   Module         ESP32-S3-WROOM-1 N16R8: 16 MB flash, 8 MB octal PSRAM
#   USB            USB-C wired straight to the native ESP32-S3 USB port (GPIO19/20), enumerates as 303A:1001.
#                  UART0 (GPIO43 TXD0 / GPIO44 RXD0) is only on header H1.
#   Power gating   GPIO46 PER_EN  -> +3.3V_PER rail: camera regulators, camera I2C pull-ups, SD card,
#                                    WS2812 strip power, battery divider. 10k pull-down, so OFF after reset.
#                  GPIO45 ETH_EN  -> +3.3V_ETH rail: W5500. 10k pull-down, so OFF after reset.
#                  Both must be driven HIGH before the I2C bus, camera and Ethernet are set up.
#   Ethernet       W5500 on SPI: SCLK GPIO21 / MOSI GPIO1 / MISO GPIO14 / CS GPIO39 / INT GPIO38, no reset line
#   Camera (DVP)   XCLK GPIO15, PCLK GPIO13, VSYNC GPIO6, HREF GPIO7, SIOD GPIO4, SIOC GPIO5
#                  D0..D7 (Y2..Y9) = GPIO11 9 8 10 47 18 17 16;  RESET pulled up by R13, PWDN not wired
#   Stemma QT      shares the camera I2C bus (GPIO4 SDA / GPIO5 SCL), powered from +3.3V_PER
#   SD card        SPI: CS GPIO3 / MOSI GPIO42 / MISO GPIO41 / SCLK GPIO40 (needs an external component, not used here)
#   LEDs           4x WS2812B camera backlight on GPIO12 (level shifted), white status LED on GPIO48
#   Battery        TP4057 charger; VBAT_MEASURE on GPIO2 through a 10k/10k divider, only live while PER_EN is high
#   Button         GPIO0 (BOOT)
#   Reserved       GPIO33-37 (octal PSRAM), do not use
#
# Notes
#   - ESP-IDF framework and octal PSRAM @ 80 MHz are required for the camera.
#   - Ethernet is the primary link (PoE). ESPHome allows only one of wifi/ethernet;
#     see the commented wifi block at the bottom to switch. If you use Wi-Fi you can
#     leave the Ethernet rail off to save power.

substitutions:
  name: "aiote-cam"
  friendly_name: "AI On The Edge Cam"

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  on_boot:
    # Runs right after the two power switches below (priority 1100) and before the
    # I2C bus (1000). Gives the regulators, the W5500 and the camera time to come up.
    priority: 1050
    then:
      - lambda: delay(250);

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  flash_size: 16MB
  framework:
    type: esp-idf

psram:
  mode: octal
  speed: 80MHz

logger:
  level: DEBUG
  hardware_uart: USB_SERIAL_JTAG   # USB-C is the native ESP32-S3 USB port
  logs:
    esp-idf: NONE

api:
  encryption:
    key: !secret api_key_aiote_cam
  reboot_timeout: 6h

ota:
  - platform: esphome

web_server:
  port: 80

ethernet:
  type: W5500
  clk_pin: GPIO21
  mosi_pin: GPIO1
  miso_pin: GPIO14
  cs_pin: GPIO39
  interrupt_pin: GPIO38
  clock_speed: 25MHz

time:
  - platform: homeassistant
    id: ha_time

# ---------------------------------------------------------------------------
# Power rails. Set up before everything else (setup_priority 1100) so the
# peripherals are powered when their components initialise.
# ---------------------------------------------------------------------------
switch:
  - platform: gpio
    name: "Peripheral Power"
    id: periph_power
    pin:
      number: GPIO46
      ignore_strapping_warning: true
    restore_mode: ALWAYS_ON
    setup_priority: 1100
    entity_category: config
    icon: mdi:camera

  - platform: gpio
    name: "Ethernet Power"
    id: eth_power
    pin:
      number: GPIO45
      ignore_strapping_warning: true
    restore_mode: ALWAYS_ON
    setup_priority: 1100
    entity_category: config
    icon: mdi:ethernet

# ---------------------------------------------------------------------------
# Camera
# ---------------------------------------------------------------------------
i2c:
  - id: cam_i2c          # camera SCCB bus, also exposed on the Stemma QT connector
    sda: GPIO4
    scl: GPIO5
    frequency: 100kHz
    scan: false

esp32_camera:
  name: "Camera"
  id: cam
  i2c_id: cam_i2c
  external_clock:
    pin: GPIO15
    frequency: 20MHz
  data_pins: [GPIO11, GPIO9, GPIO8, GPIO10, GPIO47, GPIO18, GPIO17, GPIO16]
  vsync_pin: GPIO6
  href_pin: GPIO7
  pixel_clock_pin: GPIO13
  resolution: 800x600     # OV5640 can go higher, e.g. 1280x1024 or 1600x1200
  jpeg_quality: 12
  max_framerate: 10fps
  idle_framerate: 0.1fps
  frame_buffer_count: 2
  brightness: 0
  aec_mode: AUTO
  aec2: true
  ae_level: 0
  agc_mode: AUTO
  agc_gain_ceiling: 2x
  wb_mode: AUTO
  # vertical_flip: true
  # horizontal_mirror: true

# MJPEG stream (:8080/stream) and snapshot (:8081/snapshot) over plain HTTP
esp32_camera_web_server:
  - port: 8080
    mode: stream
  - port: 8081
    mode: snapshot

# ---------------------------------------------------------------------------
# Onboard peripherals
# ---------------------------------------------------------------------------
light:
  - platform: esp32_rmt_led_strip
    name: "Camera Backlight"
    id: backlight
    pin: GPIO12
    chipset: WS2812
    channel_colors: GRB
    num_leds: 4
    restore_mode: ALWAYS_OFF

  - platform: status_led
    name: "Status LED"
    id: white_led
    pin: GPIO48
    entity_category: config

binary_sensor:
  - platform: gpio
    name: "Boot Button"
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: true
      ignore_strapping_warning: true
    entity_category: diagnostic

  - platform: status
    name: "Status"
    entity_category: diagnostic

button:
  - platform: restart
    name: "Restart"
    entity_category: diagnostic

sensor:
  - platform: adc
    name: "Battery Voltage"
    pin: GPIO2
    attenuation: 12db
    update_interval: 60s
    accuracy_decimals: 2
    device_class: voltage
    entity_category: diagnostic
    filters:
      - multiply: 2.0      # 10k / 10k divider

  - platform: uptime
    name: "Uptime"
    entity_category: diagnostic

  - platform: internal_temperature
    name: "Chip Temperature"
    entity_category: diagnostic
    update_interval: 60s

  - platform: template
    name: "Free PSRAM"
    unit_of_measurement: "KB"
    icon: mdi:memory
    entity_category: diagnostic
    lambda: return heap_caps_get_free_size(MALLOC_CAP_SPIRAM) / 1024.0f;
    update_interval: 60s

text_sensor:
  - platform: ethernet_info
    ip_address:
      name: "IP Address"
    mac_address:
      name: "MAC Address"

  - platform: version
    name: "ESPHome Version"
    hide_timestamp: true

# ---------------------------------------------------------------------------
# Wi-Fi alternative: comment out `ethernet:` + ethernet_info above and
# uncomment this block.
# ---------------------------------------------------------------------------
# wifi:
#   ssid: !secret wifi_ssid
#   password: !secret wifi_password
#   ap:
#     ssid: "${friendly_name} Fallback"
# captive_portal:

Konfiguracja HomeAssistant

Płacę za subskrypcję Claude, więc zadecydowałem żeby sprawdzać zawartość skrzynki przy użyciu Haiku 5.5. Po optymalizacji koszt <$1/mo.

chrome_nRX9pCHQuC

Build a “mail in the mailbox” detector in my Home Assistant config (YAML, as a package).

My setup

  • Camera: <camera.mailbox_camera> (ESPHome ESP32 camera inside a closed mailbox)
  • LED inside the mailbox: <light.mailbox_led>
  • AI Task entity (Settings → Devices & services → Anthropic → add “AI Task”, model claude-haiku-5-5): <ai_task.claude_ai_task>
  • Phone notify service: <notify.mobile_app_my_phone> (Android companion app)
  • Dashboard uses Bubble Card (v3); view path: <bubble>
  • HA runs in Docker; /media is the default local media dir (check media_dirs, adjust paths if different)

Requirements

  1. Put everything in one package file mailbox.yaml (add it under homeassistant: packages:).
  2. script.mailbox_light_on: turn the LED on, white and 100%. Pick the color data from supported_color_modes (white / rgb / color_temp / brightness / onoff) so the call never fails on an unsupported mode.
  3. script.mailbox_check (mode single, field force bool):
  • Remember whether the LED was already on → turn it on → wait until its state is on → wait 2 s.
  • Take 4 throwaway camera.snapshots 1 s apart (/media/mailbox/warmup.jpg), then the real photo /media/mailbox/last.jpg.
    IMPORTANT: when idle, the ESP32 camera barely captures frames, so its auto-exposure can’t adjust in time. Without warm-up shots the photo is black in the dark and the AI says “empty”.
  • Compare locally against /media/mailbox/reference.jpg with a small Python script /config/shell/mailbox_diff.py (Pillow + numpy are already in the HA container), run through shell_command with
    response_variable. Method: grayscale → resize to 80×60 → Gaussian blur 1 → normalize each image (subtract mean, divide by std) → changed_pct = % of pixels with |diff| > 0.5. Print JSON. A missing
    reference counts as 100 %.
  • Fire event mailbox_diff {changed_pct, ai_check}.
  • Call the AI only if force, or changed_pct ≥ 2, or the last AI check was more than 12 h ago (or never happened).
  • AI call: ai_task.generate_data (continue_on_error) with the attachment media-source://media_source/local/mailbox/last.jpg (image/jpeg). Instructions: “inside of a closed mailbox lit by an LED;
    is there any mail (letters, envelopes, flyers, newspapers, parcels)?”. Structured output: has_mail (boolean), description (short text).
  • On a valid result: copy last.jpg → reference.jpg, then fire event mailbox_check_result {has_mail, description}.
  • Turn the LED off unless it was on before or the camera pop-up is open.
  1. Trigger-based template entities (they keep their state across restarts):
  • binary_sensor.mailbox_has_mail, from mailbox_check_result. Attributes: description, last_checked. Icon: mdi:mailbox-up / mdi:mailbox.
  • sensor.mailbox_image_difference (%), from mailbox_diff, for tuning the threshold.
  1. input_boolean.mailbox_viewing, plus scripts mailbox_view_open (boolean on + LED on) and mailbox_view_close (boolean off, wait for a running check to finish, then LED off). Opening or closing the
    pop-up must NOT call the AI.
  2. Automations:
  • every 15 min (time_pattern /15), skip if the camera is unavailable → script.mailbox_check
  • LED on for 3 min while not viewing → turn it off (safety)
  • viewing on for 10 min → mailbox_view_close
  • on HA start → viewing off, LED off
  • has_mail off→on → phone notification: title “You’ve got mail”, message = description, data: tag: mailbox, channel: Mailbox, priority: high, ttl: 0 (otherwise Android delays it while the phone
    is idle), image: /media/local/mailbox/last.jpg?t=<timestamp>, clickAction: /lovelace/<bubble>#mailbox
  • has_mail on→off → message: clear_notification, same tag
  1. Bubble Card YAML for me to paste:
  • Button on binary_sensor.mailbox_has_mail that navigates to #mailbox. Use a styles JS snippet to set .bubble-name to “Mailbox empty” when off, the AI description when on, “not checked yet” when
    unknown.
  • Pop-up #mailbox with open_action → script.mailbox_view_open and close_action → script.mailbox_view_close. Contents: picture-entity for the camera with camera_view: live, a markdown card
    with the description and last check time, and a “Check now” button → script.mailbox_check with force: true.

Notes

  • New shell_command entries need a full HA restart; reloading scripts isn’t enough.
  • Validate with python -m homeassistant --script check_config -c /config.

The parts they’ll most likely need to adjust:

  • the /media path, if their HA install isn’t in Docker;
  • the 2% threshold, which depends on how noisy their camera is (watch sensor.mailbox_image_difference for a day);
  • the notification options, which are written for the Android app; iPhone uses different ones.

Dodatkowo trzeba pamiętać żeby skonfigurować MAC address allowlist dla danego portu oraz odizolować urządzenie w sieci, tak jak dla każdego innego urządzenia PoE, które może być zdemontowane przez włamywacza. Hint: Opus też potrafi w Mikrotika :eyes: