Home        Store        Docs        Blog

Ping1d distance return at extreme depths

I use the Ping Sonar with Arduino, and get correct distance() return in mm from Ping1d.h in a swimming pool.
But I can’t check what the return will be at extreme distances, like on open ocean, a km deep. (No ocean nearby to do the check). I need it, for autonomous USV use.
I divide the distance by 10, to get to cm. But if the return will not be an integer, script will crash, while error handling on Arduino is not possible.
How to handle this problem best?

1 Like

BlueRobotic’s ping1d is only spec’d to measure distances up to 30 meters, so I believe you’ll have trouble using it for the application described. As for integer values, Arduino has functions such as round(), which rounds to the nearest integer, as well as floor(), which rounds down to the nearest integer, either of which should help solve your issue.

Thanks Robin,
I don’t need to ping over 30m, but the plan is to move from deep open sea to a reef, using the sonar to trigger arrived. If it is known by developers of this product: Will at 40m the return be a high int, like a set max of 29999? Or will nothing be returned, so the script will stop after calling distance?