In order to have some visible output on the serial monitor I've added two serial.print, one linked to the float "distance", the other linked to the float "angle", but the only output which i managed to get on the serial monitor is like a reverse question Mark.
Somebody has encountered the same trouble and in which way It can be solved?
The connection are:
Pwm of Lidar with PIN 3
Gnd of the lidar with the gnd of the board
RX to tx1 and TX to rx1
5V of the Lidar with the 5V PIN of the board
Please post your code, in line, using code tags. Posting hints are in the the "How to get the best out of this forum" post, linked at the head of very forum category.
Make sure that serial Baud rates are matched between the serial monitor and the program code.
Why do you use Serial1.begin() and lidar.begin() twice?
If you look at the library, lidar.begin() does not return any value.
I don't know why it would return 0 for distance and angle. Check whether the power supply is adequate for operation.
// open the given serial interface and try to connect to the RPLIDAR
bool RPLidar::begin(HardwareSerial &serialobj)
{
if (isOpen()) {
end();
}
_bined_serialdev = &serialobj;
_bined_serialdev->end();
_bined_serialdev->begin(RPLIDAR_SERIAL_BAUDRATE);
}
I am facing same problem, I want to run s2 rplidar with arduino mega but I am getting no where , having issues with library I guess, can you help me out.
best regards
Unfortunately we haven't yet find a solution to this trouble, we tried to change the Rx pin with the tx pin and we got some value, but this number seems to be without any sense and the sensor seems to be steady during the execution of the code.
So if you have any idea or any type of doubts that can help us (we and you) to find a solution you can post in this page of the forum, if you would obv.
Best regards, hoping to solve once for all this annoying problem.
Maybe this library doesn't support s2 rpLidar. GitHub - Slamtec/rplidar_sdk: Open source SDK for Slamtec RPLIDAR series products. This is some repo i tried to follow, i could run given client frame grabber with prebuild arduino nano code, but I want Api access so I can do it in Arduino Mega.
I hope we find some solution soon.
Hi @saad2212, we're thinking that the problem derive from the voltage od the pin rx/tx (which is 5V) because the lidar works with a voltage between 3.2V to max 3.5V (source: salmtec datasheet), so we gonna try with a resistive devider from rx/tx to gnd to reduce the voltage to the expected 3,3V, then, if it works, we gonna improve this condition with a level shifter. But we have a doubt with that consist between which pin we have to put the voltage divider? we thought from tx/rx to gnd, but we don't know if that solution have any sense. what do you think about that? Let us know.
Best regards to you and to anyone that would help us.
Hi, I also looked into the possibilities for getting RPLidar S2 to work in Arduino context. I am a hobby Arduino-coder and I have limited skills in the C++ coding world. From the research I did about the availability of Arduino libraries for this RPLidar S2 I must conclude that at present NO Arduino specific library is available for reading the S2 lidar data. The S2 model is only supported in the most recent SDk v2.x by Slamtec ( dated 2022), but not in any of the previous SDK versions. On top, the available Arduino libraries refer only to A models (A1-A3) requiring a Motorcontrol command that is needed to start to the scan operation. The S2 model does not have that feature. I checked wit Slamtec if an S2 Arduino specific library is/would become available: no plans at this time. But I did found a library for an ESP32-Arduino at github GitHub - KKest/ESP-rplidarS2: ESP32 (Arduino) RPLIDAR S2 interface library, that looked interesting for starting experimenting with S2 model. An Arduino-ESP32 is cheap and much more powerfull versus the AVR Arduino boards such as the Una and Mega 2560. I ordered an Arduino ESP32 board an will test the library developed by KKEST.
In addition , it should be possible to adapt the ESP32 code to Arduino code, according to Mr/Ms chatGPT. I will keep you posted. Greetz, YankBoy
Hi, @yankoboy wow thx for your contribution, i'm gonna study this new library and if it will be possible i'll test the code on the arduino ble33 (that is the most similar board to the sp32 from our "collection"). Please when you have some interesting news post here; maybe we'll very close to the solution. Best regards Elax.
Hi ELAX2002, don't waste time in testing Arduino Nano 33 BLE with the ESP library without code modification. I did that already and it results in several compilation errors in the Arduio IDE 2.x. According to chatGPT, modifications are mainly required in the Serial communication part of the code. I did limited trials with code modification but failed. These modifications go pretty deep in the ESP32 library code. But I am not a C++ expert. I let you know if I had the ESP32 library working on the Arduino ESP32 board. Greetz!
Alo, alo Elax2002,
I did experimented with a NodeMCU-ESP32 -Joyit (replacing the Arduino ESP32 for now) using the KKest library with partial succes. The RPLidar S2 connected tot the NodeMCU-ESP32 and did work well for about 3 minutes showing correct data in the Arduino IDE monitor. However after that I couldn't get the device to start up again, even not by hard reset or relaoding program. Still, the device responds OK when reconnected to the Robostudio via the Serial/USB converter, so not broken. I shared my observations with KKest, the library author, for his inputs.
I retry the Arduino ESP32 this week and wait for the KKest inputs. All idea's to solve this are welcomed. As mentioned earlier I am a hobby coder and I am rather a library-user than a library-programmer. Greetz.
@elax2002, @yankoboy:
I just ran across this thread. I’ve just finished a ESP32-specific port for Slamtec’s SDK v2.0.0. My code is available here. It requires an ESP32 board with PSRAM. I’ve only tested it on an A1 model, so I’d be interested in results with an S2. Try the included example program. I think you’ll need to increase the baud rate of Serial2 to 1000000 for the S2 model. You may also need to make changes for motor control, etc.
I also have an ESP32 port of Slamtec’s SDK v2.1.0, but have not yet put it on GitHub.
PS:
You should probably also increase the baud rate of Serial so the printing keeps up.
I have used your library and it works great using an Arduino Nano ESP32 and Slamtec RPLidar A1 (firmware 1.29). I appreciate your hard work to port it to the ESP32. I have tested the Standard and Express modes. Are the other modes (Boost, etc.) dependent on the RPLidar firmware version? By the way, for what purpose are you using the PSRAM?
Note the assert() statements in sl_lidar_driver.cpp. They should cause a run-time exception if the call to ps_malloc() failed (I should have also added an assert() to the example code, my bad.). So, I can't explain what's going on with the ESP32S3 and I don't have one to test.