Data sent in flutter but not received in HC-05

I have the following flutter code:

void sendData() async{
  print("Sending Data to hc 05  bluetooth");
  int i=0;
  int contact1, contact2;
  Uint8List mobileData = Uint8List(4);
  if(bluetoothCheck) {
    if(currentUser.quickAccessList!=null) {
      for (var j in currentUser.quickAccessList!) {
        contact1 = (double.parse(j.mobile.toString())).toInt();
        contact2 = (double.parse(j.mobile.toString()) % 100000).toInt();
        print(contact1.toString());
        ByteData.view(mobileData.buffer).setInt32(0, int.parse(contact1.toString()), Endian.little);
        connection!.output.add(mobileData);
        await connection!.output.allSent.then((_) {
          print("Sent Data");
        }).catchError((error) {
          print('Error: $error');
        });
      }
    }
  }
}

The output of flutter code is:

Sending Data to hc 05  bluetooth
I/flutter (31463): 639999999
Sent Data

My arduino code:

SoftwareSerial mySerial(8, 9);

void setup(){
mySerial.begin(38400);
}

void loop(){
  Serial.print(mySerial.available());
  if (mySerial.available()>0) {
    // Read the incoming byte from Bluetooth module
    char receivedChar = mySerial.read();
    receivedChar += 30;
    
    // Print the received byte to the Serial Monitor
    Serial.println("Received: ");
    Serial.println(receivedChar);
  }
}

Output in arduino is just 0 in mySerial.available(). Other than that no output is shown.

I ensure that my bluetooth is connected to flutter.

What is the received byte is NOT a character?

It's just a comment. You can ignore that

Data at that rate in software serial is not a good idea. This particularly applies if you have not configured HC-05 to 38400, and you probably don't need 38400 anyway.

Even if I change the baud rate to 9600, same result persists

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