Introduction
This laser distance sensor is specifically designed to address the issues commonly found in distance sensors on the market, such as large size, slow response time, and poor installation adaptability. It has a compact size, comparable to the size of a fingernail, and a measurement range of up to 4m. It boasts a range of advantages including small size, minimal blind zone, fast response time, high installation adaptability, dust and water resistance, long lifespan, and high reliability.
The sensor outputs data through an I2C interface, which allows users to easily integrate it with Arduino IO expansion boards. It finds widespread applications in various fields, including smart furniture with motion sensing capabilities, home security systems, intelligent detection systems, smart control systems, robot obstacle avoidance, and object proximity and presence detection.
Features
- Compact size and small blind zone.
- Lightweight and fast response time.
- Simple to use with I2C output.
- IP67 waterproof rating.
Specification
- Measurement range: 2-400cm.
- Measurement accuracy: ≤25cm@±1cm, >25cm@±S*4%cm (with an actual error of around 5mm).
- Operating voltage: 3.3-5V.
- Idle current: 2mA.
- Operating current: <19mA.
- Communication method: I2C.
- I2C address:0x74
- Output response time: 19-38ms.
- Power-on delay time: ≤800ms.
- Detection angle: 19°.
- Operating temperature: -15°C ~ 60°C.
- Operating humidity: 65% ~ 80%RH.
- Storage temperature: -30°C ~ 80°C.
- Storage humidity: 65% ~ 90%RH.
Board Overview
Num | Label | Description |
---|---|---|
Red line | VCC | power supply input positive pole |
Black line | GND | power ground wire |
Yellow line | SCL | I2C clock line SCL |
Green line | SDA | I2C data line SDA |
Dimensional Drawing
Installation opening suggestion
Tutorial
Requirements
- Hardware
- DFRduino UNO R3 (or similar) x 1
- Laser Ranging Sensor(4m) x1
- Software
Connection Diagram
Sample Code
#include "Wire.h"
#define address 0x74
uint8_t buf[2] = { 0 };
void setup() {
Serial.begin(115200);
Wire.begin();
}
uint8_t dat = 0xB0;
int distance = 0;
void loop() {
writeReg(0x10, &dat, 1);
delay(50);
readReg(0x02, buf, 2);
distance = buf[0] * 0x100 + buf[1] + 10;
Serial.print("distance=");
Serial.print(distance);
Serial.print("mm");
Serial.println("\t");
delay(100);
}
uint8_t readReg(uint8_t reg, const void* pBuf, size_t size) {
if (pBuf == NULL) {
Serial.println("pBuf ERROR!! : null pointer");
}
uint8_t* _pBuf = (uint8_t*)pBuf;
Wire.beginTransmission(address);
Wire.write(®, 1);
if (Wire.endTransmission() != 0) {
return 0;
}
delay(20);
Wire.requestFrom(address, (uint8_t)size);
for (uint16_t i = 0; i < size; i++) {
_pBuf[i] = Wire.read();
}
return size;
}
bool writeReg(uint8_t reg, const void* pBuf, size_t size) {
if (pBuf == NULL) {
Serial.println("pBuf ERROR!! : null pointer");
}
uint8_t* _pBuf = (uint8_t*)pBuf;
Wire.beginTransmission(address);
Wire.write(®, 1);
for (uint16_t i = 0; i < size; i++) {
Wire.write(_pBuf[i]);
}
if (Wire.endTransmission() != 0) {
return 0;
} else {
return 1;
}
}
Expected Results
View the distance value detected by the sensor through the serial port.
FAQ
For any questions, advice or cool ideas to share, please visit the DFRobot Forum.