Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dbrgn/chicken-coop
Hardware and firmware for our chicken door automation
https://github.com/dbrgn/chicken-coop
chicken chicken-coop chicken-coop-automation chicken-coop-door embedded-rust librepcb rust
Last synced: 17 days ago
JSON representation
Hardware and firmware for our chicken door automation
- Host: GitHub
- URL: https://github.com/dbrgn/chicken-coop
- Owner: dbrgn
- Created: 2021-04-29T21:20:15.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-07T20:10:20.000Z (2 months ago)
- Last Synced: 2024-10-18T21:24:37.745Z (26 days ago)
- Topics: chicken, chicken-coop, chicken-coop-automation, chicken-coop-door, embedded-rust, librepcb, rust
- Language: JavaScript
- Homepage:
- Size: 3.27 MB
- Stars: 7
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Chicken Door / Chicken Cam
An automated door for our chicken coop, plus a Raspberry Pi that livestreams
two cameras to the browser using WebRTC.## Block diagram
![Block diagram](chicken-coop.png)
## How it works
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:
- In the morning, the door will open if the `OPENING_LUX_THRESHOLD` is passed,
but not before `EARLIEST_OPENING_TIME`.
- If `LATEST_OPENING_TIME` is reached, the door will open even if the
`OPENING_LUX_THRESHOLD` has not yet been reached.
- Once the door is open, it will not close again before `EARLIEST_CLOSING_TIME`
is reached.
- After `EARLIEST_CLOSING_TIME`, the door will close once the ambient light
falls below the specified `CLOSING_LUX_THRESHOLD`.
- If the `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.### Firmware: State machine
┌───────┐ ┌─────┐
│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_TIME`
- `PreOpening`: Waiting for either `OPENING_LUX_THRESHOLD` or `LATEST_OPENING_TIME`
- `Open`: Waiting for `EARLIEST_CLOSING_TIME`
- `PreClosing`: Waiting for `CLOSING_LUX_THRESHOLD` or `LATEST_CLOSING_TIME`
- `Error`: 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.## Firmware: Testing
To run unit tests:
cargo test --target x86_64-unknown-linux-gnu --tests
## Firmware: Flashing
cd firmware
cargo flash --connect-under-reset --chip STM32F411CEUx --release## Firmware: Serial Terminal
To open a serial connection:
python -m serial.tools.miniterm /dev/ttyACM0 9600
Then type `?` to see the help.
## Chicken Cam
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