"Finálna verzia" radšej v uvodzovkách nakoľko predpokladám, že až ta tretia "finálna verzia" bude posledná
(už sme na druhej! //// a už sme na tretej
)
HW Verzia 2 s radiačným štítom pre teplomer
Meranie záhrady
Čo dokáže:
- Meranie teploty, vlhkosti, tlaku vzduchu
- Meranie teploty a vlhkosti pôdy
- Meranie napätia na superkondezátoroch, solarnom panely a mcu
- Meranie jasu
Čo potrebujeme:
Moduly:
- Solárny panel 5V (najlepšie by bol 5.5V)
- Superkondenzátory 2x22uF 2.7V
- Esp8266 12F
- BH1750
- Dallas temperature sensor
- Capacitive Soil Moisture Sensor V2.0
- AHT22
- BMP280
Súčiastky:
Dioda 1N5817 2x
Tranzistor PNP 2N3906 2x
Rezistor 220k 2x
Rezistor 220
Rezistor 100k 2x
Rezistor 470k 2x
Rezistor 470
Rezistor 10k 4x
Rezistor 4k7 3x (je možné nahradiť 10k)
Rezistor 1M 2x ( je možné nahradiť aj vyššim)
Rezistor 1k 2x
Rezistor 2k
Led 3mm červená
Logic power mofset NPN FQP30N60L >0.5A (je možné nahradiť iným podobným logic mofsetom)
Logic power mofset NPN 2N7000 >0.2A 2x ( je možné nahradiť aj transiztorom)
PNP transistor 2N2907
Kondenzátor foĺiový 470uF 2x (alebo vyššim)
Trim 103
supervizor LMS33460
timer LM555CN (alebo original použiť z kapacitného senzoru)
keramický kondezátor 20uF (alebo podobný)
keramický kondezátor 0.33uF (alebo podobný)
keramický kondezátor 10nF 2x (alebo podobný)
keramický kondezátor 100nF (alebo podobný)
Poistku PPCT 0.5A (nie je potrebná ak sa nebojíte zapájania)
Tlačidlo smd 4pinové
PCB sot23 pre supevizor
PCB pre ldo
PCB adapter pre esp8266
headery pre ldo, supervizor, esp, supercap, solarny panel, dallas, moisture senzor, am2301, temt6000
Vodotesnú krabicu s prehľadným vekom + stojan do pôdy
PCB 5x7 2.54mm
Kábliky, dupont konektory
Všetky súčiastky sú neni potrebné ak niektoré veci nechcete merať + sa daju upravovať podľa potreby
Prevedenie:
V príspevku vyššie
Schéma:
Schéma je priamo na pcb ak by chcel lepšie niekto schému viem dať PDFko alebo priamo dwg
Kód:
Kód: Vybrat vše
#-------------------------------------------
# BUG AND REPAIR AND PLANNED
#-------------------------------------------
#-------------------------------------------
# REVISION
#-------------------------------------------
# 2023.05.1.1.0
# - replace AMS2301 by BME280
# - replace TEMT600 by BH1750
# - disconnect ADS1115
# - measure only supercap voltage on ADC pin
#-------------------------------------------
# SUBTITUTIONS - basic definitions and description of the device
#-------------------------------------------
substitutions:
device_name: plant-garden
friendly_name: Plant-Garden
created_by: StudioTiiM 2023
device_description: "Soil sensor measure weather and soil powered supercap and solar"
#-------------------------------------------
# POWER CONSUMPTION - whit multimeter
# not yet measured.
# partial consumption below
#-------------------------------------------
# Power consumption 3.3V
# First booting MCU:
# Booting MCU after connected to mqtt:
# Measure sensors:
# Normal: > 68 mA ~ 12s
# Deep sleep: >19µA 3600s
#-------------------------------------------
# DEFINE PINS AND VARIABILES
# CIRCUIT AND MODULES - basic definitions and description of the device
#-------------------------------------------
# ----- MCU -----
# Module: Ai-Thinker ESP8266-12F
# Circuit: Solder on adapter esp8266
# Power Consumption: Peak ~ 330mA / Normal wifi: 120 ~ 170mA / Normal: ~ 70mA / DeepSleep: ~ 20μA
# Specification: Chip Family: ESP8266 / Chip Model: ESP8266EX / Chip ID: 00BC7BB7 / MAC Address: A4:E5:7C:BC:7B:B7 / Number of Cores: 1 / CPU Frequency: 80MHz / Ram: 80kB / Flash: 1Mb
# Description pins:
# PINS ESP8266 | FUNCTION | INPUT | OUTPUT | ADC | PWM | I2C(only one) | SPI | RESISTOR | BOOT | FLASH | HIGH AT BOOT | BOOT FAILS |
# -------------------------------------------------------------------------------------------------------------------------------------------------------------
# EN | | 10.0k PULLUP adapter | |
# RST | | 12.0k PULLUP internal| |
# ADC0 A0 | ANALOG ADC0 | | | OK | | | | | | | |
# GPIO0 D3 | STRAPPING | OK! | OK! | | OK | OK | | 10.0k PULLUP | PULLUP | pulldown | HIGH 110ms*6 | LOW
# GPIO01 TX | TX | OK!*1 | OK | | OK | OK | | | | | HIGH | LOW
# GPIO02 D4 | ON BOARD LED | OK | OK | | OK | OK | | 10.0k PULLUP | PULLUP | | HIGH 70ms*6 | LOW
# GPIO03 RX | RX | OK | OK!* | | OK | OK | | | | | HIGH |
# GPIO04 D2 | SDA | OK | OK | | OK | OK*2 | | | | | |
# GPIO05 D1 | SCL | OK | OK | | OK | OK*2 | | | | | |
# GPIO06 | INTERNAL SPI | | | | | | CLK | | | | |
# GPIO07 | INTERNAL SPI | | | | | | MISO | | | | |
# GPIO08 | INTERNAL SPI | | | | | | MOSI | | | | |
# GPIO09 | INTERNAL SPI | | | | | | HD | | | | HIGH |
# GPIO10 | INTERNAL SPI | | | | | | WP | | | | HIGH |
# GPIO11 | SPI CSC/CMD | | | | | | CS | | | | |
# GPIO12 D6 | | OK | OK | | OK | OK | MISO | | | | HIGH 110ms |
# GPIO13 D7 | | OK | OK | | OK | OK | MOSI | | | | HIGH 110ms |
# GPIO14 D5 | | OK | OK | | OK | OK | SCLK | | | | HIGH 110ms |
# GPIO15 D8 | STRAPPING | OK! | OK! | | OK | OK | CS | 10k PULLDOWN adapter | PULLDOWN | | LOW 110ms | HIGH
# GPIO16 D0 | STRAPPING | OK*4 | OK*5 | | OK | OK | | 470 -> RST*3 | PULLUP | PULLUP | HIGH 110ms*5 |
# *1 Disable hardware uart. logger baud_rate: 0
# *2 recommended I2C
# *3 Enable deep sleep
# *4 No interrupt
# *5 after boot falls ~110ms to ~ 1V
# *6 oscillates
# GPIO08 and GPIO09 pulldown invalid on boot
# Current draw 12mA max per GPIO
# ESP8266 GPIO Behaviour at Boot: https://rabbithole.wwwdotorg.org/2017/03/28/esp8266-gpio.html
# ----- ELECTRICITY -----
# ----- POWER SUPPLY -----
# Module: Super capacitor
# Specification: 2.7V 22F
# Circuit: 2x connected in series out 5V
# Converting energy:
# F - mAh
# mAh = (F * Delta V / 3600) * 1000 = (22 * 2 /3600) * 1000 = 12.2mAh
# Teoretical Life on SuperCap:
# Battery Capacity: 12.2mAh
# Voltage: 3.3V
# Running Time: 12s
# Running current: 80mA
# Idle Time: 3584s
# Idle Current: 20μA
# Average Consumption: 375.5μA
# Battery Life: 1.353d
# Watt-hours: 40.26mWh
# ADC Voltage supercap
battery_pin: A0
battery_measure_pin: GPIO13
# -----------------
# ADC reading whit transistor
# Enable bipolar transistor: 2N3906 PNP and 2N7000 mofset NPN
# Base resistor calculate:
# hFE: 60
# iL (load A): 0.001A
# Vi (base): 3.3V
# Base resistor: Vi/(iL/hFE)/1000 = 3.3/(0.001/60)/1000 = 198kΩ => 220kΩ
# -----------------
# ----- SOLAR PANEL -----
# Module: Solar panel 2Wp polycrystalline 5V
# Specification: Pmax 2W / Voltage Vmp: 5.0V Voc: 5.0V / Imp: 400mA Isc: 400mA / dimension: 94x157x2mm / Operating temperature: -40 ~ +85°C / Wafer: class A polysilicon / Process: EVA lamination
# Circuit: protected shotky diode 1N5817 drop 0.2V
width_panel: "0.07" # m
height_panel: "0.14" # m
# ----- SUPERVISOR -----
# Module: LMS33460 3V under voltage detector
# Specification: Vin 0.8 ~ 7V / open drain out / SC70-5 package / Out current 30mA /
# Power consumption: disable 35µA / enable 45µA
# Settings:
# Default: Falling 2.85 ~ 3.15V / Rising (change using divider): 0.095 ~ 0.215V / Delay time: 70 ~ 130µs
# Circuit:
# Voltage divider: Supercap -> Protect diode 1N5817 -> VCC -> Trim 103 (7.07kΩ) -> In -> 100kΩ -> GND (VCC -> 470kΩ -> Out)
# Mofset: Logic power mofset NPN FQP30N06L Gate -> 220Ω -> Out supervisor
# HYSTERESIS OFF ON
# SuperCAP: 3.3V 3.56V
# ----- LDO -----
# Module: Holtek HT7833
# Specification: Voltage in 0 ~ 8V out fixed 3.3V 2% / max voltage drop 360mV / current max 0.5A /
# Protection: overtemperature / current limiting
# Power consumption: Quiescent current 4µA
# Circuit: VIN -> 2x ceramic 10μF -> GND / VOUT -> PPTC FUSE 0.5A 6V -> VOUT / VOUT -> 470μF 6.3V + 680μF 25V -> GND
# ----- LEDS -----
# Modul: Status led
# Specification: on esp board smd red led
# Modification: remove on board led and solder red whit additional 1KΩ resistor (+ on board 470Ω - down power consumption)
# Power consumption: 328µA
status_led: GPIO02
# Modul: led red diode
# Specification: red led 3mm
# Circuit: GPIO -> LED -> 2kΩ -> VCC(after deep sleep no light on)
# Power consumption: 500µA
indicator_led: GPIO0
# ----- POWER SENSORS -----
# Modul: NPN power transistor 2N7000
# Specification: power all measure modules (reduction of consumption)
# Circuit: GND -> Collector / GPIO -> 1kΩ -> Base / Emitter -> GND out sensor
power_pin: GPIO15
# ----- SOIL MOISTURE SENSOR -----
# OLD WHIT MOISTURE ADC
# Module: Soil moisture sensor
# Specification: Voltage 3.3 ~ 12V / Current working: 20mA, Output 30mA / Dimension: 36x15x7 mm / PCB module whit LM393 comparator
# Modification: unsolder leds (reducer consumption)
# Power consumption: 1.6mA
# Settings:
#moisture_dry: 3.0V
#moisture_wet: 1.85V
#moisture_adc_pin: A0_GND
#moisture_enable_pin: GPIO12
#moisture_stabilize_time: 15s
# NEW WHIT PWM SIGNAL INPUT
# Module: Capacitive Soil Moisture Sensor v2.0
# Specification: Voltage 3.3 ~ 5.5V / Current working: 4.5mA / Dimension: 99x16 mm / PCB module whit TLC555 timer
# Modification: https://thecavepearlproject.org/2020/10/27/hacking-a-capacitive-soil-moisture-sensor-for-frequency-output/
# Unsolder all smd chips on board
# Create new circuit on PCB whit LMC555 timer
# Output PWM signal
# Power consumption: 1.6µA
# Settings:
moisture_dry: 310kHz
moisture_wet: 33kHz
# dry sand: 246kHz
# middle wet soil: 210kHz
moisture_pwm_pin: GPIO12
# How to measure moisture soil:
# https://www.mdpi.com/1424-8220/21/15/5110
# https://thecavepearlproject.org/2020/10/27/hacking-a-capacitive-soil-moisture-sensor-for-frequency-output/
# https://makersportal.com/blog/2020/5/26/capacitive-soil-moisture-calibration-with-arduino
# ----- AMBIENT LIGHT SENSOR -----
# OLD WHIT ADC
# Module: TEMT6000
# Specification: Voltage max. 6V / silicon NPN epitaxial planar phototransistor / Operating Temperature: -40 ~ +85°C / Angle of Half sensitivity: 60° / Wavelength of Peak Sensitivity: 570nm / Range of Spectral Bandwidth: 360 ~ 970nm
# Conection: on module GND -> 10kΩ -> GPIO -> NPN -> VCC
# Power consumption: 20mA (change whit intensity light)
# Measure and formula calculate lux https://devices.esphome.io/devices/temt6000
# I = adc_value/10000kΩ
# The datasheet for the TEMT6000 specifies a proportional correlation between current and illuminance: Every 2 µA of current correlates to 1 lx in the illuminance.
#temt6000_resistor: "10000" #Ω
#temt6000_amps: "2000000" #mA
# max lux = 3.3V * 2000000 /10000 = 660lux / we adjust as much as possible using the cover
# No real calibration is currently used.
# Calibration designed for the exterior.
#temt6000_adc_pin: A1_GND
# NEW WHIT I2C
# Module: BH1750 GY-302 lux meter
# Specifications: 3V ~ 3.6V / Range: 1 ~ 65 535 lx
# Circuit: Interface: I2C address: 0x23
# Consumption: normal 4.4mA
# Modification: unsolder ldo 602K
# http://wiki.sunfounder.cc/index.php?title=GY-302_BH1750_Digital_Light_Intensity_Module
# LUX wiki
# Illuminance (lux) | Surfaces illuminated by
# -----------------------------------------------
# 0.0001 | Moonless, overcast night sky (starlight)[5]
# 0.002 | Moonless clear night sky with airglow[5]
# 0.05–0.3 | Full moon on a clear night[6]
# 3.4 | Dark limit of civil twilight under a clear sky[7]
# 20–50 | Public areas with dark surroundings[8]
# 50 | Family living room lights (Australia, 1998)[9]
# 80 | Office building hallway/toilet lighting[10][11]
# 100 | Very dark overcast day[5]
# 150 | Train station platforms[12]
# 320–500 | Office lighting[9][13][14][15]
# 400 | Sunrise or sunset on a clear day.
# 1000 | Overcast day;[5] typical TV studio lighting
# 10,000–25,000 | Full daylight (not direct sun)[5]
# 32,000–100,000 | Direct sunlight
# ----- TEMPERATURE / PRESSURE SENSOR -----
# OLD WHIT TX
# Module: ASAIR AM2301
# Specifications: Voltage: 3.3 ~ 5.2V / Operational Range: Temperature: -40 ~ +80°C Humidity: 0~100% / Resolution: Humidity: 0.1%RH, Temperature 0.1°C / Accuracy: Temperature: +-1°C Humidity: +-3% / Sample period: 2s
# Circuit: Interface: one wire SDA
# Power consumption: Dormancy: 15μA / Measuring: 500μA / Average: 300μA / whit multimeter 760μA
# Measure after enable min. 2s
#am2301_pin: GPIO13
# NEW WHIT I2C
# Module: BMP280 - pressure / temperature
# Specifications: Voltage: 1.8 ~ 3.6V / Operational Range: Temperature: -40 ~ +85°C Pressure: 300~1100 hPa / Accuracy: Temperature: +-0.01°C Pressure: +-1.3Pa
# Circuit: Interface: I2C address: 0x77
# Power consumption: normal: 0.4mA measure: 0.7mA sleep: 0.2μA
# Cabling: yellow: vcc / brown: gnd / green: sda / white: scl
# ----- HUMIDITY SENSOR -----
# Module: AHT22 - humidity / temperature
# Specifications: Voltage: 2.0 ~ 5.5V / Operational Range: Temperature: -40 ~ +85°C Humidity: 0~100% / Accuracy: Temperature: +-0.3°C Humidity: 0.2%RH
# Circuit: Interface: I2C address: 0x33
# Power consumption: normal: 0.25μA measure: 23μA
# Cabling: yellow: vcc / brown: gnd / green: sda / white: scl
# Module: Dallas DS18B20
# Circuit: 4.7kΩ resistor data pin to VCC
# Power consumption: 50uA
# Measure: Soil
# UPDATE AFTER BOOT: 1s
dallas_pin: GPIO14
# ----- UPDATE TIME -----
update_interval: never
stabilize_time: 2300ms
#-------------------------------------------
# PROTOCOLS
#-------------------------------------------
# Circuit: I2C 4.7k pullup
# ----- PROTOCOLS PINS -----
# I2C
i2c_sda: GPIO04
i2c_scl: GPIO05
# ----- PROTOCOLS SETTINGS -----
i2c:
sda: $i2c_sda
scl: $i2c_scl
scan: False
dallas:
- pin: "$dallas_pin"
update_interval: 10s # Does not work component.update
#-------------------------------------------
# ESP main settings
#-------------------------------------------
# preferences:
# flash_write_interval: 10min # reduce writings to the flash to preserve its health, adjust it on demand
esphome:
name: ${device_name}
project:
name: "studiotiim.plant-garden"
version: 2023.05.1.1.0
platform: esp8266
board: esp12e
platformio_options:
board_build.f_cpu: 80000000L
on_boot:
- priority: 900.0
then:
# Wake up info
- lambda: |-
id(wake_up_reason) = ESP.getResetInfoPtr()->reason;
# Thanks: https://www.homeassistant-cz.cz/viewtopic.php?t=257&hilit=ldo&sid=40796e1ff02dc925e2c1f1bd375a9918&start=20
# OTA UPDATE: 4
# WAKE DEEP SLEEP: 5
# RESET: 6
# POWER ON: 0
- priority: 600.0
then:
# control battery status
- switch.turn_on: switch_measure_battery
- delay: 55ms
- if:
condition:
sensor.in_range:
id: battery_temp_global
below: 3.5
then:
deep_sleep.enter: deep_sleep_component
- priority: 300.0
then:
# wait mqtt
- wait_until:
condition: mqtt.connected
timeout: 30s
- text_sensor.template.publish: # Send online state when mqtt is connected
id: online_status
state: "Online"
# prevent enter deepsleep on boot user switch sleep/loop measure button
- if:
condition:
- lambda: "return id(wake_up_reason) == 4;"
then:
- switch.turn_on: deepsleep_switch
# measure after boot
- if:
condition:
switch.is_off: deepsleep_switch
then:
- switch.turn_on: switch_measure_sensors
- light.turn_on: indicatorled
- delay: 50ms
- light.turn_off: indicatorled
- component.update: soil_moisture
- component.update: ambient_light
- component.update: signal_strange
- delay: $stabilize_time
- component.update: temp_air1
- component.update: temp_air2
- component.update: soil_moisture
# prevent enter deepsleep on boot user switch sleep/loop measure button
- if:
condition:
not:
- lambda: "return id(wake_up_reason) == 4;"
then:
- delay: 10ms
- switch.turn_off: switch_measure_sensors
on_shutdown: # send offline state when mcu power off or go to deep sleep
priority: 0.0 # tested more settings the server does not always receive the value
then:
- text_sensor.template.publish:
id: online_status
state: "Offline"
# Enable logging
logger:
#-------------------------------------------
# MQTT
#-------------------------------------------
mqtt:
broker: '192.168.31.212'
username: !secret mqtt_username
password: !secret mqtt_password
discovery: true
reboot_timeout: 30s
# online first message
birth_message:
topic: $device_name/status_on
payload: online
# drop connected message
will_message:
topic: $device_name/status_unavailable
payload: unavailable
# offline last message
shutdown_message:
topic: $device_name/status_off
payload: offline
# OTA message
on_message:
- topic: "$device_name/ota_mode"
payload: 'ON'
then:
- deep_sleep.prevent: deep_sleep_component
- switch.turn_on: deepsleep_switch
- logger.log: "OTA blocking deep sleep"
- topic: $device_name/ota_mode
payload: 'OFF'
then:
- logger.log: "Ota finished back to deep sleep allow"
- deep_sleep.allow: deep_sleep_component
ota:
password: !secret ota_pass
on_end:
then:
- mqtt.publish:
topic: $device_name/ota_mode
payload: 'OFF'
retain: true
#-------------------------------------------
# WIFI
#-------------------------------------------
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
#power_save_mode: light
fast_connect: True
#output_power: 8.5dB
manual_ip:
static_ip: 192.168.31.222
gateway: 192.168.31.1
subnet: 255.255.255.0
ap:
ssid: "$device_name Hotspot"
password: "passplantgarden"
captive_portal:
#-------------------------------------------
# GLOBALS
#-------------------------------------------
globals:
#-------------------------------------------
# Global set wake up
#-------------------------------------------
- id: wake_up_reason
type: int
restore_value: no
initial_value: '0'
#-------------------------------------------
# Restore global battery value
#-------------------------------------------
- id: battery_global_value
type: float
restore_value: yes
initial_value: '4.0'
#-------------------------------------------
# DEEP SLEEP
#-------------------------------------------
deep_sleep:
id: deep_sleep_component
sleep_duration: 3600sec
run_duration: 30sec
#-------------------------------------------
# STATUS LED
#-------------------------------------------
status_led:
pin:
number: ${status_led}
inverted: True
#-------------------------------------------
# SENSORS
#-------------------------------------------
sensor:
#-------------------------------------------
# Uptime
#-------------------------------------------
- platform: uptime
device_class: duration
name: ${friendly_name} Uptime Sensor
id: time_since_boot
#update_interval: 60s
#-------------------------------------------
# Who enable MCU
#-------------------------------------------
- platform: template
name: "${friendly_name} Who enable"
id: kdo_mne_budi
accuracy_decimals: 0
internal: true
lambda: |-
return (id(wake_up_reason));
on_value:
- if:
condition:
lambda: return id(kdo_mne_budi).state;
then:
- if:
condition:
lambda: "return id(wake_up_reason) == 4;"
then:
text_sensor.template.publish:
id: start_enable
state: "OTA"
- if:
condition:
lambda: "return id(wake_up_reason) == 5;"
then:
text_sensor.template.publish:
id: start_enable
state: "DEEP SLEEP"
- if:
condition:
lambda: "return id(wake_up_reason) == 6;"
then:
text_sensor.template.publish:
id: start_enable
state: "RESET"
#- if:
# condition:
# lambda: "return id(wake_up_reason) == 0;"
# then:
# text_sensor.template.publish:
# id: start_enable
# state: "POWER"
else:
text_sensor.template.publish:
id: start_enable
state: "POWER"
#-------------------------------------------
# Wifi signal component
#-------------------------------------------
- platform: wifi_signal
name: "${friendly_name} MCU Signal"
id: "signal_strange"
update_interval: never
#-------------------------------------------
# ADC - Battery
# 2x Supercap 5.5V 22F
#-------------------------------------------
- platform: adc
pin: $battery_pin
name: "${friendly_name} Voltage Battery"
id: battery
update_interval: never
unit_of_measurement: "V"
accuracy_decimals: 2
filters:
- multiply: 5.75
on_value:
then:
- component.update: battery_percent
- globals.set:
id: battery_global_value
value: !lambda 'return x;'
device_class: battery
entity_category: diagnostic
icon: mdi:home-battery
#-------------------------------------------
# Template - Battery percent
#-------------------------------------------
- platform: template
name: "${friendly_name} Battery"
unit_of_measurement: "%"
id: battery_percent
update_interval: never
lambda: "return id(battery).state;"
filters:
- calibrate_linear:
- 3.4 -> 0
- 5.0 -> 100
- lambda: 'return max((float)0.0, x);' # No value lower than 0
- lambda: 'return min((float)100.0, x);' # No value greater than 100
device_class: battery
entity_category: diagnostic
#-------------------------------------------
# Template - Battery global set
#-------------------------------------------
- platform: template
name: "${friendly_name} Battery global"
id: battery_temp_global
accuracy_decimals: 1
lambda: |-
return (id(battery_global_value));
internal: true
#-------------------------------------------
# Ambient light sensor - LUX sensor - BH1750
#-------------------------------------------
- platform: bh1750
name: "${friendly_name} Outdoor Illuminance"
address: 0x23
accuracy_decimals: 0
update_interval: never
id: ambient_light
device_class: illuminance
#-------------------------------------------
# Temperature pressure sensor - BMP280
#-------------------------------------------
- platform: bmp280
id: temp_air1
temperature:
name: "${friendly_name} Outdoor Temperature"
oversampling: 1x
pressure:
name: "${friendly_name} Outdoor Pressure"
oversampling: 1x
address: 0x77
update_interval: never
#-------------------------------------------
# Temperature humidity sensor - AHT22
#-------------------------------------------
- platform: aht10
id: temp_air2
temperature:
id: temp_aht
internal: True
humidity:
name: "${friendly_name} Outdoor Humidity"
id: humidity_sensor
update_interval: never
#-------------------------------------------
# DALLAS - Temperature sensor
# DS18B20
# connected 4.7k to VCC
#-------------------------------------------
# Temperature solar panel
- platform: dallas
address: 0xa13c24f648b38e28
name: "${friendly_name} Soil Temperature"
id: temp_soil
unit_of_measurement: "°C"
icon: mdi:thermometer
filters:
filter_out: nan
#-------------------------------------------
# PULSE COUNTER - Soil moisture sensor
#-------------------------------------------
- platform: pulse_counter
pin: $moisture_pwm_pin
name: "${friendly_name} Soil Moisture"
id: soil_moisture
update_interval: never
unit_of_measurement: "%"
accuracy_decimals: 1
icon: mdi:water-percent
filters:
- calibrate_linear:
- 310000.0 -> 0
- 33000.0 -> 100
- lambda: 'return max((float)0.0, x);' # No value lower than 0
- lambda: 'return min((float)100.0, x);' # No value greater than 100
on_value:
if:
condition:
switch.is_off: deepsleep_switch
then:
- text_sensor.template.publish:
id: online_status
state: "Offline"
- delay: 1150ms
- deep_sleep.enter: deep_sleep_component
#-------------------------------------------
# SWITCHES
#-------------------------------------------
switch:
#-------------------------------------------
# Deep Sleep and continual measure enable switch
#-------------------------------------------
- platform: template
name: "${friendly_name} Sleep/Loop Measure"
#icon: mdi:power-sleep
icon: mdi:move-resize-variant
id: deepsleep_switch
entity_category: config
optimistic: True
on_turn_on:
then:
- deep_sleep.prevent: deep_sleep_component
- logger.log:
format: "DEEP SLEEP DISABLE"
level: warn
- switch.turn_on: switch_measure_sensors
on_turn_off:
then:
- logger.log:
format: "DEEP SLEEP ENABLE"
level: warn
- switch.turn_off: switch_measure_sensors
- delay: 2s
- deep_sleep.enter: deep_sleep_component
#-------------------------------------------
# Power mofset switch
# DALLAS, MOISTURE
#-------------------------------------------
- platform: gpio
name: "${friendly_name} Measure Sensors"
icon: mdi:move-resize-variant
restore_mode: ALWAYS_OFF
pin: $power_pin
id: switch_measure_sensors
entity_category: config
internal: true
#-------------------------------------------
# Power mofset switch
# BATTERY
#-------------------------------------------
- platform: gpio
name: "${friendly_name} Measure Battery"
id: switch_measure_battery
restore_mode: ALWAYS_OFF
pin: GPIO13
entity_category: config
on_turn_on:
then:
- delay: 50ms
- component.update: battery
- switch.turn_off: switch_measure_battery
#-------------------------------------------
# BUTTONS
#-------------------------------------------
button:
#-------------------------------------------
# RESTART
# restart = reset prevent deepsleep
#-------------------------------------------
- platform: restart
name: "${friendly_name} MCU Restart"
entity_category: diagnostic
#-------------------------------------------
# INTERVALS - measurement cycling battery
#-------------------------------------------
interval:
# cycling measure
- interval: 5s
then:
- if:
condition:
- switch.is_on: deepsleep_switch
then:
- switch.turn_on: switch_measure_battery
- component.update: ambient_light
- component.update: signal_strange
- component.update: temp_air1
- component.update: temp_air2
- component.update: soil_moisture
# led status blinking
- interval: 2s
then:
- if:
condition:
mqtt.connected
then:
- light.turn_on: indicatorled
- delay: 50ms
- light.turn_off: indicatorled
#-------------------------------------------
# TEXT SENSORS
#-------------------------------------------
text_sensor:
#-------------------------------------------
# Defines who started esp
#-------------------------------------------
- platform: template
name: "${friendly_name} MCU Enable"
id: start_enable
icon: "mdi:power-standby"
entity_category: diagnostic
lambda: return {"Loading"};
update_interval: never
#-------------------------------------------
# Online state mcu
# bug no send online or offline does always state
#-------------------------------------------
- platform: template
id: online_status
name: "${friendly_name} MCU Status"
lambda: |-
return {"Loading"};
icon: "mdi:power-standby"
update_interval: never
entity_category: diagnostic
#-------------------------------------------
# BINARY SENSORS
#-------------------------------------------
binary_sensor:
#-------------------------------------------
# LIGHT
#-------------------------------------------
light:
#-------------------------------------------
# Led Red - infolight
#-------------------------------------------
- platform: binary
name: "${friendly_name} Led Indicator"
output: indicator_led
id: indicatorled
internal: True
restore_mode: ALWAYS_OFF
#-------------------------------------------
# OUTPUTS
#-------------------------------------------
output:
#LED
- id: indicator_led
platform: gpio
pin: "$indicator_led"
inverted: True
Meranie vlhkosti pôdy je veľká veda tak ak vie niekto ako by sme mohli vylepšiť kód tak sem s tym v kóde sú aj užitočné články na to. Ja som to zatial spravil jednoducho voda vs vzduch a percentá.
EDIT: úprava kódu + zmena na kapacitny senzor pôdy.
EDIT2:
- Pridaný riadiačný štít
- Úprava kódu pre korekntné posielanie hodnôt vlhkosti pôdy
- Vyzerá to tak, že bude treba dať väčši kondenzátor nakoľko vydrži celú noc ale svietilo celý den slnko. Uvidíme správanie sa počas oblačnosti a hlavne už je letný čas v zime by to senzor nedával.
EDIT3:
- nahradený svetelny senzor temt6000 za i2c bh1750
- nahradený teplotny senzor am3201 za aht22 + bmp280
- odstránený adc ads1115 senzor
- meranie iba napätia na supercap
- úprava kóde beh teraz iba 12s