]> www.infradead.org Git - users/dwmw2/esp32-pool.git/commitdiff
Use AtomS3 Lite for softener
authorDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 7 Aug 2024 15:12:43 +0000 (16:12 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 7 Aug 2024 15:15:59 +0000 (16:15 +0100)
softener.yaml

index ab474d1b60d1cf79a7622903d2e10e9ac956d7dc..8e6437900194e0a78e3ed3e3248e950b921d8465 100644 (file)
@@ -1,23 +1,36 @@
 #
-# https://www.aliexpress.com/item/1005004099215436.html
+# https://shop.m5stack.com/products/atoms3-lite-esp32s3-dev-kit
 #
-# GPIO23: Onboard blue LED (used to show MQTT connectivity)
-# GPIO16: Onboard relay (bathroom fan)
-# GPIO13: DHT22
+# GPIO41: Pushbutton
+# GPIO35: W2812 LED
+# GPIO1: HX711 SCK
+# GPIO2: HX711 DOUT
 
 esphome:
   name: softener
+  name_add_mac_suffix: false
+  on_boot:
+    then:
+      - light.turn_on:
+          id: led
+          red: 100%
+          green: 0%
+          blue: 0%
 
 esp32:
-  board: esp32-gateway
+  board: esp32-s3-devkitc-1
+  variant: esp32s3
   framework:
-    type: arduino
+    type: esp-idf
+    version: 5.0.2
+    platform_version: 6.3.2
 
 # Enable logging
 logger:
   level: DEBUG
 
 ota:
+  platform: esphome
   password: !secret ota_upgrade_pw
 
 external_components:
@@ -27,8 +40,14 @@ external_components:
    components: [syslog]
 
 wifi:
-  ssid: !secret wifi_ssid
-  password: !secret wifi_pw
+  power_save_mode: none
+  networks:
+    - ssid: !secret wifi_ssid
+      password: !secret wifi_pw
+      bssid: !secret wndr3800_bssid
+      priority: 1
+    - ssid: !secret wifi_ssid
+      password: !secret wifi_pw
 
 script:
     # Publish a value to Domoticz as an nvalue
@@ -85,15 +104,16 @@ script:
 #captive_portal:
 
 syslog:
-    ip_address: !secret syslog_ip
+    ip_address: !secret syslog_ipv6
 
 time:
   - platform: sntp
     id: sntp_time
     servers: !secret ntp_servers
 
-#network:
-#  enable_ipv6: true
+
+network:
+  enable_ipv6: true
 
 mqtt:
   broker: !secret mqtt_server
@@ -105,33 +125,70 @@ mqtt:
   id: mqtt_client
   on_connect:
     then:
-      - light.turn_on: blue_led
-
+      - light.turn_on:
+         id: led
+         blue: 100%
+         red: 0%
+         green: 0%
   on_disconnect:
     then:
-      - light.turn_off: blue_led
+      - light.turn_on:
+         id: led
+         blue: 0%
+         red: 100%
+         green: 0%
+
+  on_json_message:
+    - topic: domoticz/out
+      then:
+        - lambda: |-
+            int idx = x["idx"];
+            int nvalue = x["nvalue"].as<int>();
 
-light:
-  - platform: binary
-    name: "Blue LED"
-    id: blue_led
-    output: led_output
+            // ESP_LOGD("on_json_message", x["name"]);
 
-output:
-  - id: led_output
-    platform: gpio
-    pin: GPIO23
 
-switch:
+light:
+#G35=RGB WS2812C-2020
+  - platform: esp32_rmt_led_strip
+    name: Led
+    id: led
+    rgb_order: GRB
+    pin: 35
+    num_leds: 4
+    # RMT 0 channels will be occupied by IR
+    rmt_channel: 1
+    chipset: ws2812
+    restore_mode: ALWAYS_OFF
+
+#G41=Button
+binary_sensor:
   - platform: gpio
-    name: "Fan"
-    id: fan_relay
-    pin: GPIO16
+    name: Buttonw
+    id: g41button
+    pin:
+      number: GPIO41
+      inverted: true
+      mode:
+        input: true
+        pullup: true
+    filters:
+      - delayed_off: 10ms
+    # Toggle the switch when the pushbutton is pressed
+    on_press:
+      then:
+        - lambda: |-
+           ESP_LOGD("Button", "pressed");
+
 
 sensor:
   - platform: hx711
-    dout_pin: GPIO13
-    clk_pin: GPIO14
+    dout_pin:
+      number: GPIO2 # Orange
+      mode:
+        input: true
+        pullup: true
+    clk_pin: GPIO1 # Yellow
     gain: 128
     update_interval: 30s
     name: "HX711 value"