Hologram SIM Times Out

Hi there.

I'm using a SIM900 with a Hologram SIM to send sensor data to a website.

The data send is fine, but when I try to have an hour delay in between data sends, the SIM disconnects at the end of the hour instead of uploading the new data.

When I do a delay of 10 minutes, it works fine.

Any ideas what to change? Thanks.

Code:

#include <SoftwareSerial.h>
SoftwareSerial gprsSerial(10, 11);

#include <String.h>
#include "DHT.h"

#define DHTPIN 2                                    // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11                               // DHT 11
DHT dht(DHTPIN, DHTTYPE);                           // Setup DHT

#define soilPin A0                                  // define the soil pin for reading soil data
float soilValue = 0;                                // the value for the soil sensor (used in the loop)

void setup()
{
  dht.begin(); // begin dht

  gprsSerial.begin(9600);
  Serial.begin(9600);

  Serial.println("Config SIM900...");
  delay(2000);
  Serial.println("Done!...");
  gprsSerial.flush();
  Serial.flush();

  //delay(10000);
    
  // bearer settings
  gprsSerial.println("AT+SAPBR=0,1");
  delay(2000);
  toSerial();

  // attach or detach from GPRS service
  gprsSerial.println("AT+CGATT?");
  delay(100);
  toSerial();


  // bearer settings
  gprsSerial.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
  delay(2000);
  toSerial();

  // bearer settings
  gprsSerial.println("AT+SAPBR=3,1,\"APN\",\"hologram\"");
  delay(2000);
  toSerial();

  // strength
  gprsSerial.println("AT+CSQ ");
  delay(2000);
  toSerial();

  // bearer settings
  gprsSerial.println("AT+SAPBR=1,1");
  delay(2000);
  toSerial();
}


void loop()
{
  /*
        GET TEMPERATURE AND HUMIDITY
  */
  float h = dht.readHumidity();
  float t = dht.readTemperature(true);
  float f = dht.computeHeatIndex(t, h);

  /*
    FIND SOIL MOISTURE AVERAGE FOR BEST RESULT
  */
  for (int i = 0; i <= 100; i++)
  {
    soilValue = soilValue + map(analogRead(soilPin), 0, 1023, 100, 0); //convert reading to %
    delay(1);
  }
  float m = soilValue = soilValue / 100.0;

  Serial.print("Hum: "+String(h)+"\n temp: "+String(t)+"\n moist: "+String(m)+"\n heat index: "+String(f)+"\n");

  // initialize http service
  gprsSerial.println("AT+HTTPINIT");
  delay(2000);
  toSerial();

  // set http param value
  gprsSerial.println("AT+HTTPPARA=\"URL\",\"http://api.jackhaegele.com/fielded-api.php?t=" + String(t) + "&m=" + String(m) + "&h=" + String(h) + "&f=" + String(f) + "\"");
  delay(6000);
  toSerial();

  // set http action type 0 = GET, 1 = POST, 2 = HEAD
  gprsSerial.println("AT+HTTPACTION=0");
  delay(6000);
  toSerial();

  // read server response
  gprsSerial.println("AT+HTTPREAD");
  delay(1000);
  toSerial();

  gprsSerial.println("");
  gprsSerial.println("AT+HTTPTERM");
  toSerial();
  delay(300);

  gprsSerial.println("");
  delay (60UL * 60UL * 1000UL);
}

void toSerial()
{
  while (gprsSerial.available() != 0)
  {
    Serial.write(gprsSerial.read());
  }
}

do you need to send a heartbeat to keep the channel up?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.