Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- esphome:
- name: ens160
- esp32:
- board: esp32doit-devkit-v1
- wifi:
- networks:
- - ssid: kkkkkk
- password: xxxxx
- - ssid: zzzzzz
- password: yyyyyyy
- # Enable logging
- logger:
- level: debug
- # Enable Home Assistant API
- api:
- # Enable over-the-air updates.
- ota:
- platform: esphome
- # Enable Web server.
- web_server:
- port: 80
- version: 1
- i2c:
- sda: 21
- scl: 22
- scan: true
- sensor:
- - platform: ens160_i2c
- eco2:
- name: "ENS160 eCO2"
- tvoc:
- name: "ENS160 Total Volatile Organic Compounds"
- aqi:
- id: ens160_air_quality_index
- name: "ENS160 Air Quality Index"
- update_interval: 10s
- address: 0x53
- compensation:
- temperature: id_temperature_sensor
- humidity: id_humidity_sensor
- - platform: aht10
- variant: AHT10
- temperature:
- id: id_temperature_sensor
- name: "Temperature"
- humidity:
- id: id_humidity_sensor
- name: "Humidity"
- update_interval: 10s
- address: 0x38
- # You need the http_request component defined
- http_request:
- id: thingspeak_request # Give it an ID
- verify_ssl: false
- interval:
- - interval: 10min
- then:
- # Use the http_request.get action provided by the component with the ID 'thingspeak_request'
- - http_request.get:
- id: thingspeak_request # Optional if you only have one http_request component
- url: !lambda |-
- // Use esphome::to_string for simpler float-to-string conversion
- std::string temp_str = esphome::to_string(id(id_temperature_sensor).state);
- std::string hum_str = esphome::to_string(id(id_humidity_sensor).state);
- std::string airq_str = esphome::to_string(id(ens160_air_quality_index).state);
- // Construct the URL string
- std::string url = "https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxxxx";
- url += "&field3=" + temp_str; // Assuming field3 is temperature
- url += "&field4=" + hum_str; // Assuming field4 is humidity
- url += "&field5=" + airq_str; // Assuming field5 is AirQuality
- ESP_LOGD("thingspeak", "ThingSpeak URL: %s", url.c_str()); // Optional: Log the URL for debugging
- return url;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement