1

This question is similar to another question, but I have added more details. See: MKR GSM 1400 Works only when connected to computer.

I have designed and built a custom board into which I plug an Arduino MKR GSM 1400. It's a basic IO abstraction level shifter as the system I am integrating to run on 24 V logic (done via opto-couplers). Everything is working perfectly and as-designed. I've added an I2C EEPROM.

When I boot the board from an external ATX supply +12 V line it doesn't complete setup. After I've left it for some time, I connect it to my PC USB port and open the serial monitor in the Arduino IDE and it simply completes the setup process and enters loop successfully.

Voltages are perfect. The 12-24 V supply is first fed through a standard 7810 (since I need +10 V for the analog lines of the controlled system) and then a 7805. The +5 V output of the 7805 is sent into the Vin of the Arduino. Measuring VIN with a DMM reads +5.07 V and VCC reads +3.33 V. I have a 3.7 V, 300 mAh 25C Li-Po connected to the battery port on the Arduino, to deal with the current requirements as specified in the documentation.

I thought this could be a power issue, so I also tried booting it with a 10 Ah USB Power bank that has 2 x 5 V, 2 A (3 A max) USB ports. Same result, until I connect the PC with the serial monitor.

Simplified Arduino Code:

#include <MKRGSM.h>
#include <Wire.h>

GSM gsm;
GPRS gprs;
GSMServer server(80);
GSMSSLClient client;
GSM_SMS sms;

void setup() {
  //Initialise Serial
  Serial.begin(9600);
  while(!Serial)
  {}
  Serial.println("Gineer.Industrial.GSM.Controller");
  Serial.println("www.gineer.co.za");
  Serial.print("Hardware Version: ");
  Serial.println(hwVersion);
  Serial.print("Software Version: ");
  Serial.println(swVersion);
  Serial.println();

  
  Serial.print("Connecting");

  bool connected = false;

  while (!connected) {

>>> Here is where it gets stuck until I plug in the USB Serial Monitor, and then it continues happily.


    if ((gsm.begin(SIMpinNumber) == GSM_READY) &&
        (gprs.attachGPRS(SIMgprsAPN, SIMgprsLogin, SIMgprsPassword) == GPRS_READY)) {
      connected = true;
    } else {
      Serial.print(".");
      delay(1000);
    }
  }
.
.
.

Interestingly, the +5 V output pin on the Arduino measures 4.68 V when not connected to the PC. I don't however use this pin as I have the 7805 on my board. All other voltages measure as above at all times.

3
  • your program does not fail to start up ....... take a look at your code ... examine any command lines that deal with Serial ... any of them look like they might hang up your code?
    – jsotola
    Commented Aug 5, 2020 at 22:18
  • @jsotola Can you help me understand how Serial could do that? The way I understand it is that serial would just output without checking if it is connected anywhere. In fact, I can see this happening, until the point where it hangs.
    – Gineer
    Commented Aug 6, 2020 at 6:02
  • 1

1 Answer 1

3

while(!Serial) {} will wait for a serial connection and in your program will block execution until it gets one.

Remove it and your program should continue without the serial monitor.

1
  • 1
    Copy and Paste will get you every time. When I noticed it I wanted to delete the question, but maybe it helps someone.
    – Gineer
    Commented Aug 6, 2020 at 19:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.