HC-SR04 default value for over max distance

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
waspie
Normal user
Posts: 127
Joined: 09 Feb 2017, 19:35

HC-SR04 default value for over max distance

#1 Post by waspie » 06 Apr 2018, 02:16

I've been banging my head against a wall trying to get 2 US sensors working right. I have second esp running with 2 and it's been fine but i made another with 2 more US sensors in a different position and I cannot get solid readings from them.

But I think I finally figured it out. Most of the time these 2 sensors will not pick anything up. In other words, they'll be trying to measure a distance that is beyond 400CM.
When they're in this state I get some crazy numbers out of them like:
547285 : SR04 : Distance: 9435517.00
or it says something else..unknown distance or something. I can't remember right now.

Is there a way to report the distance as out of bounds (like 1000 or 0 or something) when there is nothing within range?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: HC-SR04 default value for over max distance

#2 Post by grovkillen » 06 Apr 2018, 05:51

With rules and dummy device you can do this.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: HC-SR04 default value for over max distance

#3 Post by toffel969 » 09 Apr 2018, 13:47

grovkillen wrote: 06 Apr 2018, 05:51 With rules and dummy device you can do this.
Yes I am using that exactly, works perfectly

You check the value for "sanity", then you write it into a dummy device. Further reactions only when the dummy is rewritten.

Code: Select all

On dist#scr4<400  do 
Taskvalueset,7,1,[dist#scr4]
Taskrun,7
Endon

On distance#dummy do
whatever
Endon

Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

Post Reply

Who is online

Users browsing this forum: No registered users and 52 guests