Im working on a project where I want to sleep my sim900.
So my code is:
#include <Time.h>
#include <TimeLib.h>
#include <SoftwareSerial.h>
#include <TimeAlarms.h>
#include <dht.h>
dht DHT;
#define DHT11_PIN 5
char number[]="+mynumber";
boolean started=false;
SoftwareSerial sim900(9,10);
void setup(){
Serial.begin(9600);
delay(10000); //Allow time for the SIM to register
Alarm.timerRepeat(10800, MainAlarm);
void loop(){
Alarm.delay(10);
}
void MainAlarm(){
sim900.print("AT\r"); //wake up<<<<<<<<<<<<<<<<<<<<<<<WAKE UP
delay(2000);
Serial.println("Main Alarm...");
int chk = DHT.read11(DHT11_PIN);
Serial.print("Temperature = ");
double temp = DHT.temperature;
Serial.println(DHT.temperature);
Serial.print("Humidity = ");
double hum = DHT.humidity;
Serial.println(DHT.humidity);
sendData(temp,hum);
}
void sendData(double temp, double hum){
sim900.begin(9600);
static char outTempStr[15];
static char outHumStr[15];
String tempString = dtostrf(temp,5,2,outTempStr);
String humString = dtostrf(hum,5,2,outHumStr);
delay(5000);
sim900.print("\r");
delay(1000);
sim900.print("AT+CMGF=1\r"); //text mode
delay(1000);
sim900.print("AT+CMGS=\"+mynumber\"\r");
delay(1000);
sim900.print("Temp=" + tempString + "Hum=" + humString + "\r");
Serial.println("sent!");
delay(1000);
sim900.write(0x1a);
sim900.println(char(26));
Serial.println("done!!");
//Now that it is sent, sleep the sim900
sim900.print("AT+CSCLK=2\r"); //sleep mode <<<<<<<<<<<<<<<<<<SLEEP
}
and I would add:
AT+CSCLK=2
which sleeps it. Now it should be woken up with something like:
AT
And then I continue my code execution. Can anyone tell me how to check if its gone to sleep?