In-fridge capture hardware for PantryPilot.
Detects door-close via a reed switch, captures a JPEG, and POSTs it to POST /images on the backend. The rest of the system is hardware-agnostic.
| Folder | Hardware | Language | Toolchain |
|---|---|---|---|
esp32_cam/ |
ESP32-CAM + reed switch | C++ | PlatformIO |
raspberry_pi/ |
Raspberry Pi + Pi Camera + reed switch | Python | uv |
phone_fallback/ |
Any spare smartphone | — | manual / app |
Use whichever fits your setup. The ESP32-CAM is the primary target (cheapest, battery-friendly). The RPi is the fallback for faster iteration. The phone fallback requires no hardware wiring.
The only interface between this repo and the backend:
POST {BACKEND_BASE_URL}/images
Content-Type: multipart/form-data
Body: file=<JPEG bytes>
Response: { "job_id": "<uuid>" }
Set BACKEND_BASE_URL in your .env (see below).
Requirements: PlatformIO CLI or PlatformIO IDE extension for VSCode.
cd esp32_cam
pio run # build
pio run --target upload # flash to board
pio device monitor # serial outputWire the reed switch to GPIO 12 (configurable in src/main.cpp). Mount the board inside the fridge door with a small LED strip for even lighting.
Bill of materials: ESP32-CAM ($10), magnetic reed switch ($3), USB battery pack ($15), small LED strip ($8), mounting bracket.
Requirements: Python 3.11+, uv, Pi Camera module.
cd raspberry_pi
cp .env.example .env # set BACKEND_BASE_URL
uv sync
uv run python -m src.captureThe script blocks and listens for GPIO door events. Connect the reed switch to GPIO 17 (configurable in src/door_sensor.py).
Open the camera app, photograph the fridge shelves, and upload through the PantryPilot web app (/upload). No hardware required.
cp .env.example .env| Variable | Description |
|---|---|
BACKEND_BASE_URL |
e.g. http://192.168.1.x:8000 or the deployed backend URL |
CAPTURE_INTERVAL_S |
Minimum seconds between captures (RPi, default 2) |