Skip to main content

Sugar - Ultrasonic Module




Judge the distance between obstacles ahead and the module by transmitting and receiving sound waves.

Signal Timing signal

Working Principle of the Module

Sound waves with frequencies higher than 20 kHz are called ultrasonic waves, which feature good directivity and penetration capability, especially in water, where they can propagate over longer distances. To facilitate the study and utilization of ultrasonic waves, people have designed many types of ultrasonic generators, which vary in the way they generate ultrasonic waves, ranging from electrical to mechanical methods, and therefore have different applications. Each type of generator has its own application scenarios, but at present, the most widely used type is the piezoelectric ultrasonic generator. The key component of a piezoelectric ultrasonic generator is the piezoelectric chip inside, which mainly utilizes the resonance of the piezoelectric chip to work. There are two piezoelectric chips and a resonant plate inside the generator. When a pulse signal is applied between the two electrodes of the generator, the piezoelectric chip will vibrate when the frequency of the applied signal is equal to the frequency of the piezoelectric chip, and it will also drive the resonant plate to vibrate. This will generate ultrasonic waves, which is the transmitting end of the ultrasonic generator. However, if there is no applied pulse signal between the two electrodes of the generator and the resonant plate receives the transmitted ultrasonic waves, the piezoelectric chip will be forced to vibrate, and the mechanical energy generated will be converted into an electrical signal. This is the receiving end of the ultrasonic generator. image.png

Ultrasonic Distance Measurement Principle

The principle of ultrasonic distance measurement is very simple. An ultrasonic transmitter emits a beam of ultrasonic waves. The timer starts when the ultrasonic waves are emitted, and the emitted ultrasonic waves propagate through the medium. Sound waves have the property of reflection, and when they encounter an obstacle, they reflect back. When the ultrasonic receiver receives the reflected ultrasonic waves, the timer stops. When the medium is air, the speed of sound is 340m/s. Based on the recorded time t, the distance between the transmitting position and the obstacle can be calculated using the formula s=340*t/2.

Usage in Future Board Lite

School lighting (small).png

With the intelligent sensing device, you can control lighting in school areas (classrooms/basements/libraries). Using the school street lamp as a demonstration, the street lamp will light up when someone comes close, and turn off after the person leaves.

Structure building

Campus lighting.pdf

Circuit Connection


Future Board Lite InterfaceWire in Use
IMG_4009.JPGRGB Light RingPort1White PH2.0-3Pin Interface Wireuntitled.100.png
超声波新版-2.pngUltrasonic Distance Measuring ModulePort3White PH2.0-3Pin Interface Wireuntitled.100.png

Plugin Loading - Ultrasonic Plugin



Building Block Usage - Main Building Block

SequenceBuilding Block ImageBuilding Block Function
1image-20240321135944216Read the distance value of the ultrasonic module

Main Program - Ultrasonic Ranging

info Using ultrasonic for distance measurement and controlling RGB lights


Use on Microbit


Programming Platform

Microsoft MakeCode for micro:bit
Use the Makecode program platform

Adding the Sugar plugin

image-20240311154521941 image.png

Search for Sugar in extensions, click Add

Building Block - Function Description

Serial NumberBlock DiagramBlock Function
1image-20240316171135143Obtain the distance of obstacles in front of the ultrasonic module (supports mm and cm)

Circuit connection


Microbit InterfaceWiring
Ultrasonic new-2.pngUltrasonic ranging moduleP1White PH2.0-3Pin interface cableuntitled.100.png

Case: Distance Measurement