Files
sbc-sprinkler-controller/README.md
T

122 lines
4.7 KiB
Markdown

# README
## Description
I am documenting how I created my own Single Board Computer (SBC) sprinkler controller to be used for my home.
This setup will outline each step I took to make this setup work using Home Assistant, Docker, MQTT, Portainer.
## Product I bought
- Power Supply for SBC: [https://www.amazon.com/dp/B0190MCSS0?ref=ppx_yo2ov_dt_b_fed_asin_title](https://www.amazon.com/dp/B0190MCSS0?ref=ppx_yo2ov_dt_b_fed_asin_title)
- Heatsink: [https://www.amazon.com/dp/B0792VXBVH?ref=ppx_yo2ov_dt_b_fed_asin_title](https://www.amazon.com/dp/B0792VXBVH?ref=ppx_yo2ov_dt_b_fed_asin_title)
- SBC: [https://www.amazon.com/dp/B078RT6H8X?ref=ppx_yo2ov_dt_b_fed_asin_title](https://www.amazon.com/dp/B078RT6H8X?ref=ppx_yo2ov_dt_b_fed_asin_title)
- SD Card: [https://www.amazon.com/dp/B076TBYNKS?ref=ppx_yo2ov_dt_b_fed_asin_title](https://www.amazon.com/dp/B076TBYNKS?ref=ppx_yo2ov_dt_b_fed_asin_title)
- Terminal Block: [https://www.amazon.com/dp/B07CLR3MLK?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1](https://www.amazon.com/dp/B07CLR3MLK?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1)
- Power Supply Transformer: [https://www.amazon.com/dp/B0797LCBYS?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1](https://www.amazon.com/dp/B0797LCBYS?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1)
- Wifi dongle: [https://www.amazon.com/dp/B00GFAN498?ref=ppx_yo2ov_dt_b_fed_asin_title](https://www.amazon.com/dp/B00GFAN498?ref=ppx_yo2ov_dt_b_fed_asin_title)
- Voltage Regulator: [https://www.amazon.com/dp/B07TMMTX4K?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1](https://www.amazon.com/dp/B07TMMTX4K?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1)
- Jumper Wire: [https://www.amazon.com/dp/B09FPGT7JT?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1](https://www.amazon.com/dp/B09FPGT7JT?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1)
- 8 Channel Relay: [https://www.amazon.com/dp/B07XM5GVWJ?ref=ppx_yo2ov_dt_b_fed_asin_title](https://www.amazon.com/dp/B07XM5GVWJ?ref=ppx_yo2ov_dt_b_fed_asin_title)
- Brass Hex Spacers: [https://www.amazon.com/dp/B0BZYTC581?ref=ppx_yo2ov_dt_b_fed_asin_title](https://www.amazon.com/dp/B0BZYTC581?ref=ppx_yo2ov_dt_b_fed_asin_title)
- Junction Box: [https://www.amazon.com/dp/B07KXSJ4J2?ref=ppx_yo2ov_dt_b_fed_asin_title](https://www.amazon.com/dp/B07KXSJ4J2?ref=ppx_yo2ov_dt_b_fed_asin_title)
- DC Power Adapters: [https://www.amazon.com/dp/B01ER6QWAY?ref=ppx_yo2ov_dt_b_fed_asin_title](https://www.amazon.com/dp/B01ER6QWAY?ref=ppx_yo2ov_dt_b_fed_asin_title)
## Software Used
- Ubuntu Jammy
- Docker
- Portainer
- Home Assistant
- MQTT
## Setup
### Installation
Ubuntu: https://releases.ubuntu.com/jammy/
Once setup is done and you have created your user account and password, install either libgpiod or lgpio, I did libgpiod found below:
```
sudo apt update
sudo apt install gpiod
sudo apt update
sudo apt install libgpiod-dev
sudo apt install python3-libgpiod
sudo apt install python3-dev
pip install gpiod
````
Then verify from the below:
```
gpiodetect
```
Docker: https://docs.docker.com/engine/install/ubuntu/
Portainer: https://docs.portainer.io/start/install-ce/server/docker/linux
### After install prep
Use Portainer to download and start Home Assistant from docker hub here: https://hub.docker.com/r/homeassistant/home-assistant
Also use Portainer to download and start MQTT Broker from docker hub here: https://hub.docker.com/_/eclipse-mosquitto
### Setting up MQTT Config file
You will want to create a config yaml file that you will be volume mounting into the container via portainer.
Mine looks something like this:
```
mqtt:
host: localhost
user: [your user]
password: [your password]
topic_prefix: /home/irrigation
ha_discovery:
enabled: yes
# GPIO
gpio_modules:
# Use the libgpio built-in GPIO
- name: gpio
module: gpiod
chip: /dev/gpiochip2
digital_outputs:
# Find the pins you would like to use from a schamtic of your board so you can map pins here
- name: Zone 1
module: gpio
pin: 23
on_payload: "1"
off_payload: "0"
- name: Zone 2
module: gpio
pin: 16
on_payload: "1"
off_payload: "0"
- name: Zone 3
module: gpio
pin: 18
on_payload: "1"
off_payload: "0"
- name: Zone 4
module: gpio
pin: 15
on_payload: "1"
off_payload: "0"
```
### Home Assistant Setup
After creating your account and logging in.
Configure MQTT by the below:
- Click on the hamburger button
- Click Devices and Services
- Add Integration
- Select MQTT
- Configure with your settings
### Hardware connection
- Assemble the heatsink to the SBC
- Assemble the SBC to the Junction Box peg board
- Assemble Channel Bay near by
- Add Jumper Cables from GPIO pin to Channel Bay
- Add Male to Male Jumper from Channel Bay to Terminal Block
- Add wire from Terminal Block to Power Supply Adapter Transformer
## How everything runs
Explain how the project or application operates.