![]() |
Forum Index : Microcontroller and PC projects : Ultrasonic ranging using HC-SR04
Author | Message | ||||
larny Guru ![]() Joined: 31/10/2011 Location: AustraliaPosts: 346 |
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: AustraliaPosts: 6269 |
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. Jim VK7JH MMedit |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6269 |
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. 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 StatesPosts: 209 |
Hi TassyJim;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: AustraliaPosts: 6269 |
@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 ' 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: AustraliaPosts: 346 |
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: AustraliaPosts: 6269 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |