esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

during GIMPLE pass: *diagnose_omp_blocks ERROR esphome 12.5 #5343

Closed tiimsvk closed 8 months ago

tiimsvk commented 8 months ago

The problem

when compiling the code for the weather station, a problem popped up that I can't solve. Problem is "hal" files: Compiling .pioenvs/weather-station/FrameworkArduino/esp32-hal-cpu.c.o

sorry for yaml code is too long

Which version of ESPHome has the issue?

2023.12.5

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP8266

Board

ESP32S

Component causing the issue

esp32-hal-adc.c

Example YAML snippet

#-------------------------------------------
# SUBTITUTIONS - basic definitions and description of the device
#-------------------------------------------
substitutions:
  device_name: ESP-Weatherstation
  friendly_name: weather-station
  created_by: StudioTiiM 2021-2023
  device_description: "A complete battery-powered weather monitoring station"

#-------------------------------------------
# CONECTION OF CABLES
#-------------------------------------------
# RADIATION SHIELD:
  # USB cable:
    # white  : NO 
    # green  : Smoke ADC
    # blue   : GND
    # orange : 5V
  # LAN cable:
    # dark brown  : 5V
    # brig brown  : GND PWM
    # dark blue   : SPS30 SCL
    # brig blue   : SPS30 SDA
    # dark orange : 3.3V
    # brig orange : GND
    # dark green  : MHZ RX
    # brig green  : MHZ TX

#-------------------------------------------
# POWER CONSUMPTION 
# whit multimeter
#-------------------------------------------
# Power consumption 12V
# First booting MCU + MCU CAM: 300mA
# Booting MCU: 180mA
# Heating sensors: 130mA
# Normal: 40mA
# Deep sleep: 17mA

# Power consumption 5V
# First booting MCU + MCU CAM: 510mA
# Booting MCU after connected to mqtt: 350mA
# Heating sensors: 330mA
# Normal: 270mA
# Deep sleep: 13mA

#-------------------------------------------
# DEFINE PINS AND VARIABILES
# CIRCUIT AND MODULES - basic definitions and description of the device
#-------------------------------------------

