[18:22:05][C][ultrasonic.sensor:035]: Ultrasonic Sensor 'Waste tank'
[18:22:05][C][ultrasonic.sensor:035]: Unit of Measurement: '%'
[18:22:05][C][ultrasonic.sensor:035]: Accuracy Decimals: 0
[18:22:05][C][ultrasonic.sensor:035]: Icon: 'mdi:water-percent'
[18:22:05][C][ultrasonic.sensor:036]: Echo Pin: GPIO4 (Mode: INPUT)
[18:22:05][C][ultrasonic.sensor:037]: Trigger Pin: GPIO5 (Mode: OUTPUT)
[18:22:05][C][ultrasonic.sensor:038]: Pulse time: 10 µs
[18:22:05][C][ultrasonic.sensor:039]: Timeout: 11661 µs
[18:22:05][C][ultrasonic.sensor:040]: Update Interval: 5.0s
[18:22:05][C][ota:029]: Over-The-Air Updates:
[18:22:05][C][ota:030]: Address: waste_tank.local:3232
[18:22:05][C][ota:032]: Using Password.
[18:22:05][C][api:103]: API Server:
[18:22:05][C][api:104]: Address: waste_tank.local:6053
[18:22:06][D][ultrasonic.sensor:025]: 'Waste tank' - Distance measurement timed out!
[18:22:06][D][sensor:092]: 'Waste tank': Sending state nan % with 0 decimals of accuracy
[18:22:11][D][ultrasonic.sensor:025]: 'Waste tank' - Distance measurement timed out!
[18:22:11][D][sensor:092]: 'Waste tank': Sending state nan % with 0 decimals of accuracy
[18:22:16][D][ultrasonic.sensor:025]: 'Waste tank' - Distance measurement timed out!
[18:22:16][D][sensor:092]: 'Waste tank': Sending state nan % with 0 decimals of accuracy
[18:22:21][D][ultrasonic.sensor:025]: 'Waste tank' - Distance measurement timed out!
I have tried to swap the echo and trigger, no change. Never once got an echo. Is there some way to measure if I have cabled it correctly with a multimeter or similar?
Is there some magic I do not understand? I have tried my code with a HC-SR04 and that works fine. When I put my ear to the sensor (the A02YYWM one) I can hear the “tick” of the trigger. But it does not read any data back. Tried also to increase the pulse time but still no cigar.
3.3V is enough to trigger the measurement to start.
But, the echo pin will pulse 5V into GPi04. It is only rated for 3.3V.
Connect a 4K7 resistor to the SR04 echo pin. Connect a 9K1 resistor from the other end of the 4K7 to ground. The junction of the two resistors goes to GPIO4.
I have tried with the resistance to shift the level. I measured with a multimeter and it was down to 3,1V so that should be working well, but still it does not work. Tried to configure the HC-SR04 with the same setup and that works just perfect. So the GPIOs seems to be working fine. Also, just to be 100% sure I replaced the ESP with a new one and I get the same results.
But looking in the data of the sensor I find this.
Does this make a difference? For my eyes it seems that it has a delay on T2 that might be troublesome? Am I wrong?
Yes the HC-SR04 is working, but I am trying the waterprotected version, which is supposed to be 100% compatible. The HC-SR04 is not water protected at all. But I suspect that the sensor I use is not 100% compatible … therefor I link the picture above.
Here is the IP65 sensor:
And this is the Arduino code for the PWM version (which is supposed to be 100% compatible… again, I doubt it).
So sadly it does not work for my application (measurement of waste water inside a tank).
Just to be 100% clear. I have tried the HC-SR04 and the DYPA02YY sensor on the same ESP (one at a time) with the same code. Both with 3,3V and with 5V power supply. The HC-SR04 works fine, but not the DYPA02YY. So what I am looking for is to try and debug the difference of these sensors…
not sure if it may help you, but I’ll share.
I’ve been using this sensor with a wemosd1 without any resistors for about 2 years with tasmota.
The tasmota sensors.bin already include this sensor.
just pick your pins, connect and thats it.