# GSM fails to connect, two different boards.

**URL:** <https://forum.arduino.cc/t/gsm-fails-to-connect-two-different-boards/680519>\
**Category:** MKR GSM 1400\
**Created:** [October 29, 2020, 9:42pm UTC](https://forum.arduino.cc/t/gsm-fails-to-connect-two-different-boards/680519 "2020-10-29T21:42:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tdarrah](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tdarrah](https://forum.arduino.cc/u/tdarrah)\
**Post date:** [October 29, 2020, 9:42pm UTC](https://forum.arduino.cc/t/gsm-fails-to-connect-two-different-boards/680519/1 "2020-10-29T21:42:14Z")

</div>

Arduino version: 1.8.11  
Environment: Windows 10 desktop  
SAMD boards version: 1.8.9  
Hello, I am trying to just get the board (MKR GSM 1400) to connect by following various boiler plate code examples available from [hologram.io](https://support.hologram.io/hc/en-us/articles/360035696973-Arduino-MKR-GSM-1400) or other threads.  
I have separated the GSM and GPRS functions to help with debugging. I have the device plugged into USB and an antenna plugged in as well. I am not supplying external power. I have tried:

```cpp
gsmAccess.begin();
gsmAccess.begin(PINNUMBER);
gsmAccess.begin(true, false);

```

Out of the last 4 hours I have been messing with this, it connected once. GPRS never did. when I restarted the board, GSM never successfully began ever again. I get the following debug output repeatedly:

_OK_  
_AT+CREG?_  
_+CREG: 0,0_

Here is the code:

```cpp
#include <MKRGSM.h>

const char PINNUMBER[] = " "; 
const char GPRS_APN[] = "hologram";
const char GPRS_LOGIN[] = " ";
const char GPRS_PASSWORD[] = " ";
// these are irrelevant since the device cant access the network to begin with
// String HOLOGRAM_DEVICE_KEY = "1234abcd";
// String HOLOGRAM_MESSAGE = "Your Message here";
// String HOLOGRAM_TOPIC = "TOPIC";
// Hologram's Embedded API (https://hologram.io/docs/reference/cloud/embedded/) URL and port
// char server[] = "cloudsocket.hologram.io";
// int port = 9999;

// initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess(true); //true to enable debugging

bool flag = false;
int gsmBeginStatus;
int gprsAttachStatus;

void setup() 
{
    pinMode(LED_BUILTIN, OUTPUT);
    // initialize serial communications and wait for port to open:
    Serial.begin(9600);
    while (!Serial) {};
  
    Serial.println("Starting Arduino web client.");
    // connection state
    boolean connected = false;
  
    while (!connected) 
    {
        Serial.println("Begin gsm Access");
        gsmBeginStatus = gsmAccess.begin();        
        if ((gsmBeginStatus == GSM_READY))
        {
            Serial.println("gsm access success!");
            flag = true;
        }
        else
        {
            Serial.println("gsm failed to begin.");
        }
        if(flag)
        {
            Serial.println("attaching gprs...");
            //delay(2000); //tried with and without delays
            gprsAttachStatus = gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD);
            if(gprsAttachStatus == GPRS_READY) 
            {
                connected = true;
                Serial.println("gprs attached!");
            }
            else
            {
                Serial.println("gprs failure.");
            }
        } 
        else 
        {
            Serial.println("Not connected");
            delay(1000);
        }
    }
    Serial.println("setup complete.");
}

// the loop function runs over and over again forever
void loop() 
{

}

```

??? Please help. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![tdarrah](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tdarrah](https://forum.arduino.cc/u/tdarrah)\
**Post date:** [October 29, 2020, 11:54pm UTC](https://forum.arduino.cc/t/gsm-fails-to-connect-two-different-boards/680519/2 "2020-10-29T23:54:46Z")

</div>

UPDATE

The battery is required for the device to work. I didn't realize this, and other threads with similar issues never pointed this out. So anyone else come across this in the future, plug the battery in before testing the code 🙂 (I tend to incrementally test from the other direction, software first).

---

<div class="post-metadata">

**Author:** ![racpra16](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/racpra16/32/309631_2.png) [@racpra16](https://forum.arduino.cc/u/racpra16)\
**Post date:** [November 6, 2020, 9:59am UTC](https://forum.arduino.cc/t/gsm-fails-to-connect-two-different-boards/680519/3 "2020-11-06T09:59:39Z")

</div>

Please make sure that you have an [antenna](https://store.arduino.cc/antenna) attached to the MKR GSM 1400 board. If you still face any issue, please feel free to escalate your issue to the support@arduino.cc.

//Arduino Support Team 🙂

---

<div class="post-metadata">

**Author:** ![ninora](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ninora/32/317892_2.png) [@ninora](https://forum.arduino.cc/u/ninora)\
**Post date:** [November 14, 2020, 6:20pm UTC](https://forum.arduino.cc/t/gsm-fails-to-connect-two-different-boards/680519/4 "2020-11-14T18:20:35Z")

</div>

> tdarrah:  
> UPDATE
> 
> The battery is required for the device to work.

Battery is NOT required to run the MKR and connect to GSM/GPRS, check that your power supply provide enough power.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 7, 2021, 11:53am UTC](https://forum.arduino.cc/t/gsm-fails-to-connect-two-different-boards/680519/5 "2021-05-07T11:53:46Z")

</div>

Closed on May 7, 2021, 11:53am UTC


