Esp23 Wroom-32 Bluetooth processing problem

Hello everyone,

I'm working on an ESP32 project where I need to receive messages over Bluetooth, accumulate them, and display the complete message. The goal is to simply gather data until a newline (\n) character is received, then print the entire message to the serial monitor.

However, I keep running into issues:

  1. Data Fragmentation: It seems that Bluetooth data is being split or cut off, resulting in incomplete messages. The received message sometimes stops in the middle or doesn't include everything I expect.
  2. Watchdog Timer Errors: I'm getting repeated "task_wdt: esp_task_wdt_reset(763): task not found" errors. `#include <BluetoothSerial.h> // For Bluetooth communication
BluetoothSerial btSerial;
String messageBuffer = "";

void setup() {
  Serial.begin(115200);
  btSerial.begin("ESP32_Player");
  Serial.println("Bluetooth initialized. Waiting for data...");
}

void loop() {
  while (btSerial.available()) {
    char receivedChar = btSerial.read();
    messageBuffer += receivedChar;

    if (receivedChar == '\n') {
      Serial.println("Received complete message:");
      Serial.println(messageBuffer);
      messageBuffer = "";
    }
  }
  delay(10);  // Small delay to avoid watchdog issues
}
`

Bluetooth initialized. Waiting for data...
Received complete message:
Set up: (0), (10/26/2024 22:43:50)

Received complete message:
Set up: (0), (10/26/2024 22:43:50)
Playtime for month: 1

Received complete message:
Set up: (0), (10/26/2024 22:43:50)
Playtime for month: 1
(01-01|05:59,11:58,14:02,16:42,17:45)

Received complete message:
Set up: (0), (10/26/2024 22:43:50)
Playtime for month: 1
(01-01|05:59,11:58,14:02,16:42,17:45)
(02-01|05:59,11:58,14:03,16:43,17:45)

Sounds like a duplicate problem.

What is sending the data? What is the sending format?

Am using mit app inventor (send text via Bluetooth block ) i had no issue when i was using the Arduino uno. After switching to esp32, am having difficulty

Hi everyone!
I'm working on a project that involves integrating an ESP32 (WROOM-32), DFPlayer Mini, DS3231 RTC, and Bluetooth communication to play scheduled audio tracks based on specific times sent via Bluetooth.

The goal:

  • Set the current date and time on the RTC via a Bluetooth message (e.g., Set up: (0), (10/25/2024 21:07:11)).
  • Receive daily playtime schedules through Bluetooth, like:
Playtime for month: 1  
(date|playtime1,playtime2,.....playime5)
(01-01|05:59,11:58,14:03,16:42,17:45)  
(02-01|05:59,11:58,14:03,16:43,17:45)  
...
  • Trigger the DFPlayer Mini to play a specific track when the current time matches the scheduled playtime and date. Current Issue:

I’m struggling with two key challenges:

  1. Parsing the Bluetooth message to correctly set the date and time on the RTC. The year, month, day, hour, minute, and second are not being extracted properly. And to parse the playtime/date.
  2. Implementing the playtime logic that checks the RTC’s current time and compares it to the daily playtime schedule, triggering the DFPlayer Mini to play the assigned audio track.

Any tips on fixing the time parsing issue and advice on managing the playtime logic would be greatly appreciated!

Thanks in advance for your help!

Sorry we don't write apps here. If you wire up the hardware and write the code to the best of your ability and it doesn't work as expected, then come back and post the wiring diagram, then post the code in code tags plus if errors the error log in code tags.

You may have misunderstood my post, I did not ask anyone to write the code for me, i just asked if someone had any advices on the problem am currently facing. Or if anyone had similar project and the past and would like to share the logic they used to solve the issues of Parsing and Implementing the playtime logic .

Thank you for your reply!

Show us the code.

Start by making the esp work with one device. Then add the second device and make it work. Make sure both work at the same time.
Add the next device...

@fryan22 ,

Your two or more topics on the same or similar subject have been merged.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

can you explain more on how to solve, all my other code is useless if am not receiving the text via Bluetooth correctly

How were you reading Bluetooth with a Uno?
What model of esp32 are you using?

If you're getting watchdog errors then you're not loop'ing in time enough - you're sketch is stuck waiting for something too long.

This is trouble --

btSerial.begin("ESP32_Player");`

You need to pay attention to posts #9, 10, 13
So far you have only posted high level specs (I suspect from school) You have not responded to any of the suggestions. Until you put in some effort, we will not be motivated to help.

what do you propose instead?

they are two different subject, one is concern receiving Bluetooth message, and the other one is about parsing logic. i think it was appropriate to have two different post.

HC05 module and am using a esp32 WROOM-32

A baudrate, an rx pin, a txpin.

Is the code in Post#1 what you were using on the Uno with the HC05 when the bluetooth was working properly?

If you do not use your app inventor code, but instead a bluetooth terminal program like Kai Morich's Serial Bluetooth Terminal do you see the same issues.

It appears to me that unexpected '\n' line terminators are being sent.

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