No Things found in this revision yet.
Browse this revision’s files →Hardware and firmware for our chicken door automation
Loading README and project media…
An automated door for our chicken coop, plus a Raspberry Pi that livestreams two cameras to the browser using WebRTC.

The main goal of this project is to automatically open the door in the morning (using a gear motor), and to close it at night.
In the controller, a combination of RTC and ambient light sensor is used:
OPENING_LUX_THRESHOLD is passed,
but not before EARLIEST_OPENING_TIME.LATEST_OPENING_TIME is reached, the door will open even if the
OPENING_LUX_THRESHOLD has not yet been reached.EARLIEST_CLOSING_TIME
is reached.EARLIEST_CLOSING_TIME, the door will close once the ambient light
falls below the specified CLOSING_LUX_THRESHOLD.CLOSING_LUX_THRESHOLD is not reached at LATEST_CLOSING_TIME, the
door will close anyways.To detect an open or closed door, reed switches are used.
The controller is connected via USB / serial to a Raspberry Pi. This Raspberry Pi is used for streaming two webcams to a website (an outdoor webcam and an indoor infrared night-sight webcam).
Additionally, the Raspberry Pi sends out Threema notifications whenever the
door status changes (or if an error occurs). For this, the observer-service
is used.
┌───────┐ ┌─────┐
│Initial├────────────────────┐ │Error│
└───────┘ │ └─────┘
│ │
▼ │
┌──────┐ ┌──────────┐ │
│Closed├────►│PreOpening│ │
└──────┘ └───────┬──┘ │
▲ │ │
│ ▼ │
┌──┴───────┐ ┌────┐ │
│PreClosing│◄──────┤Open│◄───┘
└──────────┘ └────┘
Initial: The state when turned on. The controller will transition to the
"Open" or "Closed" state depending on the sensor readings.Closed: Waiting for EARLIEST_OPENING_TIMEPreOpening: Waiting for either OPENING_LUX_THRESHOLD or LATEST_OPENING_TIMEOpen: Waiting for EARLIEST_CLOSING_TIMEPreClosing: Waiting for CLOSING_LUX_THRESHOLD or LATEST_CLOSING_TIMEError: Reachable from any state when something goes wrong (e.g. reading a sensor)If the firmware is in non-error state, the blue LED will toggle every second. If it's in error state, the LED will remain on.
To run unit tests:
cargo test --target x86_64-unknown-linux-gnu --tests
cd firmware
cargo flash --connect-under-reset --chip STM32F411CEUx --release
To open a serial connection:
python -m serial.tools.miniterm /dev/ttyACM0 9600
Then type ? to see the help.
In addition, the rpi-image directory contains a buildroot based Linux and all
configuration necessary to livestream two cameras (an USB webcam and a raspi
cam) to the web browser using WebRTC (backed by Janus as streaming server).
To build the Raspberry Pi image:
cd rpi-image
./build.sh