# ----- MCU -----
  # Module: ESP32-S + adapter
   # Circuit: Solder on Prototype PCB expansion board ESP32 7x9cm

   # Power Consumption: Peak ~  / Normal wifi:  ~  / Normal: ~  / DeepSleep: ~ 
   # Specification: Chip Family: ESP32 / Chip Model: ESP32S / Chip ID:  / MAC Address:  / Number of Cores:  / CPU Frequency: 240MHz / Ram:  / Flash: 

   # Description pins:
    # PINS ESP32    | FUNCTION     | INPUT | OUTPUT | ADC | PWM | I2C           | SPI  | RESISTOR             | BOOT       | FLASH   | HIGH AT BOOT | BOOT FAILS | NOTES
    # -------------------------------------------------------------------------------------------------------------------------------------------------------------
    # EN            | RESET                                                            | 10.0k PULLUP PCB     |                                     |
    # GPIO0         | STRAPPING    | OK!   | OK!    |     | OK  | OK            |      | 10.0k PULLUP         | PULLUP    | PULLDOWN | PWM          | LOW
    # GPIO01 *      | TX           | OK!*1 | OK     |     | OK  | OK            |      |                      |           |          | HIGH         |            | CONNECTED CH340C
    # GPIO02 *      | STATUS LED   | OK    | OK     |     | OK  | OK            |      | INTERNAL PULLDOWN    | PULLUP    |          | HIGH         |            | LED OR PULLUP 10k
    # GPIO03 *      | RX           | OK    | OK!*1  |     | OK  | OK            |      |                      |           |          | HIGH         |            | CONNECTED CH340C
    # GPIO04        |              | OK    | OK     |     | OK  | OK            |      | INTERNAL PULLDOWN    |           |          |              |
    # GPIO05 *      | STRAPPING    | OK    | OK!    |     | OK  | OK            |      | INTERNAL PULLUP      |           |          | PWM          | LOW
    # 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   |                      |           |          | HIGH         |
    # GPIO12        | STRAPPING    | OK!*3 | OK     |     | OK  | OK            |      |                      |           |          | LOW          | HIGH
    # GPIO13        |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO14        |              | OK    | OK     |     | OK  | OK            |      |                      |           |          | PWM          |
    # GPIO15        | STRAPPING    | OK!   | OK!    |     | OK  | OK            |      |                      | PULLDOWN  |          | PWM          | HIGH
    # GPIO16 *      | PSRAM*4      | OK    | OK     |     | OK  | OK            |      |                      |           |          | PWM          |
    # GPIO17 *      | PSRAM*4      | OK    | OK     |     | OK  | OK            |      |                      |           |          | PWM          |
    # GPIO18        |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO19 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |

    # GPIO21 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO22 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO23 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |

    # GPIO25 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO26        |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO27 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |

    # GPIO32 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |
    # GPIO33 *      |              | OK    | OK     |     | OK  | OK            |      |                      |           |          |              |

    # GPIO34 *      |              | OK    |        | OK  |     |               |      |                      |           |          |              |
    # GPIO35 *      |              | OK    |        | OK  |     |               |      |                      |           |          |              |
    # GPIO36 *      | VP           | OK*5  |        | OK  |     |               |      |                      |           |          |              |
    # GPIO39 *      | VN           | OK*5  |        | OK  |     |               |      |                      |           |          |              |

    # * Connected on this project
    # *1 Disable hardware uart. logger baud_rate: 0
    # *2 recommended I2C
    # *3 May damage flash if low at boot on 1.8V flash chips
    # *4 GPIO 16 & 17 are usually connected to the SPI flash and PSRAM. These do show some activity during boot to detect the presence of PSRAM. For example GPIO 17 may still show some high frequency signal until it is specifically set to a high or low output state. When PSRAM is present, these pins should not be used.
    # *5 GPIO 36 & 39 should not be used for interrupts when also using ADC or WiFi and Bluetooth. These pins are on some boards labelled as: 
    #    The internal Hall sensor in the ESP32 is connected to these two pins.
    #    The Hall Sensor uses channels 0 and 3 of ADC1. Do not configure these channels for use as ADC channels when also reading from the Hall sensor.
    # *6 
    # GPIO08 and GPIO09 pulldown invalid on boot
    # Current draw 12mA max per GPIO
    # * used on project

 # ----- LEDS -----
  # Modul: Status led
   # Specification: 1x red led
   # Circuit: 10Ω resistor to GPIO
   # Power consumption: 15mA
  status_led: GPIO02
  # Modul: Spotlight not connected
   # Specification: 8x high brightness white leds
   # Circuit: 15Ω resistor to 5V / switching whit NPN Darlington TIP122: Gate - 220Ω GPIO / Gate-Source 10kΩ pulldown
   # Power consumption: 200mA (1pic = 3.3V 25mA)
  # spotlight: GPIO26

 # ----- SMOKE SENSOR -----
 # ----- OLD SENSOR -----
  # Module: MQ-2 Smoke and Gas Sensor
   # Specification: Voltage 5V / Load resistance 20kΩ / Heater resistance   33Ω ± 5% / Heating consumption  <800mw / Sensing Resistance 10 KΩ ~ 60 KΩ / Concentration Range 200 ~ 10000ppm / Preheat Time   Over 24 hour
   # Power consumption: preheat 135mA / standby 
   # Settings: time heating and measure min. 100s
   # RL replace resistor 1kΩ to 2kΩ
   # https://circuitdigest.com/microcontroller-projects/arduino-smoke-detector-on-pcb-using-mq2-gas-sensor
   # First stable value after 90s
  #mq2_pin: GPIO39 # SVN
  # Calibrate:
  # Look datasheet and MQ-2 Gas Sensor Sensitivity Characteristics in Graph:
   # https://thestempedia.com/tutorials/interfacing-mq-2-gas-sensor-with-evive/
   # The graph tells us the concentration of a gas in part per million (ppm) according to the resistance ratio of the sensor (RS/R0).
    # RS is the resistance of the sensor that changes depending on the concentration of gas.
    # R0 is the resistance of the sensor at a known concentration without the presence of other gases, or in the fresh air.

    # RS = (Vin - Vout) / Vout

   # After 15 min. ready "MQ2 - R0" value and replace ro value
  #r0_value: "1.565"

   # Calculating PPM for a particular gas
   # Analyze the graph:

    # - The scale of the graph is log-log. This means that in a linear scale, the behavior of the gas concentration with respect to the resistance ratio is exponential.
    # - The data for gas concentration only ranges from 200 ppm to 10000 ppm.
    # - Even though the relation between resistance ratio and gas concentration may seem linear, in reality, it is not.

   # First of all, we will treat the lines as if they were linear. This way we can use one formula that linearly relates the ratio and the concentration. 
   # By doing so, we can find the concentration of a gas at any ratio value even outside of the graph’s boundaries.
   # The formula we will be using is the equation for a line, but for a log-log scale. The formula for a line is:

   # Math:
    # y: Y value              y = mx + b   
    # x: X value              x = 10 ^ {[log(y) - b] / m}
    # m: Slope of the line    m = log(y/y0) / log(x/x0)
    # b: Y intercept          b = log(y) - m*log(x)

    # For a log-log scale, the formula looks like this:  
    #  log(y) = m*log(x) + b  

    # Measure Smoke and CO calculate a defines in the sensor field

 # ----- NEW SENSOR -----
  # Module: MQ-2 Smoke and Gas Sensor
   # Specification: Voltage 5V / Load resistance 20kΩ / Heater resistance   33Ω ± 5% / Heating consumption  <800mw / Sensing Resistance 10 KΩ ~ 60 KΩ / Concentration Range 200 ~ 10000ppm / Preheat Time   Over 24 hour
   # Power consumption: preheat 135mA / standby 
   # Settings: time heating and measure min. 100s
   # https://circuitdigest.com/microcontroller-projects/arduino-smoke-detector-on-pcb-using-mq2-gas-sensor
   # First stable value after 90s
   # circuit output signal when the sensor is shifted from clean air to carbon monoxide (CO) or CH4, output signal 
   # measurement is made within one or two complete heating period (2.5 minute from high voltage (60s - 5V) to low voltage (90s - 1.4V)).

  mqx_pin: GPIO39 # SVN
  # Calibrate:
  # Look datasheet and MQ-9 Gas Sensor Sensitivity Characteristics in Graph:
   # https://thestempedia.com/tutorials/interfacing-mq-2-gas-sensor-with-evive/
   # The graph tells us the concentration of a gas in part per million (ppm) according to the resistance ratio of the sensor (RS/R0).
    # RS is the resistance of the sensor that changes depending on the concentration of gas.
    # R0 is the resistance of the sensor at a known concentration without the presence of other gases, or in the fresh air.

    # RS = (Vin - Vout) / Vout

   # After 15 min. ready "MQ2 - R0" value and replace ro value
  r0_value: "2.732"

   # Calculating PPM for a particular gas
   # Analyze the graph:

    # - The scale of the graph is log-log. This means that in a linear scale, the behavior of the gas concentration with respect to the resistance ratio is exponential.
    # - The data for gas concentration only ranges from 200 ppm to 10000 ppm.
    # - Even though the relation between resistance ratio and gas concentration may seem linear, in reality, it is not.

   # First of all, we will treat the lines as if they were linear. This way we can use one formula that linearly relates the ratio and the concentration. 
   # By doing so, we can find the concentration of a gas at any ratio value even outside of the graph’s boundaries.
   # The formula we will be using is the equation for a line, but for a log-log scale. The formula for a line is:

   # Math:
    # y: Y value              y = mx + b   
    # x: X value              x = 10 ^ {[log(y) - b] / m}
    # m: Slope of the line    m = log(y/y0) / log(x/x0)
    # b: Y intercept          b = log(y) - m*log(x)

    # For a log-log scale, the formula looks like this:  
    #  log(y) = m*log(x) + b  

    # Measure Smoke and CO calculate a defines in the sensor field

 # ----- REDUCER CONSUMPTION -----
  # Module: LaskaKit Bat-Boost 5V 0.6A Chiptron
   # Chip: DIO6605B
   # Specification: Voltage in 2.7 ~ 4.5V out fixed 5V / current max 0.6A / frequency: 1.2MHz / efficiency 95% / stadby current: 1μA, quiescent current: 55 / protection: overtemperature; Working temperature -40 ~ 85 °C / Logic EN pin: 1.8V

  # "Settings: time heating and measure min 3min delay measure (10x per day)"
   # delay measure and minimal consumption battery: MQ9 CO sensor
  reducer_pin: GPIO27

 # ----- TEMPERATURE / HUMIDITY / PRESSURE SENSORS -----
  # Module: Dallas DS18B20
   # Circuit: 4.7k resistor data pin to VCC
   # Power consumption: 50μA
   # Measure: Solar panel and Battery
  dallas_pin: GPIO23
   # UPDATE AFTER BOOT: 1s

  # Module: BME280 - pressure / humidity / temperature (ALT. DHT21 AM2301 750μA; BMP280)
   # Specifications: Voltage: 1.8 ~ 5V / Operational Range: Temperature: -40 ~ +85°C Humidity: 0~100% Pressure: 300~1100 hPa / Accuracy: Temperature: +-1°C Humidity: +-3% Pressure: +-1Pa
   # Circuit: Interface: I2C address: SDO LOW : 0x76 (SDO HIGH: 0x77)
   # Power consumption: 0.4mA
   # UPDATE AFTER BOOT: 1s /if solar panel > 30°C 15s

  # Module: SENSIRION SHT45 - humidity / temperature
   # Specifications: Voltage: 1.08 ~ 3.6V / Operational Range: Temperature: -40 ~ +125°C Humidity: 0~100% / Accuracy: Temperature: +-0.1°C Humidity: +-1%
   # Circuit: Interface: I2C address: 0x44
   # Power consumption: Idle: 1.0μA / Measure: 500μA / Heater max 200mW

 # ----- FAN RADIATION SHIELD -----
  # Module: 5V Fan 600rpm 50mm (low consumption)
   # Specification: Voltage 5V / Consmption max. 150mA / 600RPM
   # Power consumption: high speed: 150mA / normal speed 100mA / low speed 70mA
   # Circuit: FAN PWM control / switching whit NPN Darlington TIP122: Gate - 220Ω GPIO / Gate-Source 10kΩ pulldown
  fan_pwm_pin: GPIO19

 # ----- RAIN SENSORS -----
  # Module: MS-WH-SP-RG rain gauge
   # Specifications: volume 0.2794 l
   # Circuit: VCC-sensor(reed switch)sensor-GPIO-10kΩ pulldown-GND
   # Features additional: wake up pin
  rain_gauge: GPIO25

   # UPDATE AFTER BOOT: 50kΩ = 10s / < 50kΩ = 30s

  # OLD Module: MH-RD Raindrops
   # Circuit: GND and ADC pin
  # NEW Module: HD-83 Raindrops
   # Specifications: Gold sinking process for corrosion resistance / 1MM ultra-fine spacing / Double sided design / Ruler: 56 * 38 * 1.2mm
   # Circuit: GND and ADC pin
   # Consumption: standby 0μA / dry 1.4μA / full wet 10mA
  rain_drop: GPIO34
   # increasing the lifetime of raindrops module
   # Circuit: GPIO-ADCraindrops 10k resistor - GPIO turn on measure ADC pin
  raindrop_switch: GPIO5
   # Variabiles
  resistor_value: "9.9kOhm"   # rain drop resistor
  measure_dry: "10s" # In dry mode
  measure_wet: "30s" # In wet mode / Must be large enough not to damage the tracks prematurely, but small enough to be reactive enough.

 # ----- CO2 SENSOR -----
  # Module: MHZ19 Intelligent Infrared CO2 Module
   # Specifications: Voltage 3.6 ~ 5.5V / Average current < 18 mA /  / Preheat time 3 min / Reponse Time T90 < 60s / Working temperature 0 ~ 50 °C Working humidity 0 ~ 95% RH (No condensation) / Lifespan > 5 years
   # Circuit: Interface UART level 3.3 V
   # Power consumption: preheat 85mA / standby 9mA / pwm heating 90mA (cycle 5-6s 24°C)
   # UPDATE AFTER BOOT: 50s

 # ----- PARTICULATE MATTER SENSOR -----
 # ----- OLD SENSOR -----
  # Module: IKEA VINDRIKTNING Particulate Matter Sensor with PM1006 pm 2.5 (whitout original mcu board)
   # Specifications: Voltage working 5V +-0.2 / Range 0 ~ 1000μg/m³ / Working temperature -20 ~ 75 °C Working humidity 0 ~ 95% RH (No condensation)
   # Circuit: Interface UART level 4.5 V baude rate 9600 connected level-shifter reverse TX RX.
   # Consumption: standby 7.6mA
  # Module: original IKEA VINDRIKTNING Fan 5V
   # Circuit: add protect diode
   # Consumption: 30mA
   # UPDATE AFTER BOOT: 90s + 5x measure filter 5s = 95s

 # ----- NEW SENSOR -----
  # Module: SENSIRION SPS30 Particulate Matter Sensor
   # id: 5224221
   # Serial Number: 'FCBAC51BF0DCABAC'
   # Specifications: Voltage working 4.5 ~ 5.0V / Range 0 ~ 1000μg/m³ / Working temperature -10 ~ 75 °C Working humidity 0 ~ 95% RH (No condensation) / Laser Class 1 660nm /Lifetime 24h/d >10 years
   # Air direction: Fan Out
   # Pinout:
    # Left reading (logo green top) 
    # ---------------------------
    # PINS:  5  |  4  |  3  |  2  |  1
    # NAME: GND | SEL | SCL | SDA | VIN
    # ---------------------------
   # PM Number concentration size range: 
    # PM0.5: 0.3 ~ 0.5 μm
    # PM1.0: 0.3 ~ 1.0 μm
    # PM2.5: 0.3 ~ 2.5 μm
    # PM4.0: 0.3 ~ 4.0 μm
    # PM10 : 0.3 ~ 10.0 μm
   # Auto cleaning: 165hours 10s max fan
   # Circuit: I2C address: 0x69 (SEL PIN TO GND)
   # Consumption: sleep: 50µA idle: 360µA measure: 1s 65mA measure fan start: 80mA

   # AQI (Air quality index)
    # AQI       | Level           | PM2.5 (μg/m³) | PM10 (μg/m³)
    # ----------------------------------------------------------
    # 0   - 50  | Good            | 0     - 12    | 0   - 54
    # 51  - 100 | Moderate        | 12.1  - 35.4  | 55  - 154
    # 101 - 150 | Unhealthy for   | 35.5  - 55.4  | 155 - 254
    #             sensitive group 
    # 151 - 200 | Unhealthy       | 55.5  - 150.4 | 255 - 354
    # 201 - 300 | Very unhealthy  | 150.5 - 250.4 | 355 - 424
    #     > 301 | Hazardous       |       > 250.5 |     > 425
    # ----------------------------------------------------------

 # ----- SUN SENSORS -----
 # OLD MODULE
  # Module: BH1750 GY-302 lux meter
   # Specifications: 3V ~ 5V / Range:  1 ~ 65 535 lx
   # Circuit: Interface: I2C address: 0x23
   # Consumption: normal 4.4mA
   # http://wiki.sunfounder.cc/index.php?title=GY-302_BH1750_Digital_Light_Intensity_Module

  # Module: GYML8511 UV uv light uva uvb ultraviolet 
   # Specifications: 3V – 5V / Photodiode sensitive to UV-A and UV-B
   # Circuit: ADC
   # Consumption: normal 0.455mA
   # http://wiki.sunfounder.cc/index.php?title=GYML8511_UV_Sensor
  uv_pin: GPIO35 

 # NEW MODULE
  # Module: LTR-390UV Lux and UVA sensor
   # Specifications: Operating voltage: 1.7 ~ 3.6V (max 4.0V) / Operating temperature: - 40 ~ 80 °C / Temperature compesation / Error ALS 25% UV 20%
   # Wavelenght: UVA(400 ~ 320nm) and UVB(320 ~ 290nm) 300-350nm / ALS 500 ~ 620nm
   # Power consumption: Measure: 400μA Standby: 20μA Sleep: 1μA
   # Circuit: I²C address: 0x53
   # Calculate:
    # Lux = ((0.6 * als) / (gain * int)) * wfac
     # als  = ambient light count  On sensor values
     # gain = X3                   Adjusts the sensitivity of the sensor. A larger value means higher sensitivity. See table below for details. 
     # int  = 1                    Is the integration time in 100s of ms and is tied to the resolution
     # wfac = 1.0                  Window correction factor. Use larger values when using under tinted windows. Default is 1.0, must be >= 1.0.
    # UV index = UV / sensitivity * wfac
     # UV = UV sensor count        On sensor values
     # sensitivity = 95            has the value 2300 and is the sensor’s count per UVI https://www.youtube.com/watch?v=VUd6NGAcs4w
     # wfac = 1.0                  Window correction factor. Use larger values when using under tinted windows. Default is 1.0, must be >= 1.0.

   # 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

 # ----- WIND SENSORS -----
  # Module: WH-SP-WS01 wind speed anemometer
   # Circuit: 10k resitor GPIO to VCC and GPIO 104 capacitor to GND
  wind_speed_pin: GPIO32
   # Variabiles for calculating wind speed:    
  pulse_revolution: "2" # Number of pulses by revolution 
  radius: "0.09"        # Blade circle radius in meters
  math_pi: "3.1416"     # π
  factor: "1.18"        # Calibration factor compensate friction (you can adjust it)

  # Module: WH-SP-WD wind direction
   # Resistors table: 
   # ANGLE(°)   RESISTOR (kΩ)
   # ---------------------------
   #   0.0      33.00
   #  22.5       6.57
   #  45.0      8.20
   #  67.5      0.891
   #  90.0      1.00
   # 112.5      0.688
   # 135.0      2.20
   # 157.5      1.41
   # 180.0      3.90
   # 202.5      3.14
   # 225.0     16.00
   # 247.5     14.12
   # 270.0    120.00
   # 292.5     42.12
   # 315.0     64.90
   # 337.5     21.88
   # ---------------------------
   # Circuit: 10k resitor GPIO to VCC and GPIO 104 capacitor to GND
  wind_dir_pin: GPIO33

 # ----- RADIATION SENSORS -----
  # Module: Geiger-Counter-RadiationD-v1.1-CAJOE
   # Specifications: Voltage 4.5 ~ 6V / measure range 20mR/h~120mR/h γ X-ray and 100 ~ 1800 degeneracy/min · cm2 soft β For radiation
   # Geiger Muller tube: mounted J321 (360 - 440 V, dimension 10x86mm, lifespan  1 × 109 pulses)
   # Circuit:  on esp32 only VP-GPIO36 or VN-GPIO39 high impedance pin (connected P3 header 5V/GND/VIN(pulse pin))
   # Consumption: 6.66mA (reducer unmount 2x NE555 timer IC1 and U80 header =  speaker and led)
   # https://esphome.io/cookbook/geiger-counter.html
   # https://www.youtube.com/watch?v=K28Az3-gV7E
  geiger_pin: GPIO36 # SVP connected to module to VIN pin

  # Calculate correct value:
  # Alert value >0.81uSv/h >100cpm
  # Tube background:
   # SBM-20 32
   # M4011  32
   # calculate tube m4011, mounted J321
   # Gamma Sensitivity Ra226 (cps/mR/hr) 27 (SBM-20 tube = 29, J305 = 44)
   # Gamma Sensitivity Co60 (cps/mR/hr) 22
   # (27+22)/2=24.5
   # Multiply counts per second by 60 to get CPM: 24.5 x 60 = 1470 CPM
   # absorption rate to be use is 8.77 which I understand is for air
   # So finally the 1530 CPM is divided by the absorption rate of 8.77 to get ratio between CPM and uSv: 1470 / 8.77 = 167.617
   # inverse 0.00596598639455782312925170068027
   # https://sites.google.com/site/diygeigercounter/technical/gm-tubes-supported (method 2)

 # ----- CHARGING -----
  # Module: Solar panel 18V
   # Specification: 18V 25W   (50W aliexpress :D)
   # Type: Monocrystalline 
   # Solar panel dimension
  width_p: "0.315" # m
  height_p: "0.480" # m

  # Module: Charger Step Down XL4015 E1 
   # Specification: Voltage in: 4V ~ 37V out: 1.25V ~ 36V 5A efficiency: ~96% (current standby 20mA) / ABOVE INPUT HEADER FIRST current regulator clockwise increase, second voltage regulator clockwise increase
   # Setup: OUT 12.9V/1A (connected protect diode SS34: Voltage Forwarde 0.5V = 12.4V to battery pack)

 # ----- BATTERY -----
  # --- old version battery ---
  # Battery: 12V 9Ah 20h max input 13.7V/1.0A (sealed rechargeable acid battery EMOS model OT 9-12)
  # Theoretical battery life: current consumption 300mA / Life: 8 Days

  # --- new version battery ----
  # Battery: 9x 18650 3.7V/2500mAh 
   # Circuit: 3x parallel 3x series 12.4V/7.5Ah out.
   # Protection 1: BMS 3S 20A hw-375 rev2.3
    # Specification: overcharge 4.25V / discharge 2.5V /overcurrent 22A / Working temperature -40- 85 °C
    # Consumption: standby: 20μA
   # Protection 2 (OLD): Polarized power relay latching relay (Signal two coil) ADW1203HL 3V3 16A protect two diode SS110 and 2xNPN BC337 10kΩ pulldown and 100Ω to GPIO
   # Protection 2: set power supply to 8.0V in change to when battery is low.

    # Specification: battery < 9.4V (3.13V one battery) switch to power supply / if current solar > current mcu switch to battery
  #supply_off_pin: GPIO04
  #supply_on_pin: GPIO18
  capacite_battery: "7.5"    # 7.5Ah
  efficiency_charging: "1.3" # efficiency of memory and battery characteristics (20-60%)

 # ----- MEASUREMENT OF ELECTRICITY -----
  # Module: INA3221 3CH DC current sensor black board
   # Specification: Voltage in 26V / Voltage operating 2.7 - 5.5V / Working temperature -40 ~ 125 °C / shunt resistor 0.1Ω max current I=V/R; I = 0.1638 mV / 0.1Ω = 1.638 A max
   # Circuit: Interface: I2C address: 0x40
   # Consumption: standby 350μA

 # ----- LDO REGULATORS -----
  # Module: step down DD2712SA 5V (alt. OKI-78SR-5/1.5)
   # Specification: Voltage in 6.5 ~ 27V out fixed 5V / current max 2.5A; short 3.5A / frequency: 900kHz / efficiency 75 ~ 92% / stadby current: 250μA / protection: overtemperature; undervoltage; short-circuit; Working temperature -20 ~ 85 °C
  # Module: holtek HT7833 (2x = ESP32cam and ESP32 main mcu)
   # Specification: Voltage in 0-8 out fixed 3.3V 2% / max voltage drop 360mV / current max 0.5A / current standby 0.22mA (datasheet standby current 4μA) / protection: overtemperature; current limiting

