diff --git a/README.md b/README.md index bfdad1d..33fd7cb 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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,5mm2 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. + +--- + diff --git a/esphome-configuration/esphome-config.yaml b/esphome-configuration/esphome-config.yaml index 5d100fd..235ef2b 100644 --- a/esphome-configuration/esphome-config.yaml +++ b/esphome-configuration/esphome-config.yaml @@ -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 @@ -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(); diff --git a/homeassistant-configuration/.storage/lovelace b/homeassistant-configuration/.storage/lovelace new file mode 100644 index 0000000..8c44e42 --- /dev/null +++ b/homeassistant-configuration/.storage/lovelace @@ -0,0 +1,252 @@ +{ + "version": 1, + "minor_version": 1, + "key": "lovelace", + "data": { + "config": { + "title": "Growbox", + "views": [ + { + "title": "HOME", + "path": "home", + "icon": "mdi:pine-tree", + "badges": [], + "cards": [ + { + "entity": "sensor.air_temperature", + "type": "sensor", + "graph": "line", + "detail": 2 + }, + { + "entity": "sensor.soil_temperature", + "type": "sensor", + "graph": "line", + "detail": 2 + }, + { + "entity": "sensor.air_humidity", + "type": "sensor", + "graph": "line", + "detail": 2 + }, + { + "entity": "sensor.co2", + "type": "sensor", + "graph": "line", + "detail": 2 + }, + { + "entity": "sensor.soil_humidity", + "type": "sensor", + "graph": "line", + "detail": 2 + }, + { + "type": "entities", + "entities": [ + "sensor.air_pressure", + "sensor.soil_dew_point", + "sensor.soil_vapour_pressure_deficit" + ] + }, + { + "show_current": true, + "show_forecast": true, + "type": "weather-forecast", + "entity": "weather.forecast_growbox", + "forecast_type": "legacy" + }, + { + "type": "tile", + "entity": "fan.inline_fan_2", + "features": [ + { + "type": "fan-speed" + } + ] + }, + { + "type": "entities", + "entities": [ + { + "entity": "binary_sensor.usbrelay1", + "secondary_info": "last-updated" + }, + { + "entity": "binary_sensor.usbrelay2", + "secondary_info": "last-updated" + }, + { + "entity": "binary_sensor.usbrelay3", + "secondary_info": "last-updated" + }, + { + "entity": "binary_sensor.usbrelay4", + "secondary_info": "last-updated" + }, + { + "entity": "binary_sensor.usbrelay5", + "secondary_info": "last-updated" + }, + { + "entity": "binary_sensor.usbrelay6", + "secondary_info": "last-updated" + }, + { + "entity": "binary_sensor.usbrelay7", + "secondary_info": "last-updated" + }, + { + "entity": "binary_sensor.usbrelay8", + "secondary_info": "last-updated" + } + ], + "title": "Devices status", + "state_color": true + }, + { + "type": "entities", + "entities": [ + { + "entity": "script.usbrelay1_control" + }, + { + "entity": "script.usbrelay2_control" + }, + { + "entity": "script.usbrelay3_control" + }, + { + "entity": "script.usbrelay4_control" + }, + { + "entity": "script.usbrelay5_control" + }, + { + "entity": "script.usbrelay6_control" + }, + { + "entity": "script.usbrelay7_control" + }, + { + "entity": "script.usbrelay8_control" + } + ], + "title": "Devices control", + "state_color": true + } + ] + }, + { + "path": "default_view", + "title": "CAM", + "icon": "mdi:webcam", + "badges": [], + "cards": [ + { + "type": "picture-entity", + "entity": "camera.growbox_sub" + }, + { + "type": "entities", + "entities": [ + "switch.growbox_auto_focus", + "switch.growbox_email_on_event", + "switch.growbox_ftp_upload", + "switch.growbox_push_notifications", + "switch.growbox_record", + "switch.growbox_record_audio", + "switch.growbox_siren_on_event" + ], + "title": "Interruttore" + }, + { + "type": "entities", + "entities": [ + "light.growbox_infra_red_lights_in_night_mode", + "light.growbox_status_led" + ], + "title": "Luce" + }, + { + "type": "entities", + "entities": [ + "number.growbox_focus", + "number.growbox_motion_sensitivity", + "number.growbox_zoom" + ], + "title": "Numero" + }, + { + "type": "entities", + "entities": [ + "button.growbox_ptz_down", + "button.growbox_ptz_left", + "button.growbox_ptz_right", + "button.growbox_ptz_stop", + "button.growbox_ptz_up" + ], + "title": "Pulsante" + }, + { + "type": "entities", + "entities": [ + "select.growbox_day_night_mode" + ], + "title": "Seleziona" + }, + { + "type": "entities", + "entities": [ + "binary_sensor.growbox_motion" + ], + "title": "Sensore binario" + }, + { + "type": "entities", + "entities": [ + "siren.growbox_siren" + ], + "title": "Sirena" + } + ] + }, + { + "title": "System Info", + "path": "system-info", + "icon": "mdi:information", + "badges": [], + "cards": [ + { + "type": "entities", + "entities": [ + { + "entity": "sensor.memory_use" + }, + { + "entity": "sensor.memory_use_percent" + }, + { + "entity": "sensor.memory_free" + }, + { + "entity": "sensor.load_5m" + }, + { + "entity": "sensor.load_15m" + }, + { + "entity": "sensor.last_boot" + }, + { + "entity": "sensor.processor_use" + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/homeassistant-configuration/backups/39d8ff26.tar b/homeassistant-configuration/backups/39d8ff26.tar deleted file mode 100644 index f77d08d..0000000 Binary files a/homeassistant-configuration/backups/39d8ff26.tar and /dev/null differ diff --git a/homeassistant-configuration/backups/c2f241d8.tar b/homeassistant-configuration/backups/c2f241d8.tar deleted file mode 100644 index ecad089..0000000 Binary files a/homeassistant-configuration/backups/c2f241d8.tar and /dev/null differ diff --git a/homeassistant-configuration/configuration.yaml b/homeassistant-configuration/configuration.yaml index 6c73181..6d66a61 100644 --- a/homeassistant-configuration/configuration.yaml +++ b/homeassistant-configuration/configuration.yaml @@ -118,40 +118,4 @@ rest_command: method: POST usbrelay8_off: url: "http://192.168.0.137:8000/8/off" - method: POST - -sensor: - - platform: systemmonitor - resources: - - type: disk_use_percent - arg: /config - - type: disk_use - - type: disk_free - - type: memory_use_percent - - type: memory_use - - type: memory_free - - type: swap_use_percent - - type: swap_use - - type: swap_free - - type: load_1m - - type: load_5m - - type: load_15m - - type: network_in - arg: eth0 - - type: network_out - arg: eth0 - - type: throughput_network_in - arg: eth0 - - type: throughput_network_out - arg: eth0 - - type: packets_in - arg: eth0 - - type: packets_out - arg: eth0 - - type: ipv4_address - arg: eth0 - - type: ipv6_address - arg: eth0 - - type: processor_use - - type: processor_temperature - - type: last_boot \ No newline at end of file + method: POST \ No newline at end of file diff --git a/tools/jdk-8u361-linux-arm32-vfp-hflt.tar.gz b/tools/jdk-8u361-linux-arm32-vfp-hflt.tar.gz deleted file mode 100644 index 08401b7..0000000 Binary files a/tools/jdk-8u361-linux-arm32-vfp-hflt.tar.gz and /dev/null differ diff --git a/utils/install-python-ubuntu.sh b/utils/install-python-ubuntu.sh deleted file mode 100644 index 2cf7708..0000000 --- a/utils/install-python-ubuntu.sh +++ /dev/null @@ -1,15 +0,0 @@ -# Add Docker's official GPG key: -sudo apt-get update -sudo apt-get install ca-certificates curl gnupg -y -sudo install -m 0755 -d /etc/apt/keyrings -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg -sudo chmod a+r /etc/apt/keyrings/docker.gpg - -# Add the repository to Apt sources: -echo \ - "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ - "$(. /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 \ No newline at end of file diff --git a/utils/install-python-debian.sh b/utils/install-python.sh similarity index 100% rename from utils/install-python-debian.sh rename to utils/install-python.sh