esp8266 a superkapacitor
- tiimsvk
- Pokročilý
- Příspěvky: 440
- Registrován: 06. květen 2021, 07:03
- Dal poděkování: 41 poděkování
- Dostal poděkování: 43 poděkování
Re: esp8266 a superkapacitor
POZNÁMKY K SUPERCAP A PÔDNEMU SENZORU
Funkčné riešenie, ale nie je to to čo by som si uplne predstavoval. Budem tu robiť poznámky:
SUPERVIZOR:
- Zapojenie bez zvýšenia hysterézie bol problém aspoň pre moje esp8266 takže som postupoval podľa linku od kiklhorn https://www.ti.com/lit/an/slva360/slva360.pdf, postačovalo pridať ďeličku napätia aspoň v mojom nastavení kde som pridal 100kohm z napájania supervizora na gnd a z vcc trimer 103ku kde nastavujem hornú hranu spustenia (ďelička spravila zazráky čo sa týka spustena) + som pridal posun napätia pri vipnutí pomocou shotkyho diody z 3.0V na 3.2V
MOFSET:
- Mofset som skúšal IRFZ44N ako bežne dostupný, ale po skúšaní a prečitaní članku https://oscarliang.com/how-to-use-mosfe ... -tutorial/ som ho nahradil logickým mofsetom FQP30N60L,s ktorým začalo moje zariadenie fungovať.
ESP32-C3-12F vs ESP8266:
- Snažil som sa celý projekt postaviť na novom esp32-C-12F, ktorý je formátu ako klasická esp8266 12F ale bez úspechu.
Hlavný problém je asi napájanie ale bez kvalitného power profileru to neviem zistiť ako sa správa esp pri nábehu ale verím, že si stiahne dosť veľa napätia a tým pádom to nezvláda regulátor
- Ak to niekto vie skúsiť s týmto esp budem len rád za každú radu.
- Konfigurácia ESP32-C3-12F / LDO HT7833, 20uF vstup, 680uF výstup / Supervisor LMS33460 / a na vstupe 3.3V
- škoda pretože celkovo ten modul je úspornejši ako akékoľvek esp8266.
Pôdny senzor:
- Skúšal som lacný senzor pre snimanie vlhkosti pôdy https://vi.aliexpress.com/item/1005002010938691.html
- Problém s týmto senzorom je stabilizovanie až 20s cca + odčitavalo príliš vysokú hodnotu aj polosuchej pôde preičom na vzduchu bol diametrálny rozdiel, preto som sa rozhodol prejsť na kapacitný senzor.
Na laskakit ho predávaju za malo korun a je super už jeden projekt s nim mam postavený a funguje skvelo.
- Pristupil som k tomuto ale iným spôsobom, všetky súČiastky som z dosky dal dole a prirobil ich k PCB kde je esp + som použil hack zo stránky:
https://thecavepearlproject.org/2020/10 ... cy-output/
čim som vyhodil čitanie signalu cez ADC a čitam pwm signal. čital som, že pri dlhšom čase má senzor problém s pôdou tak uvidíme, aké hodnoty budú pri dlhšom použivaní. Jeden veľký uspech je ale, že namiesto pôvodných 4.5mA má teraz celý senzor pre pôdu pod 1mA.
TEPLOMER:
- z prvých pokusov merania je viditeľné že teplotný senzor ukotfený priamo na zariadení, ktoré je celé čierne nie je dobrý nápad. Teploty veľmi ulietaju pri vysokých vonkajšich teplotách.
- v pláne je vyriešiť pomocou externej pripojky a senzor umiestniť do radiačného štítu to by malo ovplyvniť teplotu k presnejšim hodnotám.
Naposledy upravil(a) tiimsvk dne 30. květen 2023, 16:09, celkem upraveno 4 x.
- tiimsvk
- Pokročilý
- Příspěvky: 440
- Registrován: 06. květen 2021, 07:03
- Dal poděkování: 41 poděkování
- Dostal poděkování: 43 poděkování
Re: esp8266 a superkapacitor
Už sa to pomaly rysuje:
Stále poznámky budú v príspevku vyššie.
Schémy aj kód postnem neskôr keď bude všetko fungovať zatial to vyzera slubne. Stále poznámky budú v príspevku vyššie.
- tiimsvk
- Pokročilý
- Příspěvky: 440
- Registrován: 06. květen 2021, 07:03
- Dal poděkování: 41 poděkování
- Dostal poděkování: 43 poděkování
Re: esp8266 a superkapacitor
"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! )
Meranie záhrady
Čo dokáže:
- Meranie teploty a vlhkosti 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
- TEMT6000
- ADS1115
- Dallas temperature sensor
- Capacitive Soil Moisture Sensor V2.0
- AM2301
Súčiastky:
Dioda 1N5817 2x
Tranzistor PNP 2N3906 2x
Rezistor 220k 2x
Rezistor 220
Rezistor 100k
Rezistor 470k 5k
Rezistor 470
Rezistor 10k 4x
Rezistor 4k7
Rezistor 1M
Rezistor 1k
Rezistor 2k
Led 3mm červená
Logic power mofset NPN FQP30N60L >0.5A
Logic power mofset NPN 2N7000 >0.2A
Kondenzátor foĺiový 630uF 2x
Trim 103
supervizor LMS33460
timer LM555CN (alebo original použiť z kapacitného senzoru)
keramický kondezátor 20uF
keramický kondezátor 0.33uF
keramický kondezátor 10nF 2x
keramický kondezátor 100nF
Poistku PPCT 0.5A
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 konektry
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:
Meranie vlhkosti pôdy je veľká veda tak ak vie niekt 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.

