GSM900 shut off after some time... AT328P continued with working

:cry:

Good day,

I have a BIG problem. My GSM900 shuts down after approximately 5 days of device operation ... AT328P continues with operation. I've been analyzing the program for a few weeks, but it's not clear to me what the problem is and what the SIM900 shuts down.

The whole day is divided into intervals of 5 minutes and the loop checks if there were any messages and based on the sent message sends a reply. Sending "0" or "1" I receive temperature or humidity value.

I set SIM900 in SAFE MODE 2 , due to reduced power consumption: with NO SLEEP MODE whole device drains about 60mA.. in SLEEP MODE2 with command AT+CSCLK=2 it reduces to 16mA. Is it possible that after a while ... as far as I know I can only guess ... the SIM900 shuts down on its own ...? In order to be able to monitor the execution of the program, I set some BLINK sequences on DIGITAL PORT 13 ... everything was executed as I programmed.

The device is made with a minimum number of external components: a crystal, a pair of capacitors and a reset resistor.

PLEASE I NEED HELP......

#include <GPRS_Shield_Arduino.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include "DHT.h"
#define DHTPIN 2
#define PIN_TX    7
#define PIN_RX    8
#define BAUDRATE  9600
#define MESSAGE_LENGTH 160
char message[MESSAGE_LENGTH];
/*code code code code code code code */
#define code "0404"
/*code code code code code code code */
int messageIndex = 0;
#define DHTTYPE DHT22
GPRS gprsTest(PIN_TX, PIN_RX, BAUDRATE); //RX,TX,BaudRate
DHT dht(DHTPIN, DHTTYPE);
char string[160];
char smsbuffer[160];
char n[20];
char phone[16];
char telephone[16];
char datetime[24];
int analogInput = A2;
float vout = 0.0;
float vin = 0.0;
int value = 0;


void setup() {
  for (int i = 2; i <= 6; i++)
  {
    pinMode(i, OUTPUT);
  }
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT); 
  pinMode(analogInput, INPUT);

  Serial.begin(9600);


       
/*
************************************************
AUTO POWER ON     for GSM900
************************************************
*/

      digitalWrite(9, LOW);
      delay(1000);
      digitalWrite(9, HIGH);
      delay(2000);
      digitalWrite(9, LOW);
      delay(3000);
  
 

/*
************************************************
Waiting 30 SEK for SIM900 initialization
************************************************
*/

while (!gprsTest.init()) {

    delay(30000);
  }

/*
*******************************************************
SIM900 is connected, deleting all mesages from MEMORY
*******************************************************
*/ 
   gprsTest.deleteSMS(messageIndex);
   delay(100);
   messageIndex = 0;
   delay(100);
  
 
/*
*******************************************************
SEND CODE, YOU HAVE 30 SECONNDS
*******************************************************
*/  
   digitalWrite(LED_BUILTIN, HIGH);   
   delay(30000);
   digitalWrite(LED_BUILTIN, LOW);

/*
**********************************
READ MEMORY FROM SIM900
**********************************
*/
   gprsTest.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);
   delay(100);
   messageIndex = gprsTest.isSMSunread();
   

   nocode:

 /*
***************************************
SMS in MEMORY, reading  parameters
***************************************
*/
  if (messageIndex > 0) {

    gprsTest.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);

    delay(100);
    Serial.println(message);
    delay(100);
    Serial.println(phone); 
    delay(100);
/*
********************************************
remember number who send code- MASTER number
********************************************
*/
    strcpy(telephone,phone);
    delay(100);
/*
********************************************
deleting all mesages from MEMORY
********************************************
*/
    gprsTest.deleteSMS(messageIndex);
    delay(100);
    messageIndex = 0;
    delay(100);
/*
********************************************
compare code 
********************************************
*/
    if (strcmp (message, code) == 0) {

       //Serial.println("Code IS OK");
       //Serial.println("Calling MASTER NUMBER...20 seconds");
       delay(1000); 

/*
********************************************
CODE IS OK, calling MASTER number
********************************************
*/
       gprsTest.callUp(telefon);
       delay(20000);
       
    }
