Fona800/sim800h GSM network status problem

Hi all,

I have an Adafruit Fona800 shield on an Arduino Uno and it’s working, for the most part. Everything is working fine, but I’m unable to get reliable results when I check the network status of the device.

Here’s my code

/*
 * This program uses code borrowed from Adafruit
 * (need citation)
 */

// serial console should be set to 115200 baud
// information will be printed to the console

#include "Adafruit_FONA.h"

#define FONA_RX 2
#define FONA_TX 3
#define FONA_RST 4

// We default to using software serial.
#include <SoftwareSerial.h>
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;

// Use this for FONA 800 and 808s
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);

uint8_t type;
int netStat;  // network status

void setup() {
      
  while (!Serial);

  Serial.begin(115200);
  Serial.println(F("FONA basic test"));
  Serial.println(F("Initializing....(May take 3 seconds)"));

  fonaSerial->begin(4800);
  if (! fona.begin(*fonaSerial)) {
    Serial.println(F("Couldn't find FONA"));
    while (1);
  }
  type = fona.type();
  Serial.println(F("FONA is OK"));
  Serial.print(F("Found "));
  switch (type) {
    case FONA800L:
      Serial.println(F("FONA 800L")); break;
    case FONA800H:
      Serial.println(F("FONA 800H")); break;
  }

  Serial.println(F("FONA Ready"));

  while (netStat != 1) {
    netStat = registerFona();
    delay(2000);  
  }


}


void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("loop running");
  delay(5000);  
}


int registerFona() {
  
  // network status
  int n = fona.getNetworkStatus();
  
  Serial.print(F("Network status "));
  Serial.print(n);
  Serial.print(F(": "));


  switch (n)  {
    case 0: {
      Serial.println(F("Not registered"));  
      break;
      }
    case 1: {
      Serial.println(F("Registered (home)")); 
      break;
      }
    case 2: {
      Serial.println(F("Not registered (searching)")); 
      break;
    }
    case 3: {
      Serial.println(F("Denied"));  
      break;
    }
    case 4: {
      if (n == 4) Serial.println(F("Unknown")); 
      break;
    }
  }  

  Serial.println(); Serial.println();
  return n;
  
}

Now, here’s what happens:

If I power on the arduino without a battery/power supply to the fona, the fona doesn’t register to the network and I get the message in the serial monitor that the gsm module isn’t registered on the network. The flashing leds clearly indicate this condition. Once I add power to the fona, it will register on the network, but the network status variable ‘n’ doesn’t change.

If I restart the arduino, without messing with the fona, it will come up as the unit is registered on the network, which it is.

I have changed the coding around a bit, and have found that when the network status of the gsm changes, it’s not reflected in the fona.getNetworkStatus() call to the adafruit library for this shield.

Any clue what might be wrong? Try another sim800 library instead of the adafruit one?

Is there a way to reset this so that the getNetworkStatus call will change as the network status of the device changes?

I have done other tests and can explain them as well, if needed to help me.

Thanks,
Randy

revolt_randy: If I power on the arduino without a battery/power supply to the fona, the fona doesn't register to the network and I get the message in the serial monitor that the gsm module isn't registered on the network.

The Fona 800 requires additional power of at least 500 mA battery. If you power up the Arduino and the Fona 800 has no power, the Fona 800's state is undetermined. I don't know how you expect Fona 800 to respond consistently in such a state?

ieee488: The Fona 800 requires additional power of at least 500 mA battery. If you power up the Arduino and the Fona 800 has no power, the Fona 800's state is undetermined. I don't know how you expect Fona 800 to respond consistently in such a state?

OK, you're right. I guess I was assuming because the indicator leds were telling me if it was or wasn't connected to the cell network that my code would reflect that status. I assumed the battery was only needed to connect.

Anyway, thanks for the help!

Randy