Hi,
I set up an ultrasonic sensor, but it is returning very variable responses. The only correct thing is:
in a sample of 100 measurements, the top 10 correspond to the correct expected measurement.
I would like to create a filter that selects the highest 10 out of 100. Then it would only pass the value of the highest 10 to the home assistant.
Using Median, would select a wrong number.
JSN-SR04T / AJ-SR04M Waterproof Ultrasonic Sensor Module
NodeMCU
Pins Rx and Tx
esphome:
name: nodemcu1
platform: ESP8266
board: nodemcuv2
## SENSOR ###
sensor:
- platform: ultrasonic
trigger_pin: GPIO3
echo_pin: GPIO1
unit_of_measurement: m
update_interval: 1s
name: "Distancia"
pulse_time: 20us
timeout: 20m
filters:
- lambda: |-
float MIN_VALUE = 0.25;
float MAX_VALUE = 6.0;
if (MIN_VALUE <= x && x <= MAX_VALUE) return x;
else return {};
- filter_out: 00.0
- offset: 0.04
- filter_out: 0.04
I still get lots of time out or wrong readings. The only correct are the top highest values.
I appreciate if someone helps me.
LOG: