Sim800l slow?

Hi Arduino wizards i have build a arduino based security system with a pir sensor, gyro, buzzer and a gsm module.

As for the project it works, i recieve notifications via sms when a sensor is trigerred the gsm module also connects fast in a couple of seconds to the network (from fast to slow blinking) it has a seperate 4.2v stable power supply with no voltage drops.

Now for the possible issue, the gsm module takes aprox 5min time to start sending notifications via sms is that a issue with my module? After its warmed up for 5min everything works fine with no delay. I did not find any info on my issue...

Module i use

.

Code is not perfect, any improvements are welcome

//#include <DS1302.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 2);
#include <Wire.h>
#include <MPU6050.h>
MPU6050 mpu;

//DS1302 rtc(6, 5, 4);
int sensor = 13;  
int val = 0;
bool sensorTriggered = false;
bool gyroTriggered = false;
int pirState = LOW;             // we start, assuming no motion detected
int pinSpeaker = 10;           //Set up a speaker on a PWM pin (digital 9, 10, or 11)

void setup()
{

  pinMode(sensor, INPUT);     // declare sensor as input
  pinMode(pinSpeaker, OUTPUT);
  
  // Set the clock to run-mode, and disable the write protection
  //rtc.halt(false);
  //rtc.writeProtect(false);
  Serial.begin(9600);
  Serial.println("KRALJICA SYSTEM AKTIVAN");
  while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
  {
  Serial.println("Error Gyro BRE");
  delay(1000);
  }
  mpu.setThreshold(1);
  // Sets the time of your RTC module
  //  rtc.setDOW(WEDNESDAY);     
  //  rtc.setTime(16, 36, 0);           //Set the time 4:30 PM; Military Time
  //  rtc.setDate(01, 05, 2018);        //dd, MM, yyyy format
}

void loop()
{
    Vector rawGyro = mpu.readRawGyro();
    Vector normGyro = mpu.readNormalizeGyro();
    float normal_x = normGyro.XAxis;
    float normal_y = normGyro.YAxis;
    float normal_z = normGyro.ZAxis;

    sensorTriggered = digitalRead(sensor) == HIGH;
    gyroTriggered = abs(normal_x) + abs(normal_y) + abs(normal_z) > 0.2;

    if (sensorTriggered && gyroTriggered) {
        playSound();
        sendMotionDetectionMsg("PIR I GYRO SENZOR AKTIVIRAN", "+381677067756");
    } else if (sensorTriggered) {
        playSound();
        sendMotionDetectionMsg("PIR SENZOR AKTIVIRAN", "+381677067756");
    } else if (gyroTriggered) {
        playSound();
        sendMotionDetectionMsg("GYRO SENZOR AKTIVIRAN", "+381677067756"); //send sms bre
    }
    
    delay(1000);
}

void playSound() { 
    playTone(300, 3000);
    delay(150);
      playTone(300, 3500);
    delay(150);
      playTone(300, 3000);
    delay(150);
      playTone(450, 3200);
    delay(150);
}

void sendMotionDetectionMsg(String message, String phoneNumber) {
  //String dowStr = rtc.getDOWStr();
  //String dateStr = rtc.getDateStr();
  //String timeStr = rtc.getTimeStr();
  //String message = String("Kretanje Detektovano: "); //+ dowStr + String(" ") + dateStr + String(" ") + timeStr;
  Serial.println(message);
  //"+381644249159"
  sendSms(message, phoneNumber);
}
void sendSms(String message, String number) {
  mySerial.begin(9600);
  delay(1000);
  mySerial.println("AT");
  delay(500);
  mySerial.println("AT+CMGF=1");
  delay(500);
  mySerial.println("AT+CMGS=\""+ number +"\"\r");
  delay(500);
  mySerial.print(message);
  delay(500);
  mySerial.write(26);
}

//speaker
void playTone(long duration, int freq) {
    duration *= 1000;
    int period = (1.0 / freq) * 1000000;
    long elapsed_time = 0;
    while (elapsed_time < duration) {
        digitalWrite(pinSpeaker,HIGH);
        delayMicroseconds(period / 2);
        digitalWrite(pinSpeaker, LOW);
        delayMicroseconds(period / 2);
        elapsed_time += (period);
    }
}

Commercial GPS units often tells:"Searching for sattelites" or a similiar messages. It takes some time att first startup to get hold of enough number of sattelites sattelites for the GPS to be able to tell all the data it is capable to.

Thanks , i think that this model of module has no GPS chip on it.

issue with your power to sim800L i suppose

GSM modules normally take some time at the startup but it's maximum 1min in those regions where signal is low. But 5 min is too much.

Check your code, you may have some delay in the setup loop. Share link of your GSM module or some datasheet to understand its behavior.

KASSIMSAMJI:
issue with your power to sim800L i suppose

Thanks, i will triple check it and will post results

jackthom41:
GSM modules normally take some time at the startup but it's maximum 1min in those regions where signal is low. But 5 min is too much.

Check your code, you may have some delay in the setup loop. Share link of your GSM module or some datasheet to understand its behavior.

Yes its strange as i have very good sell coverage and as noted in data sheet the module changes the LED state fast to Connected mode, say after couple of seconds.

Code posted.

i use that board in bunch of IoT based projects and i never had issue with any,

they run very reliably on 3.4 - 4.2V battery (Lion/LiPo), very short(and kind of thick) power wires to it

you can use oscillopscope to check if there is any voltage dip ( below 3.4V, where the module will resets )

whenever it tries to send SMS or register to a cell tower,

KASSIMSAMJI:
i use that board in bunch of IoT based projects and i never had issue with any,

they run very reliably on 3.4 - 4.2V battery (Lion/LiPo), very short(and kind of thick) power wires to it

you can use oscillopscope to check if there is any voltage dip ( below 3.4V, where the module will resets )

whenever it tries to send SMS or register to a cell tower,

I did check all, now on a 18650 battery running at 4.1v no voltage drops, it connects to the network fast and has peak current while connecting, does not restart i did try get info on serial by typing the AT command and nothing comes back, i use a arduino uno r3. Both NL & CR 9600 baud.

uploaded this test code

#include <SoftwareSerial.h>
 
//SIM800 TX is connected to Arduino D8
#define SIM800_TX_PIN 8
 
//SIM800 RX is connected to Arduino D7
#define SIM800_RX_PIN 7
 
//Create software serial object to communicate with SIM800
SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);
 
void setup() {
  //Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(9600);
  while(!Serial);
   
  //Being serial communication witj Arduino and SIM800
  serialSIM800.begin(9600);
  delay(1000);
   
  Serial.println("Setup Complete!");
}
 
void loop() {
  //Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor
  if(serialSIM800.available()){
    Serial.write(serialSIM800.read());
  }
  //Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800
  if(Serial.available()){    
    serialSIM800.write(Serial.read());
  }
}

After some time and connecting it direct to arduinos power supply it work with no delay and serial working every time it boots

After wiring external power supply to Sim800L like shown here with added resistors, no more problems.
I did not wire common Ground the first time and with no resistors (some times the module worked some not), maybe it caused a error in baud rate sync. As i found in datasheet the Module syncs automatic the baud rate to communicate with Arduino so i had communication problems with Arduino and the module.

Thanks to all!
:slight_smile: