Skip to content

Commit

Permalink
repo re-org
Browse files Browse the repository at this point in the history
escomputers committed Apr 7, 2023
1 parent 89e4fd1 commit 70de3b5
Showing 8 changed files with 182 additions and 21 deletions.
132 changes: 131 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,131 @@
### Home Assistant as growbox controller, using several different devices and sensors, connected via ESPHOME
Home Assistant as growbox controller on a Raspberry Pi 4 2GB, using several different devices and sensors, connected via ESPHome (esp8266-12-e)


## Home Assistant setup

1. Install Home Assistant as container

```
docker compose up -d
```

If you need Docker run for Raspbian/Debian/Ubuntu distros:

```
sudo bash install-docker.sh
```

2. Run the steps for ESPHome installation, when completed run step 3

3. Install the ESPHome integration and in the "host" field, put your esp8266 ip address


## ESPHome installation

1. Install Python on your PC, you can install a specific version by running:

```
sudo bash install-python.sh 3.11.0
```

2. Install pip and venv

```
sudo apt-get install python3-pip python3-venv -y
```

3. Clone repository and activate virtual environment
```
mkdir -p env
python -m venv env/
```

4. Install ESPHome and other requirements

```
python -m pip -r requirements.txt
```

5. Connect esp8266 to your PC using USB cable (buy esp8266 with serial converter integrated)

6. Edit secrets.yaml to reflect your current wifi network

7. Move secrets.yaml and sht20.h (only if you use it, otherwise it's not required) to .esphome directory

```
mv secrets.yaml sht20.h .esphome
```

8. The first time you flash esp8266, you need to tell esphome some information about
your esp8266 device. Right after that, it will validate the configuration, create a binary, upload it, and start logs

```
cd .esphome && esphome wizard esphome-config.yaml
```

Next time you'll flash it, you just need to run:

```
esphome run esphome-config.yaml
```

9. Take note of the ip address printed out in the logs after you run previous command
Read all the output and check for sensors errors, if clear come back to Home Assistant installation steps


## Sensors

### Air

BME280 Temperature + Humidity + Pressure (i2c bus)
| SENSOR | ESP8266 |
| ----------- | ---------- |
| VIN | 3V3 |
| GND | GND |
| SCK | SCL |
| SDD | SDA |


### Soil

SHT20 Temperature + Humidity (i2c bus)
| SENSOR | ESP8266 |
| ----------- | ---------- |
| RED | 3V3 |
| BLACK | GND |
| GREEN | SDA |
| YELLOW | SCL |


### CO2

MH-Z19C NDIR (uart bus - 7pin terminal connection version)
| SENSOR | ESP8266 |
| ----------- | ---------- |
| PIN4 VIN | 5V |
| PIN3 GND | GND |
| PIN5 RX | TX |
| PIN6 TX | RX |

## DEVICES

Denkovi USB 8CH relay board
| DEVICE | RPI4 |
| ----------- | ---------- |
| USB | USB |

## POWER

| DEVICE | REQUIRED POWER SOURCES |
| ----------- | ---------- |
| Denkovi USB 8CH relay board | 12V 1A + 220V|
| Esp8266 | 5V 2A |
| Raspberry Pi 4 | 5V 2A|

## WIRINGS

TODO

## 3D CASES

TODO
12 changes: 12 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3'
services:
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
volumes:
- /opt/config
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
privileged: true
ports:
- '8123:8123'
20 changes: 0 additions & 20 deletions configuration.yaml

This file was deleted.

21 changes: 21 additions & 0 deletions install-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
sudo apt-get update

sudo apt-get install \
ca-certificates \
curl \
gnupg

sudo mkdir -m 0755 -p /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y


13 changes: 13 additions & 0 deletions install-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

version=$1

cd /tmp/
wget https://www.python.org/ftp/python/"$version"/Python-"$version".tgz
tar xzf Python-"$version".tgz
cd Python-"$version"

sudo ./configure --prefix=/usr/local/python/"$version"/ --enable-optimizations
sudo make -j "$(nproc)"
sudo make altinstall
sudo rm /tmp/Python-"$version".tgz
Binary file added jdk-8u361-linux-arm32-vfp-hflt.tar.gz
Binary file not shown.
5 changes: 5 additions & 0 deletions secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
wifi_ssid: "yourssid"
wifi_password: "yourpassword"

fallback_wifi_ssid: "your-fallback-ssid"
fallback_wifi_password: "your-fallback-password"
Binary file removed snapshots/b4194f64.tar
Binary file not shown.

0 comments on commit 70de3b5

Please sign in to comment.