#-------------------------------------------
# VARIABILES
#-------------------------------------------
# Update intreval for all sensors
  update_time: 60s 

#-------------------------------------------
# PROTOCOLS
#-------------------------------------------
 # ----- PROTOCOLS PINS -----
  # i2c
  i2c_sda_pin: GPIO21
  i2c_scl_pin: GPIO22
#  i2c_enable_pin: GPIO04
  # uart
  uart_rx_pin: GPIO17
  uart_tx_pin: GPIO16
#  uart2_rx_pin: GPIO14
#  uart2_tx_pin: GPIO13

 # ----- PROTOCOLS SETTINGS -----
uart:
#  - id: uart2 # ikea vindriktining pm1006
#    rx_pin: "$uart2_rx_pin"
#    tx_pin: "$uart2_tx_pin"
#    baud_rate: 9600

  - id: uart_typ1 # mhz-19 co2
    rx_pin: "$uart_rx_pin"
    tx_pin: "$uart_tx_pin"
    baud_rate: 9600

i2c:
  sda: "$i2c_sda_pin"
  scl: "$i2c_scl_pin"
  scan: True
  frequency: 100kHz

dallas:
  - pin: "$dallas_pin"
    update_interval: $update_time

#-------------------------------------------
# CUSTOM COMPONENT
# Custom SPS30 component
# https://github.com/esphome/feature-requests/issues/2385
#-------------------------------------------
external_components:
  - source: custom_component

