SIM800L - detecting power state

Hi All

I have an Arduino Nano v3.0 and a SIM800L breakout board that has the following pins:

VCC = 3.4 - 4.4v connected to 2000mAh LiPo
GND
RI = pin that is supposed to give power state of unit
RX
TX
DTR
VIO = connected to 5v on Nano
PWR = pin that will power on/off unit if pulled high for 2s

I also have a 3 axiz accellerometer connected to the nano on A0, A1, A2, 3,3v and GND

I have connected the SIM800 module to the Nano as follow:
Nano D10 == SIM800 PWR
Nano D7 == SIM800 RI
Nano RX == SIM800 TX
Nano TX == SIM800 RX
Nano GND == SIM800 GND

Then, I connected LiPo VCC to SIM800VCC and LiPo GND to SIM800 GND

I use the below included Sketch, which very simply checks the accellerometer every 1s, and if all 3 axis record above a certain threshold, increments a counter, and then sends a text every time the counter reaches 30.

The Sketch “works” sometimes, but not always.

Sometimes, when I apply USB power to the Nano and connect the LiPo to the SIM800, then the SIM800 will auto power on, and keep switching on and off by itself.

When I get the SIM800 to NOT do this (usually by switching LiPo), and the Sketch start running on the nano, then the SIM800 will start powering up after the 30 count is hit, send a text, and then power down again, but it will not power up again after that when the counter hits 30 again.

It looks like the unit needs about 16 seconds in total to register on the network before it can send an sms, hence my long “delay” - the flashing light starts blinking roughly every 3sec.

I’m not sure where the issue lies in my sketch, so I would really appreciate it if someone could point me in the right direction.

  • I have no idea whether my check for the HIGH on pin 7 is actually even what I am supposed to be checking for - the SIM800L documentation does not say whether the pin will be HIGH or LOW, or perhaps even an analogue reading when on…

Also, as a bonus, I would appreciate any power saving tips, or indications of what I can expect ito battery life with my setup. I plan on powering the nano with a 5000mah powerbank, and then SIM800 with a 2000mah lipo - how long could I expect the “system” to be able to keep reading from the accellerometer and send SMS?

What low power alternatives are the for accellerometers - I use a Sparkfun ADXL335.

Thank you in advance for your assistance!

PPS - as a SUPER bonus, I would appreciate any explanation as to why all the example sketches I always seem to get via google always seem to make use of software serial and digital pins, instead of the dedicated TX/RX pins on most Arduino’s? This SIM800L sketch as per below is the first sketch where I have actually managed to successfully communicate via serial with a device. I have tried doing something similar to this sketch, but with WiFi modules (ESP8266 of various makes and models) but could never get any of them to actually “hit” a website with a GET variable.

int x, y, z, count;
int pwrPin = 10;
int pwrSt = 7;
int val = 0;
boolean powerOn = false;

void setup()
{
Serial.begin(19200);
pinMode(pwrSt, INPUT);
PowerCheck();
if (powerOn == true) { // I don’t want the unit to be on when the Nano starts, since it could take a while for the counter to “fill”
PowerOff();
}
}

void sendSMS()
{
PowerCheck();
if (powerOn == false) {
PowerOn();
delay(15000);
}

Serial.println(“AT+CMGF=1”); // AT command to send SMS message
delay(100);
Serial.println(“AT+CMGS=”+1234567890""); // recipient’s mobile number, in international format
delay(100);
Serial.println(“SMS Text Here”); // message to send
delay(100);
Serial.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
Serial.println();
PowerOff(); //perhaps I should do a PowerCheck() and only if on, do a PowerOff() - but it seems safe to assume here that it is on??
powerOn = false;
}

void loop()
{
x = analogRead(0);
y = analogRead(1);
z = analogRead(2);
if ((x > 370) && (y>370) && (z>370)){
count++;
Serial.println(count);
}
delay(1000);
checkCount();
}

void PowerOn()
{
pinMode(pwrPin, OUTPUT);
digitalWrite(pwrPin, HIGH);
delay(2000);
digitalWrite(pwrPin, LOW);
powerOn = true;
}

void PowerOff()
{
//pinMode(pwrPin, OUTPUT);
digitalWrite(pwrPin, HIGH);
delay(2000);
digitalWrite(pwrPin, LOW);
powerOn = false;

}

void PowerCheck()
{
val = digitalRead(pwrSt);
if (val == HIGH) {
powerOn = true;
}
}

void checkCount()
{
if (count >= 30) {
count = 0;
sendSMS();

}
}

Something I just noticed now - having D7 and D10 connected as per above description is what seems to make the SIM800L "auto start". This is true even when the Nano has no power...

[SOLVED]

Found my problem - pwrPin should be pulled LOW:

However, I did also find that regardless of this "fix" if I connect my one LiPo to the unit, it will not power up - it will start powering up for about 5 seconds, and then just go off again. This LiPo measures same voltage as the other LiPO, but perhaps it is damaged and does not provide enough amps...

void PowerOn() { pinMode(pwrPin, OUTPUT); digitalWrite(pwrPin, LOW); delay(2000); digitalWrite(pwrPin, HIGH); powerOn = true; }

void PowerOff() { //pinMode(pwrPin, OUTPUT); digitalWrite(pwrPin, LOW); delay(2000); digitalWrite(pwrPin, HIGH); powerOn = false;

}

I would appreciate any explanation as to why all the example sketches I always seem to get via google always seem to make use of software serial and digital pins, instead of the dedicated TX/RX pins on most Arduino

If you use Serial to talk to the GSM shield, you can't use it to debug your program. Debugging by guesswork sucks. Debugging with data rules.

Sir

Please educate me.

I sort of deduced the debugging thing from the various sketches I've seen, but in practise, they did not work for me - perhaps it is because very few of them come with wire diagrams as well...

So if you elect to use software serial and digital pins 10 and 11 for instance, does that mean that you also connect TX and RX at the same time, or do you manually disconnect TX/RX and connect only 10 and 11 when you want to see what is happening over the "serial" comms, and in particular, the feedback from the device?

If you do use the software serial pins, does it mean that your AT commands are not actually "executed" by the module?

If they are, then why use TX/RX at all, ie, why not always use software serial?

Sorry for all the questions, but thank you in advance for all your answers.

So if you elect to use software serial and digital pins 10 and 11 for instance, does that mean that you also connect TX and RX at the same time, or do you manually disconnect TX/RX and connect only 10 and 11 when you want to see what is happening over the "serial" comms, and in particular, the feedback from the device?

To use SoftwareSerial, you would only connect the GSM module to pins 10 and 11.

If you do use the software serial pins, does it mean that your AT commands are not actually "executed" by the module?

No. It does not matter which set of pins you use to talk to the GSM module. What it receives is dealt with the same way. What it responds with is collected the same way.

If they are, then why use TX/RX at all, ie, why not always use software serial?

HardwareSerial is more reliable and leaves more time for other things, since the arrival and transmission of serial data is handled by hardware, not software.