Hello,
I’m new to ESPHome and I try to measure the distance with the UltraSonic HC-SR4 sensor.
But I get only to wrong values in the ESPHome logs:
[12:04:05][D][ultrasonic.sensor:030]: 'Abstandssensor' - Got distance: 0.01 m
[12:04:05][D][sensor:092]: 'Abstandssensor': Sending state 0.00549 m with 2 decimals of accuracy
[12:04:07][D][ultrasonic.sensor:030]: 'Abstandssensor' - Got distance: 0.00 m
[12:04:07][D][sensor:092]: 'Abstandssensor': Sending state 0.00497 m with 2 decimals of accuracy
[12:04:09][D][ultrasonic.sensor:030]: 'Abstandssensor' - Got distance: 0.00 m
[12:04:09][D][sensor:092]: 'Abstandssensor': Sending state 0.00497 m with 2 decimals of accuracy
[12:04:11][D][ultrasonic.sensor:030]: 'Abstandssensor' - Got distance: 0.01 m
[12:04:11][D][sensor:092]: 'Abstandssensor': Sending state 0.00583 m with 2 decimals of accuracy
[12:04:13][D][ultrasonic.sensor:030]: 'Abstandssensor' - Got distance: 0.00 m
[12:04:13][D][sensor:092]: 'Abstandssensor': Sending state 0.00497 m with 2 decimals of accuracy
[12:04:15][D][ultrasonic.sensor:030]: 'Abstandssensor' - Got distance: 0.00 m
[12:04:15][D][sensor:092]: 'Abstandssensor': Sending state 0.00497 m with 2 decimals of accuracy
[12:04:17][D][ultrasonic.sensor:030]: 'Abstandssensor' - Got distance: 0.01 m
[12:04:17][D][sensor:092]: 'Abstandssensor': Sending state 0.00514 m with 2 decimals of accuracy
[12:04:19][D][ultrasonic.sensor:030]: 'Abstandssensor' - Got distance: 0.01 m
And the values are mostly the same also if I change the distance to the target.
Here is my ESPHome configuration:
esphome:
name: brunnen
platform: ESP8266
board: nodemcuv2
wifi:
ssid: "xxx"
password: "xxx"
ap:
ssid: "xxx"
password: "xxx"
captive_portal:
logger:
api:
ota:
sensor:
- platform: ultrasonic
trigger_pin: D8
echo_pin: D7
name: "Abstandssensor"
update_interval: 2000ms
And here you can see my wiring:
I connected:
- G -> GND
- 3V -> Vcc
- Echo -> D7
- Trigger -> D8
Am I missing something?
Thank you for your help.
I’m on HA 0.116.3