Bluemate sending/receiving Problem

Hello Community,

i have two Mega2560 with Bluemates on it. My problem is they didn't get any messages from each other. I have a switch which i can toggle, if its pushed it should send a 'b' to the other Bluemate. But i dindt work. I tried it with diffrent Baudrates (115,2k and 9,6k). Everytime they connect but they didnt get messages. Here is the code for Master and Slave.

//MASTER
void initMaster(){
  Serial2.begin(9600);
  Serial2.print("$$");
  delay(50);
  Serial2.println("SM,1");
  delay(50);
  Serial2.println("C,00066645B71F");
  delay(50);
  Serial2.println("---");
}

void setup(){
 initMaster();
 pinMode(30, OUTPUT);
 pinMode(13, OUTPUT);
}

void loop(){
    if (digitalRead(30) == true){//Switch pushed
      Serial2.println('b');
    }
   
    if (Serial2.read() == 'b'){
      led(1);//switch led on port 13 on/off
      delay(1000);
      led(0);//switch led on port 13 on/off
    }
    else{
      led(0);//switch led on port 13 on/off
    }
}
//SLAVE
void initSlave(){
  Serial2.begin(9600);
  Serial2.print("$$");
  delay(50);
  Serial2.println("SM,0");
  delay(50);
  Serial2.println("---");
}

void setup(){
 initSlave();
 pinMode(30, OUTPUT);
 pinMode(13, OUTPUT);
}

void loop(){
    if (digitalRead(30) == true){//Switch pushed
      Serial2.println('b');
    }
   
    if (Serial2.read() == 'b'){
      led(1);//switch led on port 13 on/off
      delay(1000);
      led(0);//switch led on port 13 on/off
    }
    else{
      led(0);//switch led on port 13 on/off
    }
}

Maybe you can help. Have a nice day, Tobs.

Check the baudrate of your bluetooth device. Mine defaults to 38400. You haven’t provided a link to a datasheet or the like, so I was unable to check myself.

Hello Pylon,

this is the datasheet. It says it has no specific baud rate, it resets after each power off.

The datasheet is not very clear about it, but from the pin description of pin 4 (page 4) it seems 115200 is the default baud rate. If you take pin 4 HIGH you force it to 9600 so you can change the standard baud rate. I’d try 115200 and use that pin if you are not successful. Alternatively you can use pin 22 (PIO 4) to reset the module to factory defaults (which probably are 115200).