ESP32 bluetooth freezing the board

maroguimo
Posts: 1
Joined: Sat Sep 05, 2020 6:13 pm

ESP32 bluetooth freezing the board

Postby maroguimo » Sat Sep 05, 2020 6:40 pm

I have a mobile project with the ESP32 Wroom card that reads a sensor through the serial port and sends the data via Bluetooth so that an Android APP handles the information. The circuit is powered by an external battery. There is a circuit that, once connected, keeps the board on until a button is pressed. When the APP connects to bluetooth, an LED lights up to indicate the connection.

When I go to the street with the sign to take the readings, ESP32 is randomly freezing. The APP loses its connection with the bluetooth, but the indicative LED remains on and the button to turn off does not work anymore, leaving the plate as if it were frozen. To get it working again, I have to disconnect the battery or press the reset button.

The problem is occurring at random, sometimes I use the circuit all day and it doesn't freeze. Sometimes with little use, the circuit freezes.

The source code looks like the following:
  1. void readData() {
  2.   if (Serial2.available()) {
  3.     SerialBT.write(Serial2.read());
  4.   }
  5.   if (SerialBT.available()) {
  6.     Serial2.write(SerialBT.read());
  7.   }
  8. }
  9.  
  10. void callback(esp_spp_cb_event_t event, esp_spp_cb_param_t* param) {
  11.   if (event == ESP_SPP_SRV_OPEN_EVT) {
  12.     ... turn on LED
  13.   }
  14.  
  15.   else if (event == ESP_SPP_CLOSE_EVT) {
  16.     ... turn off LED
  17.   }
  18. }
  19.  
  20. void checkbutton() {
  21.   If the button is pressed then
  22.     digitalWrite(PIN, 0); // TURN OFF THE CIRCUIT. THE PIN IS PULLUP TO KEEP THE BOARD ON
  23. }
  24.  
  25. void setup() {
  26.   Serial2.begin(19200);
  27.   SerialBT.begin(DEVICE_ID);
  28.   ...
  29.   SerialBT.register_callback(callback);
  30. }
  31.  
  32. void loop() {
  33.   readData();
  34.   checkbutton();
  35.   delay(1);
  36. }
Has anyone had a similar problem?

Who is online

Users browsing this forum: inF1704 and 81 guests