XBee to 328p communication

So, I am trying to make XBee working with 328p controller with no luck so far. I have following connections

Xbee => 328p

pin10(GND) => gnd pin9 (sleep) => D8 (PB0) pin1 (power) => 3.7 V pin2 (UART out) => RXD(PD0) pin3 (UART in) => TXD (PD1)

At the receiver end I have Arduino Uno + Xbee Shield + Xbee.

First of all I am trying to configure the network etc. for microcontroller + Xbee configuration by following code

void setCommands() {
   
              digitalWrite(13, HIGH);    // set the LED on
  // put the radio in command mode:
  Serial.print("+++");
  
  // wait for the radio to respond with "OK\r"
  char thisByte = 0;
  while (thisByte != '\r') {
    if (Serial.available() > 0) {
      thisByte = Serial.read();
    }
  }
  Serial.print("ATDH0\r"); //destination High and Low addresses
  Serial.print("ATDL8119\r"); //... 
  Serial.print("ATMY1999\r");    // set my address (16-bit addressing)
  Serial.print("ATID2403\r"); // PAN ID
  Serial.print("ATSM1\r"); //sleeping mode
  Serial.print("ATD70\r"); //preventing Arduino reset while Xbee on sleep
  Serial.print("ATCN\r"); // exit command mode
        digitalWrite(13, LOW);    // set the LED off
}

Led is for indication when 328p reaches the end of the code. I can see that this program is sending something (probably +++), since the receiver end (programmed to read and print) prints "square" signs.

This code works when micro controller is still connected to Arduino Uno and Xbee through Xbee shield.

At the moment I don't know what is going on and how to correct this. Any help would be appreciated.

Ok, I have a feeling that this problem is due to clock rate mismatch since I am using internal 8Mhz oscillator of 328p. If I have understood correctly I would have to change the baud rate of the communication. Anyone has similar kinds of experiences?

Ok, I have a feeling that this problem is due to clock rate mismatch since I am using internal 8Mhz oscillator of 328p.

Why are you not using a proper 16MHz external crystal and capacitors? Cost is minimal.

Hello and thanks for the reply. I am trying to get by with smallest amount of external components possible.

Yes, this problem was solved already. Just had to change the clock rate of 328p from 16Mhz to 8Mhz. This is done from board.txt file.