Hello everyone,
Does anyone know how can I properly check is my GSM shield (or any other shield) is properly powered on?
Currently I just set the pin numbers.
#define SIM800_RESET_PIN 77
#define PWKEY 6
Then I set these pin as output...
pinMode(SIM800_RESET_PIN, OUTPUT);
pinMode(PWKEY, OUTPUT);
digitalWrite(SIM800_RESET_PIN, HIGH);
digitalWrite(PWKEY, HIGH);
And a few instruction later I check power supply like this :
case GSM_WAIT:
if (digitalRead(PWKEY) == HIGH && digitalRead(SIM800_RESET_PIN) == HIGH) {
Serial.println("GSM is ON");
state = GPS_WAIT;
} else {
// Error handling, nothing special
}
break;
My program is working, but I think this is a really useless test because in a way i'm just looking at the value of the variable which will alway be the expected value.
In fact, if my shield is not plugged it will still return "GSM is ON" ?
Do you know if it's possible to check this in a better way ?
I could send a command and wait for an expected answer like this :
if (inputString == "theExpectedString\r\n") {
Serial.println("Expected answer received, consequently : GSM is ON");
}
But it's too long, my GMS is slow to get the network, and I have to be sure that the shield is properly powered on before sending ANY commands.
If someone can help me I would be glad
Thank you !