Page 1 of 1

HC-SR04 and the temperature

Posted: 04 Jan 2019, 13:51
by MrTom
Hi

does anyone created a temperature-compensation for the HC-SR04? How it realised?

Greets
Thomas

Re: HC-SR04 and the temperature

Posted: 14 Jan 2019, 18:48
by dynamicdave
I thought the HC-SR04 was an ultrasonic distance measuring device.
Are we talking about the same device?

The SR04 and SR05 work on the speed of sound that varies slightly with changes in altitude (and with temperature as others have pointed out).

Re: HC-SR04 and the temperature

Posted: 14 Jan 2019, 21:13
by Domosapiens
Speed of Sound:
c = 331.3 + 0.606 × Temperature_in_C
@20C:
c = 331.3 + 0.606 × 20 = 343.42 m/s
You can measure the temperature and compensate for the difference to 20C in a rule.

But ... useful?
Don't think so.
1 degree difference is less than 0.2% speed difference.

Re: HC-SR04 and the temperature

Posted: 15 Jan 2019, 20:30
by HomeJCL
:roll:

Re: HC-SR04 and the temperature

Posted: 17 Jan 2019, 13:36
by fluppie
Check this: https://www.instructables.com/id/Improv ... -Accuracy/

I was wondering if you would get better results on a ESP32 as the timer is in µs instead of ms?

Re: HC-SR04 and the temperature

Posted: 17 Jan 2019, 18:24
by Shardan
I think this is a bit questionable.

It could be usefull in a car ("distance radar") where you definitely find a span from -20°C to +70°C easily.
But for a sensor like the HC_SR04? Honestly this is a cheap sensor, and it has tolerances of some percent.

Within the temperature range inhouse the factor from the formula is below 1% - for a sensor that has
some percent tolerance this just pretends an exactness that does not exist.

The more: If you have an item not exactly in front of the sensor but some degrees right, left, up or down
you get even more tolerance in readings.

First step would be to calibrate this sensor. This would give better results then temperature compensation.
Anyways, even this would only be exact if an item is exactly in front of the sensor with zero degrees deviation.