Home Assistant as growbox controller, using several different devices and sensors, connected via D1 Mini/ESP8266-12-e
- Install Home Assistant as container (for Core installation check the "core" branch out)
docker compose up -d
If you need Docker run for RaspiOS/Debian:
sudo bash utils/install-docker.sh
-
Run the steps for ESPHome installation, when completed run step 3
-
Install the ESPHome integration and in the "host" field, put your esp8266 ip address
homeassistant-configuration directory contains configuration for controlling USB relay board, using RESTful Binary Sensor.
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
If you don't want to use a USB relay board, you could use a WIFI relay board like this and thus you can skip all the steps related to USB-API relay board management.
Here's the example scripts.yaml file containing the scripts used for controlling relay board via API
Here's the example YAML for dashboard setup (cards and tiles)
- Install Python (script works on Linux hosts only), you can install a specific version by running:
sudo bash utils/install-python.sh 3.11.0
- Create Python virtual environment and install Esphome package
sudo apt-get install python3-pip python3-venv -y
mkdir -p env
python -m venv env/
python -m pip -r requirements.txt
-
Connect esp8266 to your PC using USB cable (buy esp8266 with serial converter integrated)
-
Edit esphome-configuration/secrets.yaml to reflect your current wifi network
-
Move esphome-configuration/secrets.yaml and esphome-configuration/sht20.h (only if you use it, otherwise it's not required) to .esphome directory
mv esphome-configuration/secrets.yaml esphome-configuration/sht20.h .esphome
- The first time you connect to esp8266 (via usb to serial cable), 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 need to configure it, just connect to the same esp8266 network and launch commands over the air:
esphome run esphome-configuration/esphome-config.yaml
- Read all the output and check for sensors errors, if clear come back to Home Assistant installation steps
D1 Mini - pinout
USB to serial converter
Denkovi USB 8 Channel - wiring
DEVICE | RPI4 |
---|---|
USB-B | USB |
Universal AC MAINS Dimmer - MPDMv4.1
used for controlling 5 fans (4 oscillating + 1 inline)
PWM board | ESP8266 |
---|---|
VCC | 3V3 |
GND | GND |
VCNT | GPIO15/D8 |
D1-MINI/ESP8266 sensors wiring
BME280 Temperature + Humidity + Pressure (i2c bus)
SENSOR | ESP8266 |
---|---|
VIN | 3V3 |
GND | GND |
SCK | SCL/GPIO5/D1 |
SDO | SDA/GPIO4/D2 |
SHT20 Temperature + Humidity (i2c bus)
SENSOR | ESP8266 |
---|---|
RED | 3V3 |
BLACK | GND |
GREEN | SDA/GPIO4/D2 |
YELLOW | SCL/GPIO5/D1 |
MH-Z19C NDIR (UART bus - 7pin terminal connection version)
SENSOR | ESP8266 |
---|---|
PIN4 VIN | 5V |
PIN3 GND | GND |
PIN5 RX | TX/GPIO1/D10 |
PIN6 TX | RX/GPIO3/D9 |
DEVICE | REQUIRED POWER SOURCES |
---|---|
Denkovi USB 8CH relay board | 12V 1A + 220V |
Esp8266 | 5V/3.3V 1A |
Raspberry Pi 4 | 5V 2A |
Raspberry Pi 4 Fan | 9V 1A |
Power sockets | 220V 16A (1,5mm2 cables) |
Take a look at 3D directory
References:
- Raspberry Pi 4 case (40mm fan) by John_Sinclair on Thingiverse
- 12V USB 8 Channel relay board by polysquare on Thingverse
- BME280 case by leptitnicolas on Thingverse
- Arduino nano + 2 channel arduino relay + voltage stepdown box by flying_ginger on Thingverse. 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.