Esp32 Crashing on this code

/*
   RPLidar on ESP32
 
*/
 
#include <HardwareSerial.h>
//HardwareSerial LiSerial(1);
#include "esp32-hal-ledc.h"
 
// This sketch code is based on the RPLIDAR driver library provided by RoboPeak
#include <RPLidar.h>
 
// You need to create an driver instance
RPLidar lidar;
 









void setup() {
  Serial.begin(115200);
 
  // bind the RPLIDAR driver to the ESP32 hardware serial2
  lidar.begin(Serial2);
 
  
 
}
 
void loop() {
    if (IS_OK(lidar.waitPoint())) {
     
 
      //perform data processing here...
      Serial.println("Lidar Get info...");
 
    } else {
      
      delay(15);
      // try to detect RPLIDAR...
      rplidar_response_device_info_t info;
      if (IS_OK(lidar.getDeviceInfo(info, 100))) {
         // detected...
         Serial.println("Lidar Detected...");
         lidar.startScan();
 
         // start motor rotating at max allowed speed
         
         delay(1000);
      }
    }
    Serial.println(int(lidar.getCurrentPoint().distance));


  

}

error mesage


23:08:19.520 -> Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
23:08:19.520 -> Core 1 register dump:
23:08:19.520 -> PC      : 0x400d1b95  PS      : 0x00060330  A0      : 0x800d0fe8  A1      : 0x3ffb1ee0  
23:08:19.520 -> A2      : 0x00000f84  A3      : 0xba400000  A4      : 0x00000002  A5      : 0x0000ff00  
23:08:19.520 -> A6      : 0x00ff0000  A7      : 0xff000000  A8      : 0x00000f84  A9      : 0x00000000  
23:08:19.552 -> A10     : 0x00000000  A11     : 0x3f400532  A12     : 0x00000050  A13     : 0x0000ff00  
23:08:19.552 -> A14     : 0x00000000  A15     : 0x00000000  SAR     : 0x0000000a  EXCCAUSE: 0x0000001c  
23:08:19.552 -> EXCVADDR: 0x00000f90  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xffffffff  
23:08:19.552 -> 
23:08:19.552 -> ELF file SHA256: 0000000000000000
23:08:19.584 -> 
23:08:19.584 -> Backtrace: 0x400d1b95:0x3ffb1ee0 0x400d0fe5:0x3ffb1f00 0x400d1024:0x3ffb1f20 0x400d0dd5:0x3ffb1f40 0x400d0cac:0x3ffb1f70 0x400d226d:0x3ffb1fb0 0x40086125:0x3ffb1fd0
23:08:19.584 -> 
23:08:19.584 -> Rebooting...
23:08:19.584 -> ets Jun  8 2016 00:22:57
23:08:19.584 -> 
23:08:19.584 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
23:08:19.584 -> configsip: 0, SPIWP:0xee
23:08:19.584 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
23:08:19.625 -> mode:DOUT, clock div:2
23:08:19.625 -> load:0x3fff0018,len:4
23:08:19.625 -> load:0x3fff001c,len:1044
23:08:19.625 -> load:0x40078000,len:10124
23:08:19.625 -> load:0x40080400,len:5828
23:08:19.625 -> entry 0x400806a8
23:08:19.751 -> [V][HardwareSerial.cpp:91] end(): pins 0 0

What happens when the backtrace info is put into the ESP Exception Decoder?


#include <HardwareSerial.h>


HardwareSerial SerialTFMini( 1 );
HardwareSerial SerialBrain( 2 );

voiding setups()
{

  Serial.begin( SerialDataBits );
  SerialBrain.begin( SerialDataBits );
  SerialTFMini.begin(  SerialDataBits, SERIAL_8N1, 27, 26 
  tfmini.begin(&SerialTFMini);
}

i found the java app but i dont know how to create it to useable form.(windows)
BTW:lidar used Rplidar a1 https://www.waveshare.com/wiki/RPLIDAR_A1

and i am using arduino ide 2.0

it has same stability issues

i already try it

can you put back trace in to the program to see what is up with that?

How is the lidar connected to the ESP-32?

pins 16,17 or in other words hardware uart 2

Are you sure your library is aware of that?

GPIO_NUM_16 and GPIO_NUM_17 is serial port 1, see post#2.

Hey there I'm having the exact same issue, calling lidar.begin() crashes my esp32, did you find a solution?

I found the solution in case you haven't:
you need to modify the RPLidar.h and RPLidar.cpp files in the RPLidarDrive folder in your Arduino libraries, do the same thing for both files, the begin() function must return void instead of bool

i have fixed by following your solution but the data revice is wrong, have you fixed it or you got the correct data ?

It's been a while since I last worked on that project, but after modifying the library file the lidar worked fine, the data it sent was correct, if you need some help let me know

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.