#-------------------------------------------
# ESP - MAIN SETTINGS
#-------------------------------------------
esphome:
  name: weather-station
  project:
    name: "studiotiim.weather_station"
    version: 2023.09.3.2.2
  platformio_options:
    board_build.f_cpu: 160000000L # set cpu clock 160mhz
  on_boot:
#    - priority: 1200
#      then:
        #- lambda: |-
        #    pinMode(18, OUTPUT);
        #    digitalWrite(18, HIGH);
        #    delay(300);
#        - switch.turn_on: i2c_enable
#        - delay: 300ms

    #- priority: 600
    #  then:
    #    lambda: |-
    #      Wire.begin();
    #      delay(100);

    - priority: 900
      then:
        # Find how to esp wake up (deep sleep cycle or rtc pin wake up)
        # Rain-gauge add one measuring when is wake up whit gauge pin
        lambda: |-
          id(wakeup_pin) = ((log(esp_sleep_get_ext1_wakeup_status()))/log(2));;
          esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); //INTERNAL PD

    - priority: 600
      then:
        - lambda: id(sleep_prevent).publish_state(false); # on boot send template state false

    - priority: -200 # when everithing should by inicialized
      then:
        - switch.turn_on: res_bias # turn on resistance on raindrop sensor
        # - if: 
            # condition:
            #   mqtt.connected: # send online state when mqtt is connected to wifi and server
            #then:
        - text_sensor.template.publish:  # Send online state when wifi is connected 
            id: online_s
            state: "Online"
    - priority: -400  # delay so that the device is not overloaded at startup
      then:
        - delay: 2s
        - switch.turn_on: switch_reducer # turn on measure sps30 gaiger and mq2 sensor less load when booting
        - text_sensor.template.publish: # second send online 
            id: online_s
            state: "Online"

  on_shutdown: # send offline state when mcu power off or go to deep sleep
    - then:
        - text_sensor.template.publish:
            id: online_s
            state: "Offline"
        - logger.log: Shutdown Called
        #- switch.turn_off: i2c_enable
        # reduce leaking current when enable deep sleep
        - lambda: |-
            esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
            esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
            esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF); 
            // This config is large power consumption +80uA
            //gpio_deep_sleep_hold_en();
            //adc_power_release();
            //gpio_hold_en((gpio_num_t) 12);
            // i2c enable high impedancy
            //pinMode(21, INPUT);
            //pinMode(22, INPUT);

    - priority: -801.0 # tested more settings the server does not always receive the value
      then:
        - component.update: up_time
        - text_sensor.template.publish:
            id: online_s
            state: "Offline"
        - switch.turn_off: res_bias

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:
  level: DEBUG

