hi,
I have a ESP8266 and a SR04 ultrasonic sensor, but i can’t get them to work.
My Conections
5v - Vin
RX | Trig - D5
TX | Echo - D6
GND - GND
My Code:
esphome:
name: esphome-web-887b4a
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-887B4A"
password: "YQA708yGImRg"
captive_portal:
# Water Level Sensor
sensor:
- platform: wifi_signal
name: "WiFi Signal Sensor"
update_interval: 60s
- platform: ultrasonic
trigger_pin: GPIO14
echo_pin: GPIO12
unit_of_measurement: "%"
icon: "mdi:water-percent"
accuracy_decimals: 0
update_interval: 300000ms
name: "Sweet Water storage"
filters:
- lambda: return (1-((x-.10)/1.10))*100;
- filter_out: nan
- platform: ultrasonic
trigger_pin: GPIO14
echo_pin: GPIO12
update_interval: 20000ms
name: "Remaining Water in Tank"
unit_of_measurement: "l"
accuracy_decimals: 0
filters:
- lambda: return (1-((x-.10)/1.10))*1000;
- filter_out: nan
And get this log
INFO Reading configuration /config/esphome/esphome-web-887b4a.yaml...
INFO Starting log output from esphome-web-887b4a.local using esphome API
INFO Successfully connected to esphome-web-887b4a.local
[16:51:05][I][app:102]: ESPHome version 2022.10.0 compiled on Oct 24 2022, 16:40:19
[16:51:05][C][wifi:502]: WiFi:
[16:51:05][C][wifi:360]: Local MAC: E8:9F:6D:88:7B:4A
[16:51:05][C][wifi:361]: SSID: 'POCO F3_plus_2'[redacted]
[16:51:05][C][wifi:362]: IP Address: 192.168.1.40
[16:51:05][C][wifi:363]: BSSID: C0:9F:E1:8A:1D:4F[redacted]
[16:51:05][C][wifi:365]: Hostname: 'esphome-web-887b4a'
[16:51:05][C][wifi:367]: Signal strength: -50 dB ▂▄▆█
[16:51:05][C][wifi:371]: Channel: 2
[16:51:05][C][wifi:372]: Subnet: 255.255.255.0
[16:51:05][C][wifi:373]: Gateway: 192.168.1.1
[16:51:05][C][wifi:374]: DNS1: 213.228.128.99
[16:51:05][C][wifi:375]: DNS2: 213.228.129.67
[16:51:05][C][logger:275]: Logger:
[16:51:05][C][logger:276]: Level: DEBUG
[16:51:05][C][logger:277]: Log Baud Rate: 115200
[16:51:05][C][logger:278]: Hardware UART: UART0
[16:51:05][C][ultrasonic.sensor:045]: Ultrasonic Sensor 'Sweet Water storage'
[16:51:05][C][ultrasonic.sensor:045]: State Class: 'measurement'
[16:51:05][C][ultrasonic.sensor:045]: Unit of Measurement: '%'
[16:51:05][C][ultrasonic.sensor:045]: Accuracy Decimals: 0
[16:51:05][C][ultrasonic.sensor:045]: Icon: 'mdi:water-percent'
[16:51:05][C][ultrasonic.sensor:046]: Echo Pin: GPIO12
[16:51:05][C][ultrasonic.sensor:047]: Trigger Pin: GPIO14
[16:51:05][C][ultrasonic.sensor:048]: Pulse time: 10 µs
[16:51:05][C][ultrasonic.sensor:049]: Timeout: 11661 µs
[16:51:05][C][ultrasonic.sensor:050]: Update Interval: 300.0s
[16:51:05][C][ultrasonic.sensor:045]: Ultrasonic Sensor 'Remaining Water in Tank'
[16:51:05][C][ultrasonic.sensor:045]: State Class: 'measurement'
[16:51:05][C][ultrasonic.sensor:045]: Unit of Measurement: 'l'
[16:51:05][C][ultrasonic.sensor:045]: Accuracy Decimals: 0
[16:51:05][C][ultrasonic.sensor:045]: Icon: 'mdi:arrow-expand-vertical'
[16:51:05][C][ultrasonic.sensor:046]: Echo Pin: GPIO12
[16:51:05][C][ultrasonic.sensor:047]: Trigger Pin: GPIO14
[16:51:05][C][ultrasonic.sensor:048]: Pulse time: 10 µs
[16:51:05][C][ultrasonic.sensor:049]: Timeout: 11661 µs
[16:51:05][C][ultrasonic.sensor:050]: Update Interval: 20.0s
[16:51:05][C][captive_portal:088]: Captive Portal:
[16:51:05][C][mdns:100]: mDNS:
[16:51:05][C][mdns:101]: Hostname: esphome-web-887b4a
[16:51:05][C][ota:089]: Over-The-Air Updates:
[16:51:05][C][ota:090]: Address: esphome-web-887b4a.local:8266
[16:51:05][C][api:138]: API Server:
[16:51:05][C][api:139]: Address: esphome-web-887b4a.local:6053
[16:51:05][C][api:143]: Using noise encryption: NO
[16:51:05][C][wifi_signal.sensor:009]: WiFi Signal 'WiFi Signal Sensor'
[16:51:05][C][wifi_signal.sensor:009]: Device Class: 'signal_strength'
[16:51:05][C][wifi_signal.sensor:009]: State Class: 'measurement'
[16:51:05][C][wifi_signal.sensor:009]: Unit of Measurement: 'dBm'
[16:51:05][C][wifi_signal.sensor:009]: Accuracy Decimals: 0
[16:51:24][D][ultrasonic.sensor:036]: 'Remaining Water in Tank' - Distance measurement timed out!
[16:51:44][D][ultrasonic.sensor:036]: 'Remaining Water in Tank' - Distance measurement timed out!
[16:52:00][D][sensor:126]: 'WiFi Signal Sensor': Sending state -44.00000 dBm with 0 decimals of accuracy
[16:52:04][D][ultrasonic.sensor:036]: 'Remaining Water in Tank' - Distance measurement timed out!
Anyone able to help me solve the problem?
Thanks