adbasl
March 14, 2023, 5:31pm
1
Hello everyone,
I recently tried to follow the code and assembly instructions provided by the manufacturer for a Lidar sensor, but unfortunately, I am only getting 0 values in return. I am not sure what the issue could be and I am having trouble understanding the problem.
These is the code and the instructions I followed so, in fact with the if condition I have no return.
Has anyone experienced a similar issue or have any advice on how to troubleshoot this problem? Any help would be greatly appreciated.
Thank you.
Please post your code, in code tags,
like this
Also, tell us more about your sensor.
Please read and follow the instructions in the "How to get the best out of this forum" post.
adbasl
March 14, 2023, 5:40pm
4
Sorry, there is the code
> Blockquote
void getTFminiData(int* distance, int* strength) {
static char i = 0;
char j = 0;
int checksum = 0;
static int rx[9];
if(Serial.available()) {
rx[i] = Serial.read();
if(rx[0] != 0x59) {
i = 0;
} else if(i == 1 && rx[1] != 0x59) {
i = 0;
} else if(i == 8) {
for(j = 0; j < 8; j++) {
checksum += rx[j];
}
if(rx[8] == (checksum % 256)) {
*distance = rx[2] + rx[3] * 256;
*strength = rx[4] + rx[5] * 256;
}
i = 0;
} else {
i++;
}
}
}
void setup() {
Serial.begin(115200);
}
void loop() {
int distance = 0;
int strength = 0;
getTFminiData(&distance, &strength);
while(!distance) {
getTFminiData(&distance, &strength);
if(distance) {
Serial.print(distance);
Serial.print("cm\t");
Serial.print("strength: ");
Serial.println(strength);
}
}
}
adbasl
March 14, 2023, 5:43pm
5
Thank you sorry.
So I use an Arduino Yun with a Mac Laptop with the IDE arduino 1.8.9
I plugged the 5V and the GND and when I transfer my code to my arduino then i Plug mi TX to my RX on Arduino
It sounds like the sensor and the Arduino are not communicating. But there is not enough information in your posts to guess why.
What does this mean?
then i Plug mi TX to my RX on Arduino
Please post a picture of a hand drawn wiring diagram, with pins and connections clearly labeled, and a photo of your setup.
adbasl
March 14, 2023, 6:02pm
7
There is the picture :
TFmini's TX is plugged on Arduino's RX.
That is a picture of an Arduino Uno, taken from the TFmini library web site.
You claim to have a Arduino Yun, which is a completely different board.
Do not expect valid answers from the forum if you post incorrect information.
adbasl
March 14, 2023, 6:29pm
9
It's the same but if you want there is mine :
TTFmini's TX is plugged on Arduino's RX and
TTFmini's RX is plugged on Arduno's TX.
system
Closed
September 10, 2023, 6:29pm
10
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.