Reference

Last revision 2025/12/17

Communication Protocol Description

Command frame format of serial communication

Interface Type Start byte Data byte Stop byte Parity check Band rate
Full duplex 1 8 1 None 9600

Output frame format

Frame Header ID Distance Data High Distance Data Low Temperature Data High Temperature Data Low Checksum
0xFF Data_H Data_L Temp_H Temp_L SUM

Distance Calculation

Distance=Data_H*256+Data_L (Unit: mm)

Temperature Calculation

When the highest bit of Temp_H is 0, the temperature value is positive; when it is 1, the temperature value is negative.

If Temp_H=0x01=0b0000 0001, the most highest bit is 0, which means the temperature value is positive.

Temperature=Temp _H*256+ Temp _L

Eg: the temperature value is 281 when converted to decimal;
The currently detected temperature is 28.1℃. (Unit: ℃)

Checksum Calculation

Note: just reserve the eight lower bits of the accumulated value of checksum.

SUM=(frame header+ Data_H+ Data_L+ Temp_H+ Temp_L)&0x00FF

Principle

The sensor, like many other ultrasonic sensors, based on the principle of ultrasonic echo ranging, determines the distance to a target by measuring time lapses between the sending of a pulse and receiving of the echo without contacting.

Other Supplementary Information

The ultrasonic sensor has three output modes: serial, PWM, switch. The default output mode of the sensor is serial output. Change the mode by pressing or triggering. The indicators will flash in different ways to indicate the corresponding mode.

Button Operation Description

  • a. Short-press (less than 2s): serial and PWM output modes can be switched in turn by short-pressing. When successfully switched, the module will remember the mode, and it won't be lost when powered down.
  • b. Long-press (more than 3s): the controller will save the currently detected vaule and take it as threshold distance value under Switch mode. After the setting is done, the module will remember the threshold value and it won't lost when powered down.

Trigger Signal

  • a. When the trigger pin "2.Trigger" is at High Level, the controller will be in standby state of low-power consumption.
  • b. When the trigger pin "2. Tigger" is at falling edge, the Low Level of the falling edge should keep 0.1~10ms. (1) Under UART output mode, the controller will be triggerred once and then output one frame serial data;(2) Under PWM output mode, the controller will be triggerred one and output PWM signal.
  • c. When the trigger pin "2.Trigger" is at Low Level or be grounded, the controller will be under Switch Mode.

Indicator Description

  • a. When successfully switched to PWM mode by short-pressing, the LED will flash blue once, wait 1 second, and flash once again.
  • b. When successfully switched to serial mode by short-pressing, the LED will flash blue three times, wait 1 second, and flash three times again.
  • c. When the threshold value is set successfully by long-pressing, the LED will flash red and blue five times alternately.
  • d. When the controller is in the Serial or PWM mode, it will be triggered once by the falling edge, and the LED will flash red once.
  • e. When the controller is in the Switch mode, the LED will indicate the state of the Switch. If the currently detected value is within the range of the thresholds value, the LED will emit red. if not, the LED turns off.

PWM Output

Switch to PWM mode by short-pressing the button. When succeeded, the LED flashes blue once, wait 1 second, then flash once again.

When the trigger pin "2.Trigger" is at falling edge and the Low level is kept for 0.1-10ms, the controller will be triggerred once and the output pin "3.TX/PWM" will output PWM signal of 3.3V TTL. The trigger period of the controller must be over 60ms.

Output Principle

When the trigger pin received the falling edge trigger level, the module will emit 40kHz ultrasound, at the same time, the output pin "3.TX/PWM" will be pulled up. when it detected the echo signal, the output pin will be pulled down immediately. When it did't detect any objects, the output pin will be pulled down to stop detecting after 55ms, and there is no temperature compensation in this process.

Use MCU to judge the time of high level, which also is the time for the ultrasound to travel between the module and the detected object. The distance can be calculated then when we get the ultrasound velocity and the time.

SEN0300 Water-proof Ultrasonic Sensor (ULS) PWM Output

Note: T1=0.1-10ms; T2=4-6ms; T3=1-55ms

Calculation

Distance=High level time×Velocity(340m/s)/2, us/58=cm or us/148=inch; in different temeprature, the velocity of the ultrasound: v=332+0.6t(m/s). If the controller did't detect any objects, the output pin will output constant pulse width for 55ms.

Switch Output

When the trigger pin "2.Trigger" is at low level or grounded, the controller will be in Switch mode, and automatically starts detecting with 250ms working period. Compare the detected value with the pre-set threshold value so as to control the output state of the switch.

Set the threshold value

Step 1: evaluate the threshold distance value, put an object or baffle at the distance equal to the preset threshold distance. For instance, when we set the threshold vlaue to 3m, then we need to place a flat baffle at 3m away. Level the baffle on the ground to form an open field so as to assure the detection accuracy.

Step 2: direct the controller at the object or the flat baffle, long-press for 3 seconds above. When the LED flashed red and blue alternately, the setting is done. The controller will remember the currently detected distance and take it as the threshold value. Continue to long-press the button if you need to reset the threshold value.

Output State

Case 1: if the detected value is smaller than the preset threshold, the output pin "4.ON-OFFout" output low value, at the same time, the LED emits red.

Case 2: if the detected vaule is bigger than the perset threshold, "4.ON-OFFout" output pull-up high level and the LED turns off.

Was this article helpful?

TOP