Skip to content

Instantly share code, notes, and snippets.

@TalalMash
Last active March 28, 2022 20:11
Show Gist options
  • Save TalalMash/2538ed7371b35cb3f9e50188729f6acb to your computer and use it in GitHub Desktop.
Save TalalMash/2538ed7371b35cb3f9e50188729f6acb to your computer and use it in GitHub Desktop.
[Tasmota] SR-04 Ultrasonic Tank Level measurement rules
Rule1 ON sr04#distance>0 DO Backlog var1=((((%value%*)-20)-(EM-20))/(EM-20))*-100; var2=(var1*0.01)*LT; event sendval ENDON
Rule1 + ON event#sendval DO publish tele/watertank/LEVEL %var1% ENDON ON event#sendval DO publish tele/watertank/VOLUME %var2% ENDON
Rule1 1
Replace:
-LT with the number of liters
-EM with the distance when the tank is empty.
You will get percentage (level) and number of liters, accurate starting from 60cm deep tanks.
SR-04 (water proof) is recommended for use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment