Serial port unavailable


I am using Ardunio MKR FOX 1200

Normally I dont have problem with the serial port but when running this specific code the serial port opens for almost 2 seconds, displays "Adafruit GPS library basic test!" then goes to serial port unavailable.

#include <Adafruit_GPS.h>

// what's the name of the hardware serial port?
#define GPSSerial Serial1
#include <SigFox.h>
#include <ArduinoLowPower.h>

// Connect to the GPS on the hardware port
Adafruit_GPS GPS(&GPSSerial);
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
// Set to 'true' if you want to debug and listen to the raw GPS sentences
#define GPSECHO false
#define WAITING_TIME 2

// GPS coordinate structure, 12 bytes size on 32 bits platforms
struct gpscoord {
  float a_latitude;  // 4 bytes
  float a_longitude; // 4 bytes

float latitude  = 0.0f;
float longitude = 0.0f;

bool debug = false;

//////////////// Waiting function //////////////////
void Wait(int m, bool s) {
  //m minutes to wait
  //s slow led pulses
  if (debug) {
    Serial.print("Waiting: "); Serial.print(m); Serial.println(" min.");

  digitalWrite(LED_BUILTIN, LOW);

  if (s) {

    int seg = m * 30;
    for (int i = 0; i < seg; i++) {
      digitalWrite(LED_BUILTIN, HIGH); //LED on
      digitalWrite(LED_BUILTIN, LOW); //LED off

  } else {
    int seg = m * 15;
    for (int i = 0; i < seg; i++) {
      digitalWrite(LED_BUILTIN, HIGH); //LED on
      digitalWrite(LED_BUILTIN, LOW); //LED off


/////////////////// Sigfox Send Data function ////////////////
void SendSigfox(String data) {
  if (debug) {
    Serial.print("Sending: "); Serial.println(data);
    if (data.length() > 12) {
      Serial.println("Message too long, only first 12 bytes will be sent");

  // Remove EOL

  // Start the module
  // Wait at least 30mS after first configuration (100mS before)
  // Clears all pending interrupts
  if (debug) SigFox.debug();


  if (debug) {
    int ret = SigFox.endPacket(true);  // send buffer to SIGFOX network and wait for a response
    if (ret > 0) {
      Serial.println("No transmission");
    } else {
      Serial.println("Transmission ok");


    if (SigFox.parsePacket()) {
      Serial.println("Response from server:");
      while (SigFox.available()) {
        Serial.println(, HEX);
    } else {
      Serial.println("Could not get any response from the server");
      Serial.println("Check the SigFox coverage in your area");
      Serial.println("If you are indoor, check the 20dB coverage or move near a window");
  } else {

//////////////////  Convert GPS function  //////////////////
/* Converts GPS float data to Char data */

String ConvertGPSdata(const void* data, uint8_t len) {
  uint8_t* bytes = (uint8_t*)data;
  String cadena ;
  if (debug) {
    Serial.print("Length: "); Serial.println(len);

  for (uint8_t i = len - 1; i < len; --i) {
    if (bytes[i] < 12) {
      cadena.concat(byte(0)); // Not tested
    if (debug) Serial.print(bytes[i], HEX);

  if (debug) {
    Serial.print("String to send: "); Serial.println(cadena);

  return cadena;

uint32_t timer = millis();

void setup()
  while (!Serial);  // uncomment to have the sketch wait until Serial is ready
  // connect at 115200 so we can read the GPS fast enough and echo without dropping chars
  // also spit it out
  Serial.println("Adafruit GPS library basic test!");

void loop() // run over and over again
  String pos;
  longitude = -3.999;
  latitude = 53.999;
  gpscoord coords = {longitude, latitude};
  pos = ConvertGPSdata(&coords, sizeof(gpscoord));
  String position_data;

  position_data = pos;
  Wait(WAITING_TIME, false);

Any help would be greatly appreciated

How about putting some debugging statements in your code? Like a print statement after each function call. I'm guessing ti is your ConvertGPSdata() function. It seems odd since your are just converting your coordinates into a string of bytes that are the values of representation of the floats. It is not turning them into a string.

Great idea i will try it