0

In Sim800L AT-Commands Guide there are a lot of different status commands, that should tell, what state does is have.

For example:

AT+CPAS - check if device is ready
AT+CGREG? - check registration status in network
AT+CGATT? - check if device "attached to network"
AT+CSQ - get signal level

But, in some cases, answers to this commands could be an "ERROR", or no answer at all.

I need a reliable and fast method to know is device connected to network, or it's already in GPRS mode, and for now I came to use blinking LED on Sim800L to detect it's state.

LED has three blinking frequencies:

  1. Fast blinking - GPRS connection is active
  2. Medium speed of blinking - Network connection is not established yet
  3. Slow blinging - Device is connected to network (but not the GPRS)

I can use photodiode and "read" blinging of LED, or I can wire LED's power pin to analog pin of Arduino, and read it's voltage. Next, I can count how fast LED is blinking, and determine, which state Sim800L in.

But how do I get this level of reliability without using such a crutch?

MihanEntalpo
  • 1,952
  • 2
  • 14
  • 31

1 Answers1

0

Given fast means 1 sec you could send an AT command e.g. five times and take 3 non error responses as a valid result. See pseudo code

uint8_t  errorCount = 0;
for (uint8_t i=0;i<5;i++){
 .... send AT command ... 
if (response == "error")  errorCount++;
if (errorCount >=3) errorHandling();
}
 ... process successful AT command ...

or your HW approach with LED to analog pin

Codebreaker007
  • 2,911
  • 1
  • 10
  • 22
  • Thanks for your answer. I've written an async library to work with Sim800L, that using callbacks and work in non-blocking manner. So, I can do such thing, but it gets too complicated. I have to send AT-command, set callback on "OK" or "ERROR" string, inside of this callback I have to send another command (or the same), increase counter and so on. – MihanEntalpo Mar 23 '20 at 03:58