#-------------------------------------------
# MQTT
#-------------------------------------------
mqtt:
  broker: '192.168.31.212'
  username: !secret mqtt_username
  password: !secret mqtt_password
  discovery: true

  # online first message
  birth_message:
    topic: $device_name/status_on
    payload: online
  # drop connected message
  will_message:
    topic: $device_name/status_unaiavalable
    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: sleep_component
        - 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: sleep_component

ota:
  password: !secret ota_pass

wifi:
  manual_ip:
    static_ip: 192.168.31.59
    gateway: 192.168.31.1
    subnet: 255.255.255.0
  #enable_on_boot: False # future features
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  ap:
    ssid: "$device_name Hotspot"
    password: "passweatherstation"

captive_portal:

#-------------------------------------------
# DEEP SLEEP COMPONENT
#-------------------------------------------
deep_sleep:
  run_duration: 100s # all sensor send state (in time 100s)
  sleep_duration: 13min
  #sleep_duration: 2min # testing time
  id: sleep_component
  esp32_ext1_wakeup: 
    pins: 
      number: $rain_gauge
      allow_other_uses: true
    mode: ANY_HIGH 
  # Only pins 0, 2, 4, 12, 13, 14, 15, 25, 26, 27, 32, 33, 34, 35, 36, 37, 38, 39 support wakeup.
  #wakeup_pin_mode: KEEP_AWAKE # when is high no deepsleep enter

