Documentation

Camera

MudPi supports cameras for taking photos and short recordings to monitor your garden remotely.

Overview

The camera component allows you to capture images and record video from connected cameras. Captures are saved to a configurable path with customizable naming and delay settings.

Configuration

Camera components are defined in the cameras array of your configuration. Each camera requires a key and an interface:

mudpi.config.json
{
  "cameras": [
    {
      "key": "garden_cam",
      "interface": "picamera",
      "path": "/home/pi/mudpi/media/",
      "delay": 3,
      "name": "Garden Camera"
    }
  ]
}

The delay sets the number of seconds to wait before capturing (useful for letting the camera adjust exposure). The path determines where captured files are saved. File names are generated automatically using timestamps.

Interfaces

MudPi supports the following camera interfaces:

Interface Description
picamera Raspberry Pi Camera Module (CSI ribbon cable)
rtsp RTSP network camera stream

Actions

Camera components support the following actions:

Action Description
capture Take a photo and save it to the configured path
record Record a short video clip

Events

When a capture is taken, a CameraUpdated event is fired with the following data:

CameraUpdated Event
{
  "event": "CameraUpdated",
  "component_id": "garden_cam",
  "timestamp": "2024-03-15T10:30:00Z",
  "data": {
    "type": "capture",
    "path": "/home/pi/mudpi/media/garden_cam_20240315_103000.jpg"
  }
}

State

The camera's state reflects the last capture taken, including the file path and timestamp. You can read the current state via Redis or the API.

Tip

Combine camera captures with triggers to take photos automatically when sensor thresholds are met, such as snapping a photo when motion is detected.