There are a few things you need to be clear
1. Study the tutorial that you shared and wanted to do. It does not uses Xbee shield to connect the Arduino main board to the Bluetooth module, so it can choose which ever pins to communicate with Bluetooth module via Software Serial. It the tutorial case, it uses pin 10 and 11 (original), but the code you share uses pin 2 and 3 instead.
2. Why he uses pin 10 and 11? Because pin 0 and 1 is the hardware UART which are always connected to USB to UART chip on the Arduino main board. And he need the hardware UART to send to computer to show the result on serial monitor, that is the easiest way to show result.
3. The
XBee ShieldXBee shield is compatible with Xbee/BlueBee and Arduino main board, but it is not designed for your project. It is designed for BlueBee/XBee to communicate with Arduino main board only. However, in your case, Arduino main board need to communicate with laptop (via the USB to UART) and also BlueBee in the same time with the same setup. Hope you understand this.
In simple words: Xbee Shield (the one you have) provides:
Arduino UNO ----pin 0 and 1 ---- XBee Shield -------- Xbee/BlueBee - This allow Arduino to communicate with XBee/BlueBee only, it cannot offers communication with computer and BlueBee at the same time.
The tutorial that you intended to do:
Laptop ------ USB ------ USB to UART on Arduino ----- pin 0 and 1 ------ Arduino ------- pin 2 and 3 ---- Xbee shield --- BlueBee - This setup allows communication with computer and BlueBee at the same time.
But as I said earlier, the communication pins on XBee Shield (the one you have) is pin 0 and 1. In the latest code you shared, Serial and BTserial is using same pins. What ever you send to Serial.print is send to computer and BlueBee, same as what ever you send using BTserial.write, it is send to both computer and BlueBee. That is the reason you get the response of "Error", because BlueBee does not recognize "Enter AT commands" and later "Error", and it keep return "Error" because it keep receiving "Error".
That is the reason why we design improved version of
XBee shield where you can choose the pins you wanted to use for Xbee/BlueBee communication.
My advise, get familiar with UART communication first. Study the nature or this communication, play with it