Serial.write

I want to send what this function print on serial monitor
To be sent via bluetooth to mobile app.
get_RFID_name that function
Should i be using something like
Serial.write ( buffer , len );
If so what should the paramters be
If not how can i ?

// Bluetooth
#include <SoftwareSerial.h>
SoftwareSerial HC05(2,3) ;
String data ;
int Data;
// RFID
#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9
 
MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class

MFRC522::MIFARE_Key key;

// Init array that will store new NUID
byte nuidPICC[4];

int R_Forward = 5;
int R_Backward = 8;
int L_Forward =  6;
int L_Backward = 7;


void setup() {
 Serial.begin (9600) ;
 HC05.begin (9600) ;
 
 //Right wheel
 pinMode (R_Forward,OUTPUT) ;
 pinMode (R_Backward,OUTPUT) ;
 //Left wheel
 pinMode (L_Forward,OUTPUT) ;
 pinMode (L_Backward,OUTPUT) ;

 SPI.begin(); // Init SPI bus
  rfid.PCD_Init(); // Init MFRC522

  for (byte i = 0; i < 6; i++) {
    key.keyByte[i] = 0xFF;
  }

}

void loop() {

  if (HC05.available()>0) {
   data = HC05.readString() ;
    Data = data.toInt();
 //  Serial.println (Data);
  } 

 switch (Data)
      {
        case 1:
               Forward ();
               Serial.println("Forward");
                  break;
        case 2:
               Left ();
               Serial.println("Right");
                  break;
        case 3:
               Stop ();
              Serial.println("Left");
                  break;
        case 4:
               Right ();
               Serial.println("Backward");
                  break;
        case 5:
               Backward ();
               Serial.println("Stop");
                  break;      
        case 6:
               get_RFID_name ();
                  break;
        }
}

void get_RFID_name ()
{
  
  // Look for new cards
  if ( ! rfid.PICC_IsNewCardPresent())
    return;

  // Verify if the NUID has been readed
  if ( ! rfid.PICC_ReadCardSerial())
    return;

 for (byte i = 0; i < 4; i++) {
      nuidPICC[i] = rfid.uid.uidByte[i];
    }
   
  printHex(rfid.uid.uidByte, rfid.uid.size);
    Serial.println();
   rfid.PICC_HaltA();
  rfid.PCD_StopCrypto1();
}

void printHex(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], HEX);
  }
  }

Which function? You have several using Serial.print()

I want to store what this function prints on the Serial monitor into a variable
photo attached

// Look for new cards
  if ( ! rfid.PICC_IsNewCardPresent())
    return;

  // Verify if the NUID has been readed
  if ( ! rfid.PICC_ReadCardSerial())
    return;

 for (byte i = 0; i < 4; i++) {
      nuidPICC[i] = rfid.uid.uidByte[i];
    }
   
 printHex(rfid.uid.uidByte, rfid.uid.size);
    Serial.println();
   rfid.PICC_HaltA();
  rfid.PCD_StopCrypto1();
}

void printHex(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], HEX);
  }

get_RFID_name()

I want to send what this function print on serial monitor
To be sent via bluetooth to mobile app.

I want to store what this function prints on the Serial monitor into a variable

Please clarify what you want help with.

The printed values are in a variable, it is a byte array.

I want to send this value which is in a byte array to a mobile application via bluetooth module

This is the code which prints the array to the monitor

void printHex(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], HEX);
  }

I think that if you add an HC05.print() where you have a Serial.print() the data will be sent to the mobile app as well.

void printHex(byte *buffer, byte bufferSize) {
 for (byte i = 0; i < bufferSize; i++) {
   Serial.print(buffer[i] < 0x10 ? " 0" : " ");
   HC05.print(buffer[i] < 0x10 ? " 0" : " ");
   Serial.print(buffer[i], HEX);
   HC05.print(buffer[i], HEX);
 }

@HassanBosha20

Do NOT CROSS POST.

Duplicate DELETED.

Please READ THIS POST for future reference.

Bob.