#-------------------------------------------
# SCRIPTS
#-------------------------------------------
script:
#-------------------------------------------
# Deep sleep script allow
# prevent deep sleep when raindrop detected
# if raindrop sensor is wet, it's probably raining, a rain gauge can record the amount of water
# after raindrop sensor dry go to deep sleep after 100s
#-------------------------------------------
  - id: sleep_script 
    mode: single
    then:
      if:
        condition:
          binary_sensor.is_off: sleep_prevent
        then:
          - logger.log: 
              format: "ENTER DEEPSLEEP + 85s"
              level: warn
          - delay: 85s
          - text_sensor.template.publish:
              id: online_s
              state: "Offline"
          - component.update: up_time
          - logger.log: 
              format: "BEGIN DEEPSLEEP + 5s"
              level: warn
          - delay: 5s
          - if:
              condition:
                - sensor.in_range:
                    id: bat_volt
                    below: 10.0
              then:
                - lambda: id(sleep_component).set_sleep_duration(1680000);
              else:
                - lambda: id(sleep_component).set_sleep_duration(600000);
          - deep_sleep.enter: sleep_component

#-------------------------------------------
# GLOBALS
#-------------------------------------------
globals:
#-------------------------------------------
# RESTORE VALUE BME280 module
#-------------------------------------------
  - id: temp_g
    type: float
    restore_value: yes
    initial_value: '20.0'

  - id: humi_g
    type: float
    restore_value: yes
    initial_value: '50.0'

  - id: pres_g
    type: float
    restore_value: yes
    initial_value: '1000'

