02-19-2024, 08:21 PM
(This post was last modified: 02-28-2024, 06:18 PM by terrain_inconnu.)
Attached is a simple experiment for measuring the speed of sound (in air) with the help of an Arduino Nano 33 BLE Sense Rev2 and the ultrasonic distance sensor HC-SR04. The idea is pretty trivial: the HC-SR04 sends out a supersonic signal and by measuring the time it takes to detect the echo as reflected on a hard surface at a known distance (set by the user) we can compute the speed of sound (c_exp=2*d/t). By measuring the temperature and humidity at the same time with the onboard sensors of the Nano one can also calculate a theoretical speed of sound (c_theo=331.4+0.6*T+0.0124*H) and compare the result versus the experimentally determined value. Additionally, one can measure how the speed of sound varies as the temperature and humidity of the air changes, for example by continuously taking readings outside during the day (or night).
Notes
1. If you plan to use the original Nano 33 BLE Sense you will need to adjust the code in the "speed_of_sound_v1.ino" file as the temperature/humidity sensor has changed in the Rev2 edition (HS3003 vs HTS221).
2. The onboard temperature sensor of the Nano is slow to adapt to temperature changes of the surrounding air. It is advisable to add a thermistor or some other external sensor to the setup in order to capture temperature changes as close to real time as possible. If you decide to do so, you can use the attached "speed_of_sound_v1_thermistor.ino" file and adjust the code to match your thermistor/external sensor.
3. I tested the setup with a battery operated Nano 33 BLE Sense Rev2 despite the fact the standard HC-SR04 sensor requires 5V to operate. Even with the 3.3V supply from the board, the sensor performed as expected.
Edits
28/02/2024: The phyphox file has been updated to correctly plot the theoretical speed of sound value vs time.
Notes
1. If you plan to use the original Nano 33 BLE Sense you will need to adjust the code in the "speed_of_sound_v1.ino" file as the temperature/humidity sensor has changed in the Rev2 edition (HS3003 vs HTS221).
2. The onboard temperature sensor of the Nano is slow to adapt to temperature changes of the surrounding air. It is advisable to add a thermistor or some other external sensor to the setup in order to capture temperature changes as close to real time as possible. If you decide to do so, you can use the attached "speed_of_sound_v1_thermistor.ino" file and adjust the code to match your thermistor/external sensor.
3. I tested the setup with a battery operated Nano 33 BLE Sense Rev2 despite the fact the standard HC-SR04 sensor requires 5V to operate. Even with the 3.3V supply from the board, the sensor performed as expected.
Edits
28/02/2024: The phyphox file has been updated to correctly plot the theoretical speed of sound value vs time.