Ultrasonic TOF Sensor Material Detection Ultra-low Power - DFRobot

Ultrasonic Material Detection Sensor


This ultrasonic time-of-flight (TOF) sensor utilizes the difference in energy of the ultrasonic echo signal on various surfaces to identify materials. Featuring ultra-low power, small size, and light weight, the ultrasonic material detection sensor is specially designed for material identification within a short range of 2-10cm. The ultrasonic sensor can distinguish hard and soft materials and output information by IO (high/low) or UART. Compact and easy to install, it is mainly suitable for robotic cleaners to identify the floor material and automatically adjust the cleaning strategy according to the recognized ground information, thus achieving intelligent cleaning.



Note: there is a ο mark at welding pin 1 of the wiring base

NO Signal Type Description Min Typical Max
1 Rx Input UART 0V 3.3V 3.5V
2 Tx/IO Output TTL level 0V 3.3v 3.5V
3 GND Power Power Negative - 0V -
4 P3V3 Power Power positive 2.8V 3.3V 3.6V

Product size

Assembly diagram


IO mode wiring diagram

Sample Code

int ledPin = 13; // LED connected to digital pin 13
int inPin = 8;   // pushbutton connected to digital pin 8
int val = 0;     // variable to store the read value

void setup()
  pinMode(ledPin, OUTPUT);      // sets the digital pin 13 as output
  pinMode(inPin, INPUT);      // sets the digital pin 8 as input
  digitalWrite(ledPin, LOW);
void loop() {
  val = digitalRead(inPin);   // read the input pin
  if (val)
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledPin, LOW);

The response time for judgment in IO mode is 10ms; When the target material is a soft material, the TX pin outputs a low level of 0V; When the target material is a hard material, the TX pin outputs a high level of 3.3V

Serial mode wiring diagram

Module is powered on, it sends instructions to the module through the serial port to switch from IO mode to serial port mode. After that, the module sends related data at a frequency of 100 Hz. This data follows the module's serial port software communication protocol.

Baud Rate Data Bits Stop Bits Parity Bit Flow Control
115200 8 Bits 1 No No

Sample Code

#include <SoftwareSerial.h>
SoftwareSerial mySerial(9, 10); // RX, TX

unsigned char Send_Date[6] = {0XAA,0XAA,0XFE,0X01,0X00,0X53};
unsigned char buffer_RTT[100] = {}; 
uint8_t checksum = 0;

void setup() {

void loop() {
 while (mySerial.available() > 0) 
   if(mySerial.read() == 0XAA)
     for(int i=1;i<8;i++)
       checksum =(buffer_RTT[0]+buffer_RTT[1]+buffer_RTT[2]+buffer_RTT[3]+buffer_RTT[4]+buffer_RTT[5]+buffer_RTT[6])&0X00FF;
      if(buffer_RTT[7]== checksum)
        Serial.println(buffer_RTT[4]);                //read data bit status

When hard material is detected, the serial port prints 0; when soft material is detected, the serial port prints 1.

Material testing instructions

1、 Material description, common hard materials include: wooden floor, ceramic tiles, marble; common soft materials include: carpet (long-haired carpet,medium-haired carpet, short-haired carpet), sponge, etc..

2、 The unevenness and the excessively large floor gap of the hard material ground may cause the echo value of the hard material to be significantly weakened and be misjudged as a soft material. Therefore, it is not recommended to be used in complex scenes with the flatness of the ground. In order to enhance reliability, it is recommended to coordinate the detection with the movement of the sweeping robot, and use multiple detection results within a certain range to assist in the determination, which can prevent other conditions from affecting the detection..