#-------------------------------------------
# RESTORE VALUE power state (battery/power supply switch)
#-------------------------------------------
#  - id: power_g
#    type: bool
#    restore_value: yes
#    initial_value: "false"

#-------------------------------------------
# RESTORE VALUE esp_sleep_get_ext1_wakeup_status
# Rain-gauge add one measuring when is wake up whit gauge pin
#-------------------------------------------
  - id: wakeup_pin
    type: uint64_t
    restore_value: no
    initial_value: '0'

....... sensors are defined below

Anything in the logs that might be useful for us?

INFO ESPHome 2023.12.5
INFO Reading configuration /config/esphome/weather-station.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing weather-station (board: esp32dev; framework: arduino; platform: platformio/espressif32@5.4.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 160MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.0.1
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.1.0
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- Wire @ 2.0.0
|-- ArduinoJson @ 6.18.5
Compiling .pioenvs/weather-station/src/main.cpp.o
Compiling .pioenvs/weather-station/FrameworkArduino/esp32-hal-adc.c.o
Compiling .pioenvs/weather-station/FrameworkArduino/esp32-hal-bt.c.o
Compiling .pioenvs/weather-station/FrameworkArduino/esp32-hal-cpu.c.o
during GIMPLE pass: *diagnose_omp_blocks
/data/cache/platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-adc.c: In function '__analogSetClockDiv':
/data/cache/platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-adc.c:50:6: internal compiler error: Illegal instruction
 void __analogSetClockDiv(uint8_t clockDiv){
      ^~~~~~~~~~~~~~~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
*** [.pioenvs/weather-station/FrameworkArduino/esp32-hal-adc.c.o] Error 1
during GIMPLE pass: *diagnose_omp_blocks
/data/cache/platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-bt.c: In function 'btInUse':
/data/cache/platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-bt.c:19:6: internal compiler error: Illegal instruction
 bool btInUse(){ return true; }
      ^~~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
*** [.pioenvs/weather-station/FrameworkArduino/esp32-hal-bt.c.o] Error 1
during GIMPLE pass: *diagnose_omp_blocks
/data/cache/platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-cpu.c: In function 'addApbChangeCallback':
/data/cache/platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-cpu.c:91:6: internal compiler error: Illegal instruction
 bool addApbChangeCallback(void * arg, apb_change_cb_t cb){
      ^~~~~~~~~~~~~~~~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
*** [.pioenvs/weather-station/FrameworkArduino/esp32-hal-cpu.c.o] Error 1
========================= [FAILED] Took 55.52 seconds =========================

Additional information

No response

tiimsvk commented 8 months ago

reinstallation esphome fix this problem