Experiment: Measuring Distance using SR04

1. Aim

To measure distance versus time with SR04 and use the data to estimate oscillation frequency of periodic motion.


2. Apparatus / Components Required


3. Theory & Principle

SR04 emits ultrasound and detects echo return time. Distance is obtained from time-of-flight of sound pulse. ExpEYES function:

tm, dist = p.sr04_distance_time()

For periodic motion, distance-time data can be fit to sine function to obtain frequency and period.


4. Circuit Diagram / Setup

  1. Wire SR04 as shown in the ExpEYES setup.
  2. Place a flat reflecting target in front of sensor.
  3. Move target periodically (hand oscillation / spring-mass / pendulum).

5. Procedure

  1. Run acquisition for ~5 seconds and save data to sr04.csv.
  2. Plot distance vs time.
  3. Select a clean oscillation segment.
  4. Fit to sinusoid and extract frequency.
  5. Compare measured period with theoretical model (if applicable).
Transistor Amplifier - Mobile App

Measurements Screenshot

Transistor Amplifier - Desktop App

Setup Photo


6. Observation Table

Trial Mean Distance (cm) Frequency (Hz) Period (s) Remarks
1        
2        
3        

7. Results and Discussion


8. Precautions

  1. Keep reflector flat and roughly perpendicular to sensor.
  2. Avoid nearby moving objects causing false echoes.
  3. Ensure target remains within SR04 sensing range.

9. Troubleshooting

Symptom Possible Cause Corrective Action
Unstable distance values Weak/angled reflector Use larger flat target
Missing points Out-of-range target Keep target within rated range
Poor fit quality Non-periodic motion Use cleaner oscillatory motion

10. Viva-Voce Questions

Q1. Why use curve fitting instead of a single peak count?

Ans: Fitting uses all samples, reducing random error in frequency estimation.

Q2. Can SR04 measure static distance accurately?

Ans: Yes, if alignment and reflection quality are good, 3mm step size can be expected. For poor quality surfaces, 5mm +/- variations can be seen.