/*
****************************************************
CODE is NOT OK, send code again
****************************************************
*/
    else {       
      
      digitalWrite(LED_BUILTIN, HIGH);   
      delay(30000);
      digitalWrite(LED_BUILTIN, LOW);
     
      goto nocode;
    }

  }

/*
********************************************************
SMS IS NOT sent, send SMS again 
********************************************************
*/
    else if (messageIndex <= 0) {
     digitalWrite(LED_BUILTIN, HIGH);   
     delay(30000);
     digitalWrite(LED_BUILTIN, LOW);
   

    goto nocode;

  } 
     dht.begin();
     delay(100);
     scale.set_scale(21950.f);
     delay(500);
     


}


        

void retlja() {

 
               
    for (int i = 1; i <= 288; i++) {


    messageIndex = gprsTest.isSMSunread();
    if (messageIndex > 0) { //At least, there is one UNREAD SMS

     
      gprsTest.readSMS(messageIndex, message, MESSAGE_LENGTH, telefon, datetime);
      
      gprsTest.deleteSMS(messageIndex);
      messageIndex = 0;
      if (strcmp (message, "1") == 0) {
        
        mesage();

        delay(1000);
        gprsTest.deleteSMS(messageIndex);
        messageIndex = 0;

      }
      
        else if (strcmp (message, "0") == 0) {

        
        delay(1000);
        mesagee();
        delay(1000);
        
        
        gprsTest.deleteSMS(messageIndex);
        messageIndex = 0;
        
      }

       delay(297500);

    }

       
  }



void loop() {

  retlja();
}


 


void mesage()   {
  
  float t = dht.readTemperature();
  delay(100);
 
  int temp = (t);
  delay(100);
  int temp1 = (t * 100) - (temp * 100);
  delay(100);
   
  
  gprsTest.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);
  delay(100); 
  sprintf(string, "Temperature: %d.%d C  ", temp, temp1 );
  delay(100);


  gprsTest.sendSMS(telephone, string);
  delay (10000);
  gprsTest.deleteSMS(messageIndex);
  messageIndex = 0;
  delay(100);
}


void mesagee()   {
  
  float h = dht.readHumidity();
  delay(100);
  int pos = 0;
 
  delay(100);
  int hum = (h);
  delay(100);
  int hum1 = (h * 100) - (hum * 100);
  delay(100);
   
  
  gprsTest.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);
  delay(100); 
  sprintf(string, "Hummidy: %d.%d ",  hum, hum1 );
  delay(100);


  gprsTest.sendSMS(telephone, string);
  delay (10000);
  gprsTest.deleteSMS(messageIndex);
  messageIndex = 0;
  delay(100);
}

Please edit your post to add code tags, as described in the "How to use this forum" post.

I can't see the problem immediately, but you should think about rewriting the whole thing with a state-machine structure and millis() the delay()s could easily kill your enthusiasm as they did mine (most of yours are unnecessary).

Nothing obvious wrong, but why all the completely useless delay() statements? It seems like every other line is delay(), where it is obvious that it is not needed.

If there is not a specific reason for a specific delay(), take it out.

I put delay lines because I thought I'd "give time" to the processor to do each line safely ... so it wouldn't skip it by any chance. I am new to programming ...

I absolutely can't figure out why the SIM shuts down after a while. At the beginning I have an automatic swit ON sequence ...


AUTO POWER ON for GSM900


*/

digitalWrite(9, LOW);
delay(1000);
digitalWrite(9, HIGH);
delay(2000);
digitalWrite(9, LOW);
delay(3000);

maybe it somehow comes out of the loop ... WHAT SHOULD NOT HAPPEN THAT ... and it goes to the beginning and through this AUTO ON SEQUENCE turns off GSM900.

