Stefan Bracher

Ultrasound Motion Lab

Back to Microcontrollers

Overview

Ultrasound Motion Lab Web Interface

Das Ultrasound Motion Lab basiert auf einem ESP32- oder Arduino-kompatiblen Mikrocontroller und einem Ultraschall-Distanzsensor. Es misst die Position, berechnet Geschwindigkeit und Beschleunigung und zeigt anschliessend s-t-, v-t- und a-t-Diagramme in Echtzeit direkt im Webbrowser über WebSerial an.

The Ultrasound Motion Lab is based on an ESP32 or Arduino-compatible microcontroller and an ultrasonic distance sensor. It measures position and calculates velocity and acceleration, then displays real-time s-t, v-t and a-t graphs directly in a web browser using WebSerial.

Le Ultrasound Motion Lab est une expérience de physique basée sur un microcontrôleur compatible ESP32 ou Arduino et un capteur de distance à ultrasons. Il mesure la position, calcule la vitesse et l’accélération, puis affiche les graphiques s-t, v-t et a-t en temps réel directement dans un navigateur web avec WebSerial.

L'Ultrasound Motion Lab si basa su un microcontrollore compatibile ESP32 o Arduino e su un sensore di distanza a ultrasuoni. Misura la posizione, calcola la velocità e l'accelerazione e visualizza in tempo reale i grafici s-t, v-t e a-t direttamente in un browser web tramite WebSerial.

Download


Basic Setup

Part Purpose Notes
ESP32 ESP32 / ESP32-C3 / Arduino-compatible board Reads the sensor and sends data over USB serial. The current version was tested with ESP32 boards.
Ultrasonic Sensor HC-SR04 Ultrasonic distance sensor SR04 Measures the distance to the moving object. Use a 3.3 V compatible module (new version) when connecting directly to ESP32 pins.
WebBrowser Web browser with WebSerial support Displays the live graphs. Works best with Chrome or Chromium-based browsers.

Screenshot

Ultrasound Motion Lab Screenshot

Serial Data Format

The microcontroller sends one line of comma-separated data for each measurement:

time_ms,distance_m,velocity_m_s,acceleration_m_s2

Hardware Setup

  • SR04 VCC -> ESP32 3.3 V
  • SR04 GND -> ESP32 GND
  • SR04 TRIG -> ESP32 GPIO 25
  • SR04 ECHO -> ESP32 GPIO 26
Ultrasound Motion Lab Fritzing Sketch Ultrasound Motion Lab Fritzing Schematic

Videos

Complete Setup Guide

Complete Setup Guide Youtube Video

Motion Tracking with an HC SR04 Ultrasound Sensor

Motion Tracking with an HC SR04 Ultrasound Sensor Youtube Video

Credits

This project originated from a student project in 203-SNC-VA Mechatronics and Computational Physics at Vanier College.

Original Arduino Prototype:
Mobile Distance Sensor
Sophia Caruntu and Arman Ibne Kamal
Vanier College, Winter 2026

ESP32 implementation and addition of velocity-time (v-t) and acceleration-time (a-t) graphs:
Stefan Bracher