UPDATE 2: Serial commands and timing information are now available here.
UPDATE: I've posted code to parse the serial datastream here.
This is a tutorial on how to get serial data out of a cheap handheld laser distance meter, which can be fed into an Arduino or a PC. You can use the distance measurements in all sorts of projects like robots and quadcopters. There are vendors who sell conversion kits that sniff the distance measurement off the LCD and output it over serial. The problem with those kits is that they cost more than the laser meter itself. Luckily I managed to find a laser distance meter that outputs distance measurements over serial directly: the UT390B from Uni-T which sells for about $62 from online retailers (that is an affiliate link). Laser distance meters use precise electronics to measure the length of time it takes a laser beam to reflect back from a target. Handheld units like this one have a range of about 0.2m - 40m with a precision of 2mm or so. They're a great replacement for HC-SR04 ultrasonic sensors if you need long range measurements.
Preparing the unit
You can see the unit's debugging port underneath the battery cover. To take it apart, remove the 2 visible screws.
Now you can pry off the cover.
This ribbon cable connects the unit's keypad. Scrape off the glue and unplug it for now.
Next, remove the 2 screws with washers that hold the rubber piece at the front. If you want to remove the screen, it's connected by 4 clips to the circuit board. It's probably a better idea to leave the screen connected, so you can verify that the unit is working properly while you're testing your serial parsing code.
DON'T remove these 3 screws. They connect the laser diode to the circuit board, and if you loosen these screws you risk breaking your laser. The easiest way to access the debug port is by desoldering the battery connector as shown below. Note: this photo shows the 3 screws removed. DO NOT do this, as it's unnecessary and could cause the unit to break in two. Finally you can solder some thin wires to the debug port. The pinout is as follows, seen from below the board. We can replace the original keypad with a microcontroller which can simulate button presses to control the unit. The keypad pinout is below. The ribbon connector is 8 pin, 1mm pitch. If there's enough interest, I will assemble and sell a small interface board to break out the necessary signals.
Decoding the serial output
This unit's serial port runs at 115200 baud (8N1). On bootup, it outputs the following text with
\r\n line endings:
ldpara:395 curent ver:420411 Year:Jan 21 2013 Time:13:53:10 ldpara:395 Iint OK APDMIN=136 APDMAX=167 BIASVOLMIN=2307 BIASVOLMAX =1718
Notice "APDMIN" and "APDMAX", which are likely calibration values for the avalanche photodiode used to detect the reflected laser beam. A few sloppy printfs as well.. To turn the unit on, connect the ON signal to GND for about 300ms. Once it's on, the ON signal is also used to take a measurement. After a measurement is taken, the unit outputs the following:
Dist: 2827,curtemp =21 V2.0 nDist: 2827,tempDv=0
nDist values are in millimeters. As far as I can tell, the two measurements are always identical. If there's a measurement error (Error 154, out of range or sensor error) the unit will output:
OUT_RAN dist = 30
If the unit can't determine the average distance (Error 160, sensor shaking too much or Error 155, signal too weak) the unit will output one of the following lines:
MEDIUM2 AND THIN NOT MATCH MEDIUM1 AND MEDIUM2 NOT MATCH THICK AND MEDIUM1 NOT MATCH MEDIUM1 AND MEDIUM2 NOT MATCH
When you turn it off, it outputs:
SysPowerOff! WriteTestData TRUE
I'd like to find a way to control the unit over serial. So far all I've found is that sending
0x23 ('#') or
0x73 ('r') will cause the unit to power down. It seems to ignore every other byte, as well as some common english words and modbus commands. If you manage to find any other byte sequences, email me or leave a comment below. If you liked this article, you might also like DORI, my robot project. DORI uses a slightly different laser distance measurement strategy. You can learn more on the project homepage and in my thesis.