I shortened the loop to go not from: i=1 to 288 but to 5, and the duration of the same to 60000ms (1 minute) ... BEHAVES THE SAME. GSM900 turns off after about 5 days and a few hours ... I can't define how much. Yesterday with the loop parameters: i = 1 to 5 and the loop time of 60000ms GSM turned off after 2 days ... TOTALY MADNESS!!!!!!

/*

I thought I'd "give time" to the processor to do each line safely

In most cases, the processor takes a few nanoseconds to possibly a few microseconds to "do a line".

When it has moved on to the next line, the work ordered by the last line has been completed. So almost all of your delays just waste time and program memory.

If there is not a specific reason for a specific delay(), take it out.

I took out all delay() lines so ... we shall see what will be...Tonight will be put in operation ....

The other possible reason for the modem shutting down might be power.

  • noisy, or lack of it.
    Remember, these modem chips use around 200-300mA when idle, but peaks of 2A or more when registering or sending. That’s why power supplies are important in your design.

Yes, I power it with a 4A / 12V switching adapter, and then my Step Down Module LM2596s 3A DC to DC Buck Converter... lowers to 5V. I've never had a power problem. It will be some big nonsense ... I expect...

I dont know anything about simm900, but ...just a couple of thoughts.

I see you delete an sms when read. Is it possible that some received sms do not delete? in this case, what happens if sim900 memory is full?

Is the resetting period "steady" by time or by number of sms received? (can you change the timing so to see
what happens?)

sorry if misleading

Hmmm, I’ve never used the 900, but I’ve used a lot of 5320 and 7600 chips.
Basically, the only way to turn them off is with the AT+CPOF command.
I can’t think of anything else - unless perhaps the module is getting too hot??

The last page may help...

]

To GRuser:

When GSM900 memory is FULL system does not respond on received SMS "0" or "1" BUT... still working...NET LED status blinks 64/3000ms. Then I check ... connect the GSM900 via a serial / USB module to the computer and ... see exactly if there are any messages in the module's memory and which messages have been received. I'm thinking of how to do a small program to monitor the state of the pin that turns ON the GSM900. I have an Arduino Uno board on which I would bring a pin from a system that switch ON GSM900 and if any change happens ... for example, turn on the LED on DIGITAL port 13.

I have noticed something... when GSM900 turns OFF... I CAN NOT power it by pressing power switch on GSM module. I must disconect power complitly, and when put power back... it can be switched ON by program sequence.

perakojot73:
I have noticed something... when GSM900 turns OFF...

???
why (how can) GSM900 become powered off?

is power supply delivering power when 900 is Off?
900 , falls in some sleep mode?
Is disabled by arduino?

(I repeat I do not know anything about this module)

It's a mystery to me too. If I knew that, I would be happy. It's just ... shut down and I don't know what.It happens fast ... and I can't follow how it goes off. It just went off again just now. Last night it started at 23:35:28 and stopped working today at 19:16:33 ... after 161 repeated loops

on initial post you mention ~...stops after 5 days

Did you change timing of sending sms? is the time (continous operation) related with loops? (ie "5 days 500 loops and 3 days 300 loops" on one hand is different than "5 days 161 loops and 1 day 161 loops" on the other)

that is the only i can say
good luck

Here's how ... in the beginning I set the loop parameters to: i = 1 to 288 and the interval was 5 minutes ... 5 minutes*288 = 24 hours... 1 day.

And then it shut off for about 5 days ... maybe a little longer. In order not to wait for the loop to be repeated for one day, I decided to shorten the parameters as short as possible ...

So I decided that the parameters should be: i = 1 to 5, duration 1 minute. I thought that after the end of one loop, it falls out of it and LOOP is no longer executed .... BUT NO ... With these parameters, the loop was initially repeated up to 300 times (with parameters: i = 1 to 5, duration 1 minute) maybe more...after which it would shut down.

Three days ago it was reset after 4 days ... today after 161 repeated loops, less than one day (the loop lasts .. I measured 7 minutes and 20 seconds). TOTALY MADNES.

While testing this I am not sending any text messages.

Dis you found the problem?