How can I read date and time data from RTC of sim900 module using arduino? -
#include "sim900.h" #include <softwareserial.h> #include "sms.h" smsgsm sms; boolean started=false; int count = 0; void setup() { pinmode(5, input); // input pin switch serial.begin(9600); if (gsm.begin(2400)) { serial.println("\nstatus=ready"); started=true; } else serial.println("\nstatus=idle"); delay(1000); } void loop() { if (digitalread(5)==1) { delay(500); if (digitalread(5)==1) { count = count+1; /*if(started) { if (sms.sendsms("+12345678", "alarm")) serial.println("\nsms sent ok"); }*/ serial.println("count = "); serial.println(count); readtime(); serial.println(content); } } else { serial.println("normal"); } }
i use sim 900 arduino detect change of input pin 5 , alarm user. have few question need help
- how can know pin sim 900 use communicated sent sms? use jumper @ d2 , d3. did use these 2 pins? because in program use .h include file didn't know detail inside it.
- how can read date , time data rtc in sim 900 module , store in variable , use them data logger later? know if have set date , time in rtc, can read "at+cclk?" , return date , time data. how can use command in program?
i found code , work me. first ask time , expect answers , parse it.
const char* const sim900::gettimestamp(){ serial2.print("at+cclk?"); //sim900 @ command time stamp serial2.print(13,byte); delay(2000); if (serial2.available()>0){ int = 0; while (serial2.available()>0){ timestamp[i]=(serial2.read()); i++; } } int years = (((timestamp[25])-48)*10)+((timestamp[26])-48); int months = (((timestamp[22])-48)*10)+((timestamp[23])-48); int days = (((timestamp[19])-48)*10)+((timestamp[20])-48); int hours = (((timestamp[28])-48)*10)+((timestamp[29])-48); int mins = (((timestamp[31])-48)*10)+((timestamp[32])-48); int secs = (((timestamp[34])-48)*10)+((timestamp[35])-48); //your code here }
Comments
Post a Comment