Skip to content

Commit

Permalink
Added PWM + updated documentation + removed useless files
Browse files Browse the repository at this point in the history
  • Loading branch information
escomputers committed Apr 28, 2024
1 parent 1f5c058 commit 3878392
Show file tree
Hide file tree
Showing 9 changed files with 335 additions and 107 deletions.
90 changes: 59 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Home Assistant as growbox controller, using several different devices and sensors, connected via D1 Mini/ESP8266-12-e

## Home Assistant setup

1. Install Home Assistant as container
Expand All @@ -16,10 +18,11 @@ sudo bash utils/install-docker.sh

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:
1. Install Python (Linux hosts only), you can install a specific version by running:

```
sudo bash utils/install-python.sh 3.11.0
Expand Down Expand Up @@ -68,77 +71,102 @@ esphome run esphome-configuration/esphome-config.yaml

9. Read all the output and check for sensors errors, if clear come back to Home Assistant installation steps

---

## HOME ASSISTANT CONFIGURATION

[homeassistant-configuration directory](homeassistant-configuration/configuration.yaml) contains configuration for controlling USB relay board, using [RESTful Binary Sensor](https://www.home-assistant.io/integrations/binary_sensor.rest).\
To get it working, an API service must be started within raspbian OS and it allows you to install Home Assistant into a different host.\
Link to the repo: [usbAPI](https://github.com/escomputers/usbAPI)

Here's the [example scripts.yaml file](homeassistant-configuration/scripts.yaml) containing the scripts used for controlling relay board via API


Here's the [example YAML](homeassistant-configuration/.storage/lovelace) for dashboard setup (cards and tiles)

---

## DEVICES

### Main controller
[D1 Mini](https://www.az-delivery.de/en/products/d1-mini) - [pinout](https://m.media-amazon.com/images/I/71b9yM7dFlL.jpg)
[USB to serial converter](https://www.az-delivery.de/en/products/usb-auf-seriell-adapter-mit-ch340)

### Relay Board
[Denkovi USB 8 Channel](https://denkovi.com/usb-eight-channel-relay-board-for-automation) - [wiring](https://github.com/escomputers/hassio-growbox/blob/325ab9b5c127c14f19560fe0ca1c8efceda2f83e/wirings/12V-USB-8CH-relay-board-wiring.pdf)

| DEVICE | RPI4 |
| ----------- | ---------- |
| USB-B | USB |

### PWM Controller
[Universal AC MAINS Dimmer - MPDMv4.1](https://www.tindie.com/products/next_evo1/universal-ac-mains-dimmer-mpdmv41/)\
used for controlling 5 fans (4 oscillating + 1 inline)
| PWM board | ESP8266 |
| ----------- | ---------- |
| VCC | 3V3 |
| GND | GND |
| VCNT | GPIO15/D8 |


## Sensors
[D1-MINI/ESP8266 sensors wiring](https://github.com/escomputers/hassio-growbox/blob/325ab9b5c127c14f19560fe0ca1c8efceda2f83e/wirings/d1mini-esp8266-sensors-wiring.pdf)

### Air

BME280 Temperature + Humidity + Pressure (i2c bus)
[BME280](https://www.adafruit.com/product/2652) Temperature + Humidity + Pressure (i2c bus)
| SENSOR | ESP8266 |
| ----------- | ---------- |
| VIN | 3V3 |
| GND | GND |
| SCK | SCL |
| SDD | SDA |
| SCK | SCL/GPIO5/D1 |
| SDO | SDA/GPIO4/D2 |


### Soil

SHT20 Temperature + Humidity (i2c bus)
[SHT20](https://www.makerfabs.com/soil-temperature-and-humidity-sensor-sht20.html) Temperature + Humidity (i2c bus)
| SENSOR | ESP8266 |
| ----------- | ---------- |
| RED | 3V3 |
| BLACK | GND |
| GREEN | SDA |
| YELLOW | SCL |
| GREEN | SDA/GPIO4/D2 |
| YELLOW | SCL/GPIO5/D1 |


### CO2

MH-Z19C NDIR (uart bus - 7pin terminal connection version)
[MH-Z19C NDIR](https://www.winsen-sensor.com/product/mh-z19c.html) (UART bus - 7pin terminal connection version)
| SENSOR | ESP8266 |
| ----------- | ---------- |
| PIN4 VIN | 5V |
| PIN3 GND | GND |
| PIN5 RX | TX |
| PIN6 TX | RX |
| PIN5 RX | TX/GPIO1/D10 |
| PIN6 TX | RX/GPIO3/D9 |

## DEVICES

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

## HOME ASSISTANT CONFIGURATION

Home Assistant `homeassistant-configuration/configuration.yaml` contains configuration for controlling USB relay board,
using [RESTful Binary Sensor](https://www.home-assistant.io/integrations/binary_sensor.rest).
To get it working, an API service must be started within raspbian OS.
Here's the repo: [usbAPI](https://github.com/escomputers/usbAPI)
In this case, the relay board is controlled by a jar file but it can be adapted to any other board by editing the commands to run.

While `homeassistant-configuration/scripts.yaml` contains entities for controlling previously created API relays.
---

## POWER

| DEVICE | REQUIRED POWER SOURCES |
| ----------- | ---------- |
| Denkovi USB 8CH relay board | 12V 1A + 220V|
| Esp8266 | 5V 2A |
| Esp8266 | 5V/3.3V 1A |
| Raspberry Pi 4 | 5V 2A|
| Raspberry Pi 4 Fan | 9V 1A|
| Power sockets | 220V 16A (1,5mm<sup>2</sup> cables)|

## WIRINGS
[USB 8CH relay board](https://github.com/escomputers/hassio-growbox/blob/325ab9b5c127c14f19560fe0ca1c8efceda2f83e/wirings/12V-USB-8CH-relay-board-wiring.pdf)

[D1-MINI/ESP8266 sensors](https://github.com/escomputers/hassio-growbox/blob/325ab9b5c127c14f19560fe0ca1c8efceda2f83e/wirings/d1mini-esp8266-sensors-wiring.pdf)
---

## 3D CASES

Take a look at 3D directory, references:
Take a look at [3D directory](3D/)\
References:
- Raspberry Pi 4 case (40mm fan) by John_Sinclair on [Thingiverse](https://www.thingiverse.com/thing:3723481)
- 12V USB 8 Channel relay board by polysquare on [Thingverse](https://www.thingiverse.com/thing:2306082)
- BME280 case by leptitnicolas on [Thingverse](https://www.thingiverse.com/thing:3809818)
- Arduino nano + 2 channel arduino relay + voltage stepdown box by flying_ginger on [Thingverse](https://www.thingiverse.com/thing:3162083). Used for housing ESP8266 (by making a drawer/slot manually since screw holes aren't available on the board), MH-Z19, cables and as attach surface for placing BME280 externally.

---

47 changes: 23 additions & 24 deletions esphome-configuration/esphome-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ wifi:
ssid: !secret fallback_wifi_ssid
password: !secret fallback_wifi_password

# i2c:
# sda: GPIO4
# scl: GPIO5
# scan: true
i2c:
sda: GPIO4
scl: GPIO5
scan: true

uart:
rx_pin: GPIO3
Expand All @@ -58,26 +58,25 @@ sensor:
name: "MH-Z19 Temperature"
update_interval: 60s
automatic_baseline_calibration: false
# - platform: dht
# pin: GPIO4
# model: AM2302
# temperature:
# name: "Air temperature"
# humidity:
# name: "Air humidity"
# accuracy_decimals: 2
# update_interval: 60s
# update_interval: 60s
# - platform: bme280
# temperature:
# name: "Air Temperature"
# oversampling: 16x
# pressure:
# name: "Air Pressure"
# humidity:
# name: "Air Humidity"
# address: 0x77
# update_interval: 60s
- platform: dht
pin: GPIO4
model: AM2302
temperature:
name: "Air temperature"
humidity:
name: "Air humidity"
accuracy_decimals: 2
update_interval: 60s
- platform: bme280
temperature:
name: "Air Temperature"
oversampling: 16x
pressure:
name: "Air Pressure"
humidity:
name: "Air Humidity"
address: 0x77
update_interval: 60s
- platform: custom
lambda: |-
auto sht20 = new SHT20();
Expand Down
Loading

0 comments on commit 3878392

Please sign in to comment.