commit 8501474b84961fb7a8e666aee3868fb07d6c5e0d Author: Hendrik Langer Date: Fri Oct 22 12:19:35 2021 +0200 esphome test diff --git a/esp32weatherstation2.yaml b/esp32weatherstation2.yaml new file mode 100644 index 0000000..e0a986e --- /dev/null +++ b/esp32weatherstation2.yaml @@ -0,0 +1,163 @@ +esphome: + name: esp32weatherstation2 + platform: ESP32 + board: lolin_d32_pro + includes: + - veml6075_custom_sensor.h + libraries: + - "https://github.com/adafruit/Adafruit_VEML6075" + - "https://github.com/adafruit/Adafruit_BusIO" + platformio_options: + lib_ldf_mode: chain+ + project: + name: "xd0.esp32weatherstation2" + version: "0.0.1" + +# Enable logging +logger: +# level: VERY_VERBOSE + +# Enable Home Assistant API +api: + +ota: + password: "123456789" + +wifi: + networks: + - ssid: "ssid1" + password: "password1" + - ssid: "ssid2" + password: "password2" + power_save_mode: light + + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "Esp32Weatherstation2" + password: "supersecret" + +captive_portal: + +time: + - platform: sntp + id: sntp_time + timezone: "Europe/Berlin" + +#mqtt: +# broker: home.xd0.de +# username: tasmota-login +# password: supersecret + +i2c: + sda: 21 + scl: 22 + scan: true + +spi: + clk_pin: 18 + mosi_pin: 23 + miso_pin: 19 + +uart: + rx_pin: 15 + tx_pin: 2 + baud_rate: 9600 + +# display #250x122 pixels +font: + - file: 'fonts/slkscr.ttf' + id: font1 + size: 8 + +status_led: + pin: + number: GPIO5 + inverted: true + +display: + - platform: waveshare_epaper + cs_pin: 14 + dc_pin: 27 + reset_pin: 33 + model: 2.13in-ttgo + rotation: 90 + update_interval: 30s + full_update_every: 1 + lambda: |- + it.print(5, 6, id(font1), "Hello World!"); + it.strftime(130, 6, id(font1), "%Y-%m-%d %H:%M", id(sntp_time).now()); + it.line(0, 15, 250, 15); + if (id(temperature).state) { + it.printf(5, 40, id(font1), "Temperature: %.1f°C, Humidity: %.1f%%, Pressure: %.1fhPa", id(temperature).state, id(humidity).state, id(pressure).state); + } + +sensor: +# BME680 Temperature+Pressure+Humidity+Gas Sensor + - platform: bme680 + temperature: + name: "BME680 Temperature" + oversampling: 16x + id: temperature + pressure: + name: "BME680 Pressure" + id: pressure + humidity: + name: "BME680 Humidity" + id: humidity + gas_resistance: + name: "BME680 Gas Resistance" + address: 0x77 + update_interval: 60s +# BME280 Temperature+Pressure+Humidity Sensor + - platform: bme280 + temperature: + name: "BME280 Temperature" + oversampling: 16x + pressure: + name: "BME280 Pressure" + humidity: + name: "BME280 Humidity" + address: 0x77 + update_interval: 60s +# SDS 011 Particulate Matter Sensor + - platform: sds011 + pm_2_5: + name: "Particulate Matter <2.5µm Concentration" + pm_10_0: + name: "Particulate Matter <10.0µm Concentration" + update_interval: 5min +# BH1750 Ambient Light Sensor + - platform: bh1750 + name: "BH1750 Illuminance" + address: 0x23 + measurement_duration: 69 + update_interval: 60s +# VEML6075 UV sensor + - platform: custom + lambda: |- + auto veml6075 = new VEML6075CustomSensor(); + App.register_component(veml6075); + return {veml6075->uva_sensor, veml6075->uvb_sensor}; + sensors: + - name: "zelva UVA" + id: zelva_uva + unit_of_measurement: "mW/cm²" + accuracy_decimals: 0 + - name: "zelva UVB" + id: zelva_uvb + unit_of_measurement: "mW/cm²" + accuracy_decimals: 0 +# Example configuration entry + - platform: esp32_hall + name: "ESP32 Hall Sensor" + update_interval: 60s + - platform: ble_rssi + mac_address: 11:22:33:44:55:66 + name: "MiBand Hendrik RSSI value" + +# Example configuration entry +esp32_ble_tracker: + +#text_sensor: +# - platform: ble_scanner +# name: "BLE Devices Scanner" diff --git a/fonts/slkscr.ttf b/fonts/slkscr.ttf new file mode 100644 index 0000000..85a2037 Binary files /dev/null and b/fonts/slkscr.ttf differ diff --git a/veml6075_custom_sensor.h b/veml6075_custom_sensor.h new file mode 100644 index 0000000..d97da62 --- /dev/null +++ b/veml6075_custom_sensor.h @@ -0,0 +1,27 @@ +#include "esphome.h" +#include "Adafruit_VEML6075.h" + +class VEML6075CustomSensor : public PollingComponent, public Sensor { + public: + Adafruit_VEML6075 uv = Adafruit_VEML6075(); + + Sensor *uva_sensor = new Sensor(); + Sensor *uvb_sensor = new Sensor(); + + VEML6075CustomSensor() : PollingComponent(15000) {} + void setup() override { + Wire.begin(21, 22); + uv.begin(); + uv.setIntegrationTime(VEML6075_100MS); + } + + void update() override { + float uva = uv.readUVA(); + float uvb = uv.readUVB(); + ESP_LOGD("custom", "The value of sensor uva is: %.0f", uva); + ESP_LOGD("custom", "The value of sensor uvb is: %.0f", uvb); + publish_state(uva); + uva_sensor->publish_state(uva); + uvb_sensor->publish_state(uvb); + } +};