NB-IoT Shield + Arduino MEGA 2560 can't communicate with AT commands (SOLVED)

Hello All, great to know about this forum
I’ve just got the NB-IoT shield lately and I am using MEGA 2560 kit.
It seems I have some problems getting the AT commands to work I am getting nothing when I send AT in the serial monitor , here is the sketch I used :

#include "Arduino.h"

#if defined(ARDUINO_AVR_LEONARDO)
#define SerialOut Serial 
#define UBLOX Serial1

#elif defined(ARDUINO_SODAQ_EXPLORER)
#define SerialOut SerialUSB
#define UBLOX Serial

#elif defined(ARDUINO_SAM_ZERO)
#define SerialOut SerialUSB
#define UBLOX Serial1

#elif defined(ARDUINO_AVR_MEGA2560)
#define SerialOut Serial 
#define UBLOX Serial

#else
#error "Please select a Sodaq ExpLoRer, Arduino Leonardo or add your board."
#endif

// Pin to turn on/off the nb-iot module
#define powerPin 7 

void setup() 
{
  // Turn the nb-iot module on
  pinMode(powerPin, OUTPUT); 
  digitalWrite(powerPin, HIGH);

  // Start communication
  SerialOut.begin(9600);
  UBLOX.begin(9600);
}

// Forward every message to the other serial
void loop() 
{
  while (SerialOut.available())
  {
    uint8_t c = SerialOut.read();
    SerialOut.write(c);
    UBLOX.write(c);
  }

  while (UBLOX.available())
  {     
    SerialOut.write(UBLOX.read());
  }
}

Uploading the sketch went successfully, but the outcome is nothing.
Any suggestions , I am pretty new to this and hope I am not missing silly operations.

Thanks.
Maad

Try this:

// Pin to turn on/off the nb-iot module
#define powerPin 7 

void setup() 
{
  // Turn the nb-iot module on
  pinMode(powerPin, OUTPUT); 
  digitalWrite(powerPin, HIGH);

  // Start communication
  Serial.begin(9600);
}

void loop() 
{
}

Thanks Gabriel , but this did not work.
I don’t know if this NB-IoT shield is compatible with Arduino MEGA 2560 or not or is there minor changes in the code I should change.

It should be compatible. The only issue is that Serial is used for both connecting to the USB and to the header pins 0/1 (which are connected to the NBIoT module).

You could try removing this line:

    Serial.begin(9600);

as it should be unnecessary as the MCU is not sending data over the USB connection. This should allow a direct connection to the NBIoT module.

Make sure you are sending both cr/lf as your line endings.

Still no hope.
I cant get any response.

You could try using another UART for the NBIoT module, Serial1 for example

You will need to have the shield detached and wire the required pins.

You will need to connect 3.3v, GND, and D7. Additionally if you use Serial1, connect RX1 on the Mega to D0 on the shield and TX1 to D1.

http://support.sodaq.com/wp-content/uploads/2017/02/nb-iot_shield_rev3b_sch-1.pdf

As suggested by you I had to detach it and connect it to another UART to make it function successfully.
Thanks