I'm trying to communicate with this BA6A laser distance sensor (https://www.jrt-measure.com/2004-2021-new-laser-distance-sensor/58854931.html) using an Arduino Uno with a UART protocol; the datasheet for the device is attached below.
The device is supposed to take VCC between 2.5V and 3.3V so I used this level shifter (Bi-Directional Logic Level Converter Hookup Guide - SparkFun Learn) between the sensor and Arduino. I have tested the circuit in three configurations, one with this level shifter and an independent power supply for the sensor (figure 1), one with the Arduino's Vin pin powering the sensor (figure 2), and one with the Arduino's 5V pin powering the sensor (figure 3).
I have written some code attached below that I am testing with just to try to get some functionality out of the sensor. I’m using SoftwareSerial to establish one serial line for the sensor to communicate with the Arduino and another for the Arduino to communicate with my PC for debugging messages.
As specified in the sensor's datasheet, the sensor works by sending an 'O' command in serial to open the laser (or 'C' to close it), and the sensor will return "Ok!". From there, sending 'D' in serial requests a measurement and then the sensor should reply with a distance in meters followed by a unitless quality metric (ex. "1.982m, 0283").
I don't have much experience with UART communication so I've hit quite a few problems. I have confirmed that the sensor has power (the laser is on and sensor VCC is at the intended voltage). When connected to the Arduino via the level shifter as in figure 1, my debugging serial monitor just spits out a bunch of empty messages and a few unrecognized characters and ‘?’ in the mix. It won’t even display the “inByte: ” and “message: ” strings that I print directly from the Arduino to serial.
When I connect the sensor to higher voltage (Arduino Vin or 5V pins as in figures 2 and 3, respectively), the debugging serial monitor is entirely empty, not displaying any messages at all. I have confirmed that the sensor is still powered on in these configurations.
At this point I’m pretty stuck and I would greatly appreciate any guidance this community can offer!
Configuration 1:
Configuration 2:
Configuration 3:
Sensor Datasheet:
20201015205513100M-new(1).pdf (606.2 KB)
Software:
sensor_test_Av2.2.2.ino (1.5 KB)
Note: I used a lot of code from this website to help me get started with UART: Serial.read and Arduino: Here's the advanced stuff you should know