(už sme na druhej! )
Meranie záhrady
Čo dokáže:
- Meranie teploty a vlhkosti 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
- TEMT6000
- ADS1115
- Dallas temperature sensor
- Capacitive Soil Moisture Sensor V2.0
- AM2301
Súčiastky:
Dioda 1N5817 2x
Tranzistor PNP 2N3906 2x
Rezistor 220k 2x
Rezistor 220
Rezistor 100k
Rezistor 470k 5k
Rezistor 470
Rezistor 10k 4x
Rezistor 4k7
Rezistor 1M
Rezistor 1k
Rezistor 2k
Led 3mm červená
Logic power mofset NPN FQP30N60L >0.5A
Logic power mofset NPN 2N7000 >0.2A
Kondenzátor foĺiový 630uF 2x
Trim 103
supervizor LMS33460
timer LM555CN (alebo original použiť z kapacitného senzoru)
keramický kondezátor 20uF
keramický kondezátor 0.33uF
keramický kondezátor 10nF 2x
keramický kondezátor 100nF
Poistku PPCT 0.5A
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 konektry
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
#-------------------------------------------
# Replace ads1115 broken A2 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 5.0V
# First booting MCU:
# Booting MCU after connected to mqtt:
# Measure sensors:
# Normal:
# Deep sleep:
# Power consumption 3.3V
# First booting MCU:
# Booting MCU after connected to mqtt:
# Measure sensors:
# Normal:
# Deep sleep:
#-------------------------------------------
# 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| |
# A0 | ANALOG ADC0 | | | OK | | | | | | | |
# GPIO0 | STRAPPING | OK! | OK! | | OK | OK | | 10.0k PULLUP | PULLUP | pulldown | HIGH | LOW
# GPIO01 | TX | OK!*1 | OK | | OK | OK | | | | | HIGH | LOW
# GPIO02 | ON BOARD LED | OK | OK | | OK | OK | | 10.0k PULLUP | PULLUP | | HIGH | LOW
# GPIO03 | RX | OK | OK!* | | OK | OK | | | | | HIGH |
# GPIO04 | SDA | OK | OK | | OK | OK*2 | | | | | |
# GPIO05 | 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 | | OK | OK | | OK | OK | MISO | | | | HIGH |
# GPIO13 | | OK | OK | | OK | OK | MOSI | | | | HIGH |
# GPIO14 | | OK | OK | | OK | OK | SCLK | | | | HIGH |
# GPIO15 | STRAPPING | OK! | OK! | | OK | OK | CS | 10k PULLDOWN adapter | PULLDOWN | | LOW | HIGH
# GPIO16 | STRAPPING | OK*4 | OK*5 | | OK | OK | | 470 -> RST*3 | PULLUP | PULLUP | HIGH |
# *1 Disable hardware uart. logger baud_rate: 0
# *2 recommended I2C
# *3 Enable deep sleep
# *4 No interrupt
# *5
# GPIO08 and GPIO09 pulldown invalid on boot
# Current draw 12mA max per GPIO
# ----- 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
# ----- 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
width_panel: "0.07" # m
height_panel: "0.14" # m
# ----- LEDS -----
# Modul: Status led
# Specification: on esp board smd red led
# Modification: remove on board led and solder red whit additional 680Ω resistor (+ on board 470Ω)
# 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 -----
# 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)
# 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
# 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
# ----- TEMPERATURE / HUMIDITY SENSOR -----
# 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
# Module: Dallas DS18B20
# Circuit: 4.7kΩ resistor data pin to VCC
# Power consumption: 50uA
# Measure: Soil
# UPDATE AFTER BOOT: 1s
dallas_pin: GPIO14
# ----- POWER SUPPLY -----
# Module: Super capacitor
# Specification: 2.7V 22F
# Circuit: 2x connected in series out 5V
# ----- MCU VOLTAGE-----
# Module: VCC ADC MCU
# Measure: Voltage mcu detector when power failure supercap can hold for max 10s send alert to HA
voltage_mcu_pin: VCC
# ----- Charger -----
# Module: Solar panel
#Circuit: protected shotky diode 1N5817 drop 0.2V
# Voltage solar panel and supercap
supercap_adc_pin: A3_GND
solar_adc_pin: A0_GND
# -----------------
# NOT INSTALLED it works even without a transistor (no more power consumption)
# Enable bipolar transistor: 2N3906 PNP
# 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Ω
# supercap_enable_pin: GPIO0
# -----------------
# ----- ADC SENSOR -----
# Module: ADS1115 4-Channel 16-Bit A/D Converter
# Specification: Voltage: 2.0 ~ 5.5V / Operational Range: Temperature: -40 ~ +125°C / Resolution: 16-bit 6.144V
# Circuit: Interface: I2C 0X48 ADDR -> GND
# Power consumption: 150μA
# ----- UPDATE TIME -----
update_interval: never
time_measure_delay: 5s
#-------------------------------------------
# PROTOCOLS
#-------------------------------------------
# ----- PROTOCOLS PINS -----
# I2C
i2c_sda: GPIO04
i2c_scl: GPIO05
# ----- PROTOCOLS SETTINGS -----
i2c:
sda: $i2c_sda
scl: $i2c_scl
dallas:
- pin: "$dallas_pin"
update_interval: 10s # Does not work component.update
ads1115:
- address: 0x48
#-------------------------------------------
# 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.0.0
platform: esp8266
board: esp12e
platformio_options:
board_build.f_cpu: 80000000L
on_boot:
- priority: 900.0
then:
- 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:
- switch.turn_on: switch_measure_sensors
- delay: 50ms
- component.update: battery
- switch.turn_off: switch_measure_sensors
- if:
condition:
sensor.in_range:
id: battery_temp_global
below: 3.5
then:
deep_sleep.enter: deep_sleep_component
- priority: 300.0
then:
- wait_until:
condition: mqtt.connected
timeout: 10s
- text_sensor.template.publish: # Send online state when mqtt is connected
id: online_status
state: "Online"
- switch.turn_on: switch_measure_sensors
# - light.turn_on: switch_measure_moisture
- delay: 150ms
- component.update: battery
- component.update: mcu_voltage
- component.update: ambient_light
- component.update: signal_strange
- delay: $time_measure_delay
- component.update: temp_air
#- component.update: soil_moisture
- if: # prevent enter deepsleep on boot user switch sleep/loop measure button
condition:
switch.is_off: deepsleep_switch
then:
- delay: 50ms
- switch.turn_off: switch_measure_sensors
- binary_sensor.template.publish:
id: measure_moisture_cycle
state: OFF
- text_sensor.template.publish:
id: online_status
state: "Offline"
- delay: 2s
- deep_sleep.enter: deep_sleep_component
# - delay: $moisture_stabilize_time
# - if: # prevent off on boot user switch sleep/loop measure button
# condition:
# switch.is_off: deepsleep_switch
# then:
# - light.turn_off: switch_measure_moisture
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: 60s
# 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
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: ads1115
multiplexer: $supercap_adc_pin
gain: 4.096
name: "${friendly_name} Voltage Battery"
id: battery
update_interval: never
unit_of_measurement: "V"
accuracy_decimals: 2
filters:
- multiply: 2.0579
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
#-------------------------------------------
# ADC - Mcu
#-------------------------------------------
- platform: adc
pin: $voltage_mcu_pin
name: "${friendly_name} Voltage MCU"
id: mcu_voltage
update_interval: never
unit_of_measurement: "V"
accuracy_decimals: 2
device_class: battery
entity_category: diagnostic
icon: mdi:select-inverse
#-------------------------------------------
# ADC - Solar
# Solar panel
#-------------------------------------------
- platform: ads1115
multiplexer: $solar_adc_pin
gain: 4.096
name: "${friendly_name} Voltage Solar"
id: solar
update_interval: never
unit_of_measurement: "V"
accuracy_decimals: 2
device_class: battery
entity_category: diagnostic
filters:
- multiply: 2.0535
icon: mdi:solar-power-variant
#-------------------------------------------
# ADC - Soil moisture sensor
#-------------------------------------------
# - platform: ads1115
# multiplexer: $moisture_adc_pin
# gain: 4.096
# name: "${friendly_name} Soil Moisture"
# id: soil_moisture
# update_interval: never
# filters:
# - calibrate_linear:
# - 2.99 -> 0
# - 1.85 -> 100
# - filter_out: 0.0
# No value lower than 0
# - lambda: 'return max((float)0.0, x);'
# No value greater than 100
# - lambda: 'return min((float)100.0, x);'
# unit_of_measurement: "%"
# accuracy_decimals: 1
# icon: mdi:water-percent
- platform: pulse_counter
pin: $moisture_pwm_pin
name: "${friendly_name} Soil Moisture"
id: soil_moisture
update_interval: never
unit_of_measurement: "%"
accuracy_decimals: 0
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
#-------------------------------------------
# ADC - Ambient light sensor
# TEMT6000
#-------------------------------------------
- platform: ads1115
multiplexer: $temt6000_adc_pin
gain: 4.096
id: ambient_light
update_interval: never
name: "${friendly_name} Illuminance"
device_class: illuminance
unit_of_measurement: lx
accuracy_decimals: 0
filters:
#- calibrate_linear:
# - 3.18 -> 6600
# - 0.1 -> 0
- calibrate_polynomial:
degree: 5
datapoints:
- 0.1 -> 0
- 0.2 -> 10
- 0.3 -> 20
- 0.4 -> 30
- 0.5 -> 40
- 0.6 -> 50
- 0.7 -> 60
- 0.8 -> 70
- 0.9 -> 80
- 1 -> 90
- 1.1 -> 100
- 1.2 -> 240
- 1.3 -> 260
- 1.4 -> 280
- 1.5 -> 300
- 1.6 -> 320
- 1.7 -> 340
- 1.8 -> 360
- 1.9 -> 280
- 2 -> 400
- 2.1 -> 420
- 3.18 -> 6600
- lambda: 'return max((float)0.0, x);' # No value lower than 0
- lambda: 'return min((float)6600.0, x);' # No value greater than 100
# calibrate interior
# - lambda: |-
# return (x / ${temt6000_resistor}) * ${temt6000_amps};
#-------------------------------------------
# DHT - Temperature humidity sensor
# AM2301
#-------------------------------------------
- platform: dht
pin: $am2301_pin
#model: DHT21/22
temperature:
name: "${friendly_name} Temperature Air"
humidity:
name: "${friendly_name} Humidity Air"
update_interval: never
id: temp_air
#-------------------------------------------
# DALLAS - Temperature sensor
# DS18B20
# connected 4.7k to VCC
#-------------------------------------------
# Temperature solar panel
- platform: dallas
address: 0xa13c24f648b38e28
name: "${friendly_name} Temperature Soil"
id: temp_soil
unit_of_measurement: "°C"
icon: mdi:thermometer
filters:
filter_out: nan
#-------------------------------------------
# SWITCHES
#-------------------------------------------
switch:
#-------------------------------------------
# Deep Sleep 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
# - light.turn_on: switch_measure_moisture
on_turn_off:
then:
- logger.log:
format: "DEEP SLEEP ENABLE"
level: warn
- switch.turn_off: switch_measure_sensors
# - light.turn_off: switch_measure_moisture
- delay: 2s
- deep_sleep.enter: deep_sleep_component
#-------------------------------------------
# Power transistor switch
# AM2301 / DALLAS / TEMT6000
#-------------------------------------------
- platform: gpio
name: "${friendly_name} Measure Sensors"
icon: mdi:move-resize-variant
restore_mode: ALWAYS_OFF
pin: $power_pin
id: switch_measure_sensors
on_turn_on:
- then:
- binary_sensor.template.publish:
id: measure_moisture_cycle
state: ON
on_turn_off:
- then:
- binary_sensor.template.publish:
id: measure_moisture_cycle
state: OFF
entity_category: config
internal: true
#-------------------------------------------
# Switch - ADC Battery status reading
#-------------------------------------------
# - platform: gpio
# name: "${friendly_name} Measure Battery"
# restore_mode: ALWAYS_OFF
# pin:
# number: "$supercap_enable_pin"
# id: switch_measure_power
# entity_category: config
#-------------------------------------------
# BUTTONS
#-------------------------------------------
button:
#-------------------------------------------
# RESTART
# restart = reset prevent deepsleep
#-------------------------------------------
- platform: restart
name: "${friendly_name} MCU Restart"
entity_category: diagnostic
#-------------------------------------------
# INTERVALS - measurement cycling battery
#-------------------------------------------
interval:
- interval: 5s
then:
- if:
condition:
- binary_sensor.is_on: measure_moisture_cycle
then:
- component.update: soil_moisture
- if:
condition:
- switch.is_on: deepsleep_switch
then:
- component.update: battery
- component.update: solar
- component.update: mcu_voltage
- component.update: ambient_light
- component.update: signal_strange
- delay: $time_measure_delay
- component.update: temp_air
- 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:
- platform: template
id: measure_moisture_cycle
internal: true
#-------------------------------------------
# LIGHT
#-------------------------------------------
light:
#-------------------------------------------
# Led Red - infolight
#-------------------------------------------
- platform: binary
name: "${friendly_name} Led Indicator"
output: indicator_led
id: indicatorled
internal: True
restore_mode: ALWAYS_OFF
#-------------------------------------------
# Power Moisture switch
# Moisture soil sensor measure
#-------------------------------------------
# - platform: binary
# name: "${friendly_name} Measure Moisture"
# output: moisture_pwm
# id: switch_measure_moisture
# icon: mdi:pillar
# restore_mode: ALWAYS_OFF
# on_turn_on:
# - then:
# - delay: $time_measure_delay
# - component.update: soil_moisture
# entity_category: config
#-------------------------------------------
# OUTPUTS
#-------------------------------------------
output:
#LED
- id: indicator_led
platform: gpio
pin: "$indicator_led"
inverted: True
#PWM MOISTURE
# - platform: esp8266_pwm
# pin: $moisture_enable_pin
# frequency: 1.5 MHz
# id: moisture_pwm
EDIT: úprava kódu + zmena na kapacitny senzor pôdy.