SKU_BOS0045_Boson_Ultrasonic_Distance_Sensor_i22-DFRobot

Introduction

The frequency of the sound wave that the human ear can hear is 20-20000Hz. When the vibration frequency of the sound wave is greater than 20000Hz, the human ear cannot hear it. So we call sound waves with frequency above 20000Hz "ultrasonic", whose lower frequency limit is approximately equal to the upper limit of human hearing. As the speed of ultrasound in air is known, ultrasonic sensors can transmit sound waves toward a target and then calculate its distance by measuring the time between transmitting and receiving the reflected sound signal. The module works well with maincontrollers such as micro:bit and Arduino, and can be used for not only Mind+ and makecode graphical programming but also non-programming projects.

Specification

Board Overview

Num Label Description
1 GND Power -
2 VCC Power +
3 SIGNAL Analog signal line
4 LED Distance indication
5 Probe Transmit/receive
6 Mode Select Switch Obstacle detection /distance detection

Usage Description

Obstacle detection: the farther away from the detected object, the smaller the analog value; otherwise, the larger the analog value.
Distance detection: the farther away from the detected object, the larger the analog value; otherwise, the smaller the analog value.

Usage Description

Place the ultrasonic distance sensor toward the object to be measured. When the sensor measures the distance of the object, it will light up the corresponding number of LEDs and output the actual measured distance. The measurement distance of the sensor is 0cm-100cm. And the relationship between the measured distance and the number of lit LED is shown in the figure below:

Relationship between the measured distance and the number of LED to be on

Distance Number of LED
0≤D<10 0
10≤D<20 1
20≤D<40 2
40≤D<60 3
60≤D<80 4
80≤D<100 5

The distance is proportional to the analog value, that is: the distance value of 0cm-100cm corresponds to the analog value of 0-1023 Distance=AnalogData×(100/1023) (cm).

Principle

As the speed of ultrasound in air is known, ultrasonic sensors can transmit sound waves toward a target and then calculate its distance by measuring the time between transmitting and receiving the reflected sound signal. During a measurement, the sensor emits ultrasonic waves in a certain direction and starts timing at the same time. The ultrasonic wave returns immediately when it encounters an obstacle on the way during transmission, and the ultrasonic receiver immediately stops timing when it receives the reflected wave. The speed of ultrasonic waves in air at 15°C is 340m/s. According to the time recorded by the timer, the distance between the emitter and the obstacle can be calculated. The LED lights on the sensor can intuitively show the distance changes.

Application

1. Parking Radar

Description:
When reversing a car, the speaker will broadcast "please pay attention to the obstacle behind" if the ultrasonic distance sensor detects it to remind the driver and ensure the safety of reversing.

Components:

Mainboard
BOS0045 Ultrasonic Distance Sensor BOS0022 Voice Recorder Module BOS0035 Mainboard-3IO
micro:bit microbit expansion board
MBT0039 micro:bit BOS0040 micro:bit BOSON Expansion Board

Tip: micro:bit and its expansion board will be used in programming projects.

Non-programming Project

Connection Diagram:

Connection 1

Programming Project

Connection Diagram:

Program Flowchart:

Mind+ Sample Code:

MakeCode Sample Code:

2. Guard Security

Description:

The LED lights up when the sensor detects someone is approaching.

Components:

BOS0045 Ultrasonic Distance Sensor BOS0017 LED Module BOS0032 Threshold Module
micro:bit microbit expansion board Mainboard
MBT0039 micro:bit BOS0040 micro:bit BOSON Expansion Board BOS0035 Mainboard-3IO
BOS0029 Logic Module-NOT

Tip: micro:bit and its expansion board will be used in programming projects.

Non-programming Project

Connection Diagram:

Programming Project

Connection Diagram:

Program Flowchart:

Mind+ Sample Code:

MakeCode Sample Code:

Video Demo

Non-programming Programming

3. Smart Bin (Programming)

Description:
Make a smart bin that automatically opens the lid when it detects someone's approaching, and closes after 5s.

Components:

BOS0045 Ultrasonic Distance Sensor BOS0017 LED Module
micro:bit microbit expansion board
MBT0039 micro:bit BOS0040 micro:bit BOSON Expansion Board

Connection Diagram:

Program Flowchart:

Mind+ Sample Code:

MakeCode Sample Code:

Video Demo

Programming

4. Smart Fan with Distance Sensing (Programming)

Description:
Let the fan module adjust the speed according to the distance between the human and the fan: when the human is within 20cm from the fan, the fan rotates at 1st gear; when the human is 20-40cm away from the fan, the fan rotates at 2nd gear; when the human is 40-60cm away from the fan, the fan rotates at 3rd gear; when the human is outside 60cm, the fan will stop rotating (Note: the 1st gear corresponds to the fastest speed, the 3rd is the slowest, and the 2nd is in the middle).

Components:

BOS0045 Ultrasonic Distance Sensor BOS0021 Fan Module
micro:bit microbit expansion board
MBT0039 micro:bit BOS0040 micro:bit BOSON Expansion Board

Connection Diagram:

Program Flowchart:

Mind+ Sample Code:

MakeCode Sample Code:

Video Demo

Programming

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum

Turn to the Boson Kit Page