Rescue Private Cactus. Ficus Integration in Home Assistant
A ficus named Cactus lives in the house. Why he, being a ficus, has his own name Cactus is a long story and has nothing to do with this story. The fact is that the tree is well-deserved, with history.
In general, he lived, did not grieve, but it happened that we had to leave for a long time. There is no one to water the ficus, it is somehow embarrassing to carry a two-meter tree with you, and the hand did not rise to doom it to certain death.
Having quickly run through the market of automatic watering systems, I realized that none of them, by and large, suits me. It was scary to connect to the water supply – if something happened, it would flood the whole house. How much they pour is not clear. How often to adjust watering – it would be good to measure soil moisture, etc.
Then my eyes fell on a 19 liter bottle of drinking water standing idle. I decided to construct a sprinkler from what was at hand
“Under the arms”, in addition to the aforementioned bottle, were:
Electric pump from him – 300 rubles
Wemos D1 mini board – $2
The smallest car button found in the house
YL-38 Soil Moisture Sensor
Terminal blocks 2.54
Colored wires 0.35
Optional: BME260 sensor
The top white cover of the pump is fixed with two screws and one latch. Having removed it, we see a board, a battery and a water pump. On a 4.6V battery. Empirically, it turned out that this is more than enough for Vemos.
The control board is attached to the pump. There are also pump feed sites. To turn on the pump, one of the platforms must be shorted to ground.
A real circuit engineer would make his own board. Since “I’m not a real welder”®, I plugged in the ESP8266 and the first relay I could find.
Surprisingly, Wemos with soldered terminal blocks stood up like a native between the pump and the battery. There was a place for the relay at the bottom. Power is taken from the battery. Additionally, a switching board was soldered from the scraps of the breadboard. Just five terminal blocks 3.3v and Gnd in order to reduce the amount of “snot”.
A button for forced reset is connected to the En terminal, and a soil moisture sensor is connected to A0. On GPIO 4 and 5 I2C BMP280 temperature sensor. I just missed the temperature sensor in this room.
The soil moisture sensor consists of two parts: the sensor itself, which in turn consists of two electrodes, and a board for converting the sensor signal into an analog voltage. Since the sensor signal is, in fact, a current loop, I did not consider it reprehensible to cut off the native wiring and make the connection between the board and the sensor with a one and a half meter cable with a cross section of 0.5. I tied the board to the pump – next to Wemos.
Two holes were drilled in the back of the native cover – 8 mm for the button and 4 mm for the wire of the soil moisture sensor. After installing the cover in place, all this disgrace is not visible. Only a neat thin wire comes out from behind and goes into the pot to the sensor. Leroy Merlin bought a meter length of plastic hose for irrigation with an inner diameter of 8mm. I put the hose at one end on the iron spout of the pump, and fixed the other end in the pot.
Stitched Esphome. What is it and how to work with it – there are a lot of articles. For me personally, the most understandable articles are from Paul Pshennikov and Ivan Bessarabov.
Three sensors, one binary sensor and a pump switch have appeared in the Home Assistant in the Esphome iteration. Humidity is measured in volts. :). 1 volt means that everything is damp, like in a rainforest. I’m going to write a script for converting to human units, but I just can’t. Once a week I drop in to see how things are at home and, if necessary, water the well-deserved tree.
esphome: platform: ESP8266 board: d1_mini # Модель ESP, в данном случае WEMOS D1 mini name: "132-pompa-fikus-kaktus" # имя name_add_mac_suffix: false # автоматизация выключения помпы при загрузке на всякий случай on_boot: - priority: 600 # При загрузке then: - switch.turn_off: pompa - priority: 200 # При включении Wifi контрольный then: - switch.turn_off: pompa wifi: ssid: !secret wifi_ssid password: !secret wifi_password manual_ip: # Закрепленный IP используется, в том числе, как ID устройства в таблицах static_ip: 192.168.1.132 gateway: 192.168.1.1 subnet: 255.255.255.0 logger: api: password: "12345" web_server: port: 80 ota: password: "12345" on_progress: then: - logger.log: format: "OTA progress %0.1f%%" args: ["x"] # Инициализация I2C шины i2c: sda: D2 # GPIO 5 scl: D1 # GPIO 4 scan: True id: bus_a # Универсальный сенсор BMP280 на I2c sensor: - platform: bmp280 temperature: name: "132 Temperature" oversampling: 16x pressure: name: "132 Pressure" address: 0x76 update_interval: 20s # Аналоговый сенсор влажности почвы - platform: adc pin: A0 name: "132 Terra Humidity" update_interval: 60s id: terrahumidity # Цифровой сенсор влажности да\нет пороговое значение настроивается на плате. Пусть будет binary_sensor: - platform: gpio name: "132_Humidity_D" pin: number: D6 # GPIO 12 mode: input: true # pullup: true inverted: false id: ficusgrowhumiditydigit # switch: - platform: gpio name: "132_pompa" icon: "mdi:sprinkler" pin: number: D5 # GPIO 14 id: pompa inverted: True # При подаче 0 реле включается, поэтому инверт restore_mode: ALWAYS_OFF # При перезагрузке всегда выключен on_turn_on: - logger.log: "Поливалка включилась" - delay: 30s # Ради безопасности при случайном включении - switch.turn_off: pompa on_turn_off: - logger.log: "Поливалка выключилась"