SoftwareSerial at 3.6V and 8MHz

I have a custom board with a 328P running at 3.6V and using the internal oscillator at 8MHz .
I am using the ATmega328 on a breadboard (8MHz internal clock) bootloader.
I am using SoftwareSerial (Rx D10 / Tx D11).
Baud rate is 9600 on the SoftwareSerial and also on the remote Sigfox device.
According to the Sigfox device datasheet I should receive: Example Response: 00012345 (HEX)

However, my Serial Monitor displays:

‚⸮⸮⸮⸮2⸮9457D8

‚⸮⸮⸮⸮2⸮9457D8

‚⸮⸮⸮⸮2⸮9457D8

‚⸮⸮⸮⸮2⸮9457D8

‚⸮⸮⸮⸮2⸮9457D8

‚⸮⸮⸮⸮2⸮9457D8

My Code:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

byte myByte; 

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);

   pinMode(6, OUTPUT);// Set RF Module port
   digitalWrite(6, LOW);// Switch RF Module Mosfet ON
   delay(2000);



  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
//  mySerial.println("AT$I=10");
  delay(100);
}

void loop() { // run over and over

    mySerial.println("AT$I=11");
  delay(2000);

  if (mySerial.available()) {
    String MyData = (mySerial.readStringUntil('\r'));
    Serial.println(MyData), HEX;

  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}
    Serial.println(MyData), HEX;

Should be:

    Serial.println(MyData, HEX);

Except that you can't print a String in HEX. That only works for integers.

By " 00012345 (HEX)" do you mean the four bytes : 0x00, 0x01, 0x23, 0x45?

By " 00012345 (HEX)" do you mean the four bytes : 0x00, 0x01, 0x23, 0x45?
[/quote]

Yes, that is correct

Declan:

Quote from: Declan
By " 00012345 (HEX)" do you mean the four bytes : 0x00, 0x01, 0x23, 0x45?

Yes, that is correct

You generally should not read binary data as if it were a string. Try using:

void loop()   // run over and over
{
  mySerial.println("AT$I=11");
  delay(2000);
  while (!mySerial.available())
  {
    // Waiting for reply
  }
  uint32_t MyData;
  mySerial.readBytes((byte *)&MyData, 4);  // Read four bytes into an unsigned long
  Serial.println(MyData, HEX);
  if (Serial.available())
  {
    mySerial.write(Serial.read());
  }
}