Bluetooth classic & DelimiterByte

I'm creating an RFID card reader with MIT App inventor and ESP32 & RC522 sensor.
Currently, in my app, the DelimiterByte for Bluetooth is set to 0.
And in a timer control I'm testing if Bytes Available To Recieve is greater than 0

In this discussion here in the community guys (@ChrisWard @Patryk_F @ABG ) are saying that this approach is not stable and could cause crashes of the app.

Should I change this? And if yes, what is the DelimiterByte value, I'm pasting here my code from the ESP32 that is sending the string to the Bluetooth if you can check if it is 10 or 13 or something other.


My ESP32 code is:

 * RC522 and  ESP32
#include <SPI.h>
#include <MFRC522.h>
#include "BluetoothSerial.h"

#define SS_PIN 5
#define RST_PIN 22

MFRC522 mfrc522(SS_PIN, RST_PIN);
MFRC522::MIFARE_Key key;

#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
BluetoothSerial SerialBT;

void setup() {
   SPI.begin();      // Initiate  SPI bus
   mfrc522.PCD_Init();   // Initiate MFRC522

   //bluetooth name of the reader
   SerialBT.begin("RFID Card Reader");


void loop() {
   if ( ! mfrc522.PICC_IsNewCardPresent()) {

   // Select one of the cards
   if ( ! mfrc522.PICC_ReadCardSerial()) {

   char str[32] = "";
   array_to_string(mfrc522.uid.uidByte, 4, str); 
   Serial.println(str); //Print the output uid string




void array_to_string(byte array[], unsigned int len, char buffer[])
   for (unsigned int i = 0; i < len; i++)
      if (i == 0)
        sprintf(buffer, "%02X", array[i]);
        sprintf(&buffer[i*3-1], ":%02X", array[i]);

It is correct to test if 'Bytes Available to Receive' is > 0, but then 'Receive Text number of bytes' should use the math block '-1' to receive all bytes.

You could of course check that yourself!

Change your script to this:
SerialBT.println(); //This empty last line tells App "End of Data" = Ascii Line Feed Char Number 10.

Thank you @ChrisWard I have changed the ESP32 code and also changed the MIT AI App.
It all works.
Now let's test if everything will work 24/7 without any craches.
Thank you once again.

1 Like

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