I am trying to read data from an XV-11 sensor using the description of the format found here https://xv11hacking.wikispaces.com/LIDAR+Sensor. This is the code I am currently using to communicate with the computer by USB and the sensor with software serial on an arduino uno.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
mySerial.begin(115200);
}
int count = 0;
void loop()
{
if(mySerial.available())
{
byte in = mySerial.read();
Serial.println(in, HEX);
}
}
However, the data I am receiving on the computer is inconsistent with what I expect. For example, I am expecting a 0xFA byte every 22 bytes, however this only sometimes happens. Many times extra or fewer bytes appear in the middle of the data. I am using the 5 volt arduino serial communication, however I have heard that it is still compatible with 3.3 V sensor communication, so I doubt it is the problem. I don't thinkthe sensor is broken, as it is new from a working unit.