APM Ultrasonic Distance Measuring Sensor (20 - 720cm) - GY-US42
-
RM60.00
- Product Code: GY-US42
- Availability: In Stock
Pins
Communication Protocol and Operation Steps:
5.1. Serial communication parameters: 9600,N,8,1/115200,N,8,1(default baud rate is 9600bps)
5.2. Module output format: Each frame contains 8-13 bytes (hexadecimal):
- Byte0:0x5A,frame header flag
- Byte1:0x5A,frame header flag
- Byte2:0x45,this frame data type(represents that this frame data is distance data)
- Byte3:0x02,the amount of data
- Byte4:0x00~0xFF,the first 8 bits of data
- Byte5:0x00~0xFF,lower 8 bits before the data
- Byte6:0x00~0xFF,checksum (the previous data is accumulated and only the lower 8 bits are left)
5.3. Distance length calculation method:
- Distance=(Byte3<<8)|Byte4 (cm)
5.4. Serial command command:
- Command format: 0xA5+command+command+sum checksum
- Sum checksum=sum of the first three data, take the lower 8 bits
5.5 .Output mode setting instruction:
- 0xA5+0x55+0x15+0x0F:Query IIC address
- 0xA5+0x56+0x01+0xFC:Query output distance data
- 0xA5+0x56+0x02+0xFD:Continuous output distance data, about 10hz (default)
5.6. IIC address setting instruction:
- 0xA5+0x57+addr+sum:addr is the IIC 8-bit address, the lowest bit must be 0
5.7. Baud rate configuration:
- 0xA5+0x58+0xAE+0XAB:9600 (default)
- 0xA5+0x58+0xAF+0XAC:115200
5.8. Save/restore configuration:
- 0xA5+0x5A+0x01+0X00:Save output configuration,IIC address, baud rate configuration
- 0xA5+0x5A+0x02+0X01:Restore factory settings, restore IIC address, baud rate
5.9. Operation steps in serial mode:
- Use USB to TTL module or MCU to connect with GY-US42 module
- TX-RX,RX-TX, the wiring method is cross connection.
- The GY-US42 module defaults to automatic output. The TX pin sends data. You can get data directly on the serial port. For the format, refer to the communication protocol.
- For other operations, you can refer to the protocol to send corresponding instructions.
Tags: Ultrasonic