Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 00:36 06 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Ultrasonic ranging using HC-SR04

Author Message
larny
Guru

Joined: 31/10/2011
Location: Australia
Posts: 346
Posted: 08:50pm 06 Dec 2016
Copy link to clipboard 
Print this post

Does anyone know if these devices have built in thermal correction?

As you know, the speed of sound varies with air temperature.

So an internal temp compensation would save us all the need to make a correction for temp in our microprocessor programmes.

Len
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 09:17pm 06 Dec 2016
Copy link to clipboard 
Print this post

The sensor measurement is simply time without any temperature correction so if you are measuring distances over a large temperature range, you will have to do your own compensation.
For the vast majority of uses, the uncompensated result is well within expected accuracy.

In my water-level monitor, the PVC tank which the sensor is mounted on, moves with temperature, resulting an errors much greater than the speed of sound creates.

Working backwards, if you set up a fixed distance, the changes in readings could be used to calculate temperature!
You will have to take into account the changes in oscillator frequency vs temperature within the micromite.

JimEdited by TassyJim 2016-12-08
VK7JH
MMedit
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 09:45pm 06 Dec 2016
Copy link to clipboard 
Print this post

I think the maths is correct.
Columns are Temperature in degrees C, Speed of sound in m/s, distance returned by micromite for one metre.
  Quote   ' V = speed of sound in dry air metres/second
' T = temperature in degrees
PRINT "Temp V 1 Metre"
FOR T = -100 TO 100 STEP 10
V =
20.05*SQR(T+273.15)
PRINT STR$(T,4,0);" ",STR$(V,4,2);" ";STR$(331.371/V,2,3)
NEXT T


I am not sure what temperature the micromites used as a reference point.

Jim
VK7JH
MMedit
 
redrok

Senior Member

Joined: 15/09/2014
Location: United States
Posts: 209
Posted: 10:25am 07 Dec 2016
Copy link to clipboard 
Print this post

Hi TassyJim;
  TassyJim said   I think the maths is correct.
Columns are Temperature in degrees C, Speed of sound in m/s, distance returned by micromite for one metre.
  Quote   ' V = speed of sound in dry air metres/second
' T = temperature in degrees
PRINT "Temp V 1 Metre"
FOR T = -100 TO 100 STEP 10
V =
20.05*SQR(T+273.15)
PRINT STR$(T,4,0);" ",STR$(V,4,2);" ";STR$(331.371/V,2,3)
NEXT T


I am not sure what temperature the micromites used as a reference point.

Jim
Not completely correct.
Don't forget water vapor in the atmosphere.
H2O is a light molecule compared to N2 & O2.
The velocity in air does change with humidity.
And the percentage varies with temperature.
I doubt it's a large factor but is not negligible.
As I recall, but don't quote me on this, the light
H2O causes the velocity to go down a bit.(Or up?)
In your water tank if its covered may have 100% humidity.

Now, at high temperatures, say above 212F, the only gas
is H2O. There would now be a large error.

Forget about the trace gasses as they are a negligible
component of air.

Another special condition is in flue gasses. Here
the heavy gas CO2 can be a sizable percentage, O2 is
lowered, and H2O increased.

For normal use the the ranger is good enough.

redrok
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 11:58am 07 Dec 2016
Copy link to clipboard 
Print this post

@redrok,
You are correct, humidity and pollution etc will also cause the velocity to change.
I stuck to dry air for simplicity. Anything more will quickly get outside my comfort zone.

The micromite seem to use 345.9m/s which is the velocity at ~25 degrees C

My demo should be
  Quote   ' V = speed of sound in dry air metres/second
' T = temperature in degrees
PRINT "Temp V 1 Metre"
FOR T = -100 TO 100 STEP 10
V =
20.05*SQR(T+273.15)
PRINT STR$(T,4,0);" ",STR$(V,4,2);" ";STR$(345.9/V,2,3)
NEXT T


My fridge is not big enough to test the effects.
Anyone got a sauna?

Jim
VK7JH
MMedit
 
larny
Guru

Joined: 31/10/2011
Location: Australia
Posts: 346
Posted: 12:01pm 07 Dec 2016
Copy link to clipboard 
Print this post

Thanks for the responses.

I'm designing a Water Tank Level Meter & I'm using the PCB from the Silicon Chip September 2011 issue.

But rather than use a LED display as they did, I intend to use two 7 segment displays so it will display 20 levels. I'll use the same PIC - the 16F88 with the HC-SR04 in lieu of the Silicon Chip arrangement.

The tanks are under the house so there is not much temperature variation between summer & winter. So, at this stage, I won't bother doing the temperature correction.

I can do that later if it proves to be necessary.

Len
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 01:06pm 07 Dec 2016
Copy link to clipboard 
Print this post

Search ebay for "Ultrasonic Module Distance Measuring Transducer Sensor Waterproof"
The sensors are similar to the ones used on automotive parking sensors and should last well in the high humidity.
So far, I have been happy with the results.
You can purchase the sensor on it's own without the control board.

Jim
VK7JH
MMedit
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025