I’m trying to get ESP8266-MOD to work with HS-SR04 sensor. The config file is very staighforward but the reading i’m getting from the sensor is inaccurate
[13:27:05][D][sensor:092]: 'Node2 Distance Sensor': Sending state 0.60025 cm with 0 decimals of accuracy
[13:27:06][D][sensor:092]: 'Node2 Opener Wifi': Sending state -54.00000 dB with 0 decimals of accuracy
[13:27:10][D][ultrasonic.sensor:029]: 'Node2 Distance Sensor' - Got distance: 0.01 m
[13:27:10][D][sensor:092]: 'Node2 Distance Sensor': Sending state 0.60025 cm with 0 decimals of accuracy
[13:27:15][D][ultrasonic.sensor:029]: 'Node2 Distance Sensor' - Got distance: 0.01 m
[13:27:15][D][sensor:092]: 'Node2 Distance Sensor': Sending state 0.60025 cm with 0 decimals of accuracy
Here is config file
esphome:
name: node2
platform: ESP8266
board: nodemcuv2
wifi:
ssid: !secret wifi
password: !secret wifi_pw
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
# Enables status LED
status_led:
pin: GPIO2
sensor:
- platform: wifi_signal # Sensors that the ESPhome unit is capable of reporting
name: "Node2 Opener Wifi"
update_interval: 60s
- platform: ultrasonic
trigger_pin: D6
echo_pin: D5
update_interval: 5s
unit_of_measurement: cm
accuracy_decimals: 0
# apply a filter to change the distance to cm from metre #
filters:
- multiply: 100
name: "Node2 Distance Sensor"
I thought it is a sensor issue so I bought 5 new SR04 sensors and i’m getting the same results.
What pin is the vcc on the sensor connected to?
I had a similar issue when I tried the same thing a few weeks ago with an ESP32. I found that the vcc needed to be connected to the 3.3V output even though the sensor is marked with 5V.
Having exactly the same issue with nodemcu. No matter what I tried (D1 vs GPIO, switching boards). Tried 3 different SR4 sensors all reading the same. Did you managed to get this working already?
Hi, I’m having another problem related to this. Using an esp32 (ttgo) and i get good readings for the most part. But at times the readings become much longer and also very noisy. I’m measuring the level of pellets in a magasin and I don’t know if these errors are due to the shape of the material depending on how it is lying. When the sensor is at approximately 2dm from the pellets as of now, readings go up to at about 1m and stay there. The fix seems to be to recycle the power. Simply restarting the ESP does nothing. I have my sensor powered from the 5V pin.
I resolved my problem, and after reading about others with different strange errors with the same cause I wanted to write it here.
I was running the sensor from 5v but in fact it was giving 4.8 v on the ttgo board. I soldered a thin wire to get 5v directly from the USB port, without going through any diods or what not and my problems are gone. Other problems I’ve read about can be inconsistent or noisy readings, uncharged values and no readings at all
I’ve tried several different boards and I’ve used power from a board pin and I’ve used a separate power supply to ensure 5v and I still get erroneous readings from these sensors.
I’ve got the “unit of measurement” set to cm on one sensor and to ft on the other sensor in my 2 car garage.
My readings on my dashboard for one are 1.12 cm and for the other one 1.05 ft. So these readings are complete garbage.
- platform: ultrasonic
trigger_pin: 4
echo_pin: 6
name: "Glen's Garage Space"
update_interval: 30s
unit_of_measurement: ft
filters:
- filter_out: nan
Other than unit_of_measurement the config is the same for both sensors.