Questions:
-
0voteA:
Dear Sir, Please Find the code below :
- GPRS CODE :
int8_t answer;
int onModulePin = 9;
int seconds = 20;
char aux_str[30];char phone_number[]="1234567890"; // ********* is the number to call
void setup(){
pinMode(onModulePin, OUTPUT);
Serial.begin(9600);
power_on();
delay(3000);
delay(3000);
Serial.println("Connecting to the network...");while( (sendATcommand("AT+CREG?", "+CREG: 0,1", 500) ||
sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0 );sprintf(aux_str, "ATD%s;", phone_number);
sendATcommand(aux_str, "OK", 10000);
delay(seconds * 1000);Serial.println("ATH"); // disconnects the existing call
}
void loop(){
}
void power_on(){
uint8_t answer=0;
// checks if the module is started
answer = sendATcommand("AT", "OK", 2000);
if (answer == 0)
{
// power on pulse
digitalWrite(onModulePin,HIGH);
delay(3000);
digitalWrite(onModulePin,LOW);
// waits for an answer from the module
while(answer == 0){ // Send AT every two seconds and wait for the answer
answer = sendATcommand("AT", "OK", 2000);
}
}
}int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout){
uint8_t x=0, answer=0;
char response[100];
unsigned long previous;memset(response, '\0', 100); // Initialize the string
delay(100);
while( Serial.available() > 0) Serial.read(); // Clean the input buffer
Serial.println(ATcommand); // Send the AT command
x = 0;
previous = millis();// this loop waits for the answer
do{
// if there are data in the UART input buffer, reads it and checks for the asnwer
if(Serial.available() != 0){
response[x] = Serial.read();
x++;
// check if the desired answer is in the response of the module
if (strstr(response, expected_answer) != NULL)
{
answer = 1;
}
}
// Waits for the asnwer with time out
}while((answer == 0) && ((millis() - previous) < timeout));return answer;
}- Soft Serial GPRS Code :
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
int8_t answer;
int onModulePin= 9;char data[512];
int data_size;char aux_str[100];
char aux;
int x = 0;
void setup(){pinMode(onModulePin, OUTPUT);
mySerial.begin(9600);mySerial.println("Starting...");
power_on();
// Serial.begin(9600);
delay(3000);delay(3000);
while (sendATcommand2("AT+CREG?", "+CREG: 0,1", "+CREG: 0,5", 2000) == 0);
sendATcommand("AT+SAPBR=3,1,\"Contype\",\"GPRS\"", "OK", 2000);
sendATcommand("AT+SAPBR=3,1,\"APN\",\"WWW\"", "OK", 2000);
while (sendATcommand("AT+SAPBR=1,1", "OK", 20000) == 0)
{
delay(5000);
}}
void loop(){
// Initializes HTTP service
answer = sendATcommand("AT+HTTPINIT", "OK", 10000);
if (answer == 1)
{
// Sets CID parameter
answer = sendATcommand("AT+HTTPPARA=\"CID\",1", "OK", 5000);
if (answer == 1)
{
// Sets url
// 103.231.8.219/IndriynEnergyService/api/IndriynEthernetPost?strPostObj=INDRIYN2|ACA^0^22.22|ACB^0^33.30|ACC^0^44.11
mySerial.print("AT+HTTPPARA=\"URL\",\"103.231.8.219/IndriynEnergyService/api/IndriynEthernetPost?strPostObj=");
delay(100);
mySerial.print("INDRIYN2|ACA^0^22.22|ACB^0^33.30|ACC^0^44.11");
delay(100);
answer = sendATcommand("\"", "OK", 10000);
if (answer == 1)
{
// Starts GET action
delay(1000);
answer = sendATcommand("AT+HTTPACTION=0", "+HTTPACTION:0,200", 12000);
if (answer == 1)
{
x=0;
do{
answer = sendATcommand("AT+HTTPREAD=0,200","+HTTPREAD:", 10000);
if (answer == 1)
{
// Serial.print("ok = " );
x=0;
do{
if(mySerial.available() > 0){
data[x] = mySerial.read();
x++;
if (strstr(data, "OK") != NULL)
{
answer = 1;
}
}
}while(answer == 0); // Waits for the asnwer with time out
data[x] = '\0';
mySerial.println(data);
}
else if (answer == 2)
{
mySerial.println("Error from HTTP");
}
else
{
mySerial.println("Error getting the url");
data_size = 0;
}
sendATcommand("", "+HTTPACTION:0,200", 20000);
}while (data_size > 0);
mySerial.print("Data received: ");
// mySerial.println(data);
}
else
{
// mySerial.println("Error getting the url");
}
}
else
{
// mySerial.println("Error setting the url");
}
}
else
{
// mySerial.println("Error setting the CID");
}
}
else
{
mySerial.println("Error initializating");
}
sendATcommand("AT+HTTPTERM", "OK", 5000);delay(5000);
}
void power_on(){
uint8_t answer=0;
// checks if the module is started
answer = sendATcommand("AT", "OK", 2000);
if (answer == 0)
{
// power on pulse
digitalWrite(onModulePin,HIGH);
delay(3000);
digitalWrite(onModulePin,LOW);// waits for an answer from the module
while(answer == 0){
// Send AT every two seconds and wait for the answer
answer = sendATcommand("AT", "OK", 2000);
}
}}
int8_t sendATcommand(char* ATcommand, char* expected_answer1, unsigned int timeout){uint8_t x=0, answer=0;
char response[100];
unsigned long previous;memset(response, '\0', 100); // Initialize the string
delay(100);
while( mySerial.available() > 0) mySerial.read(); // Clean the input buffer
mySerial.println(ATcommand); // Send the AT command
x = 0;
previous = millis();// this loop waits for the answer
do{
if(mySerial.available() != 0){
response[x] = mySerial.read();
x++;
// check if the desired answer is in the response of the module
if (strstr(response, expected_answer1) != NULL)
{
answer = 1;
}
}
// Waits for the asnwer with time out
}
while((answer == 0) && ((millis() - previous) < timeout));return answer;
}int8_t sendATcommand2(char* ATcommand, char* expected_answer1,
char* expected_answer2, unsigned int timeout){uint8_t x=0, answer=0;
char response[100];
unsigned long previous;memset(response, '\0', 100); // Initialize the string
delay(100);
while( mySerial.available() > 0) mySerial.read(); // Clean the input buffer
mySerial.println(ATcommand); // Send the AT command
x = 0;
previous = millis();// this loop waits for the answer
do{
if(mySerial.available() != 0){
response[x] = mySerial.read();
x++;
// check if the desired answer 1 is in the response of the module
if (strstr(response, expected_answer1) != NULL)
{
answer = 1;
}
// check if the desired answer 2 is in the response of the module
if (strstr(response, expected_answer2) != NULL)
{
answer = 2;
}
}
// Waits for the asnwer with time out
}while((answer == 0) && ((millis() - previous) < timeout));return answer;
}Posted byon Tuesday, 16 December 2014
-
0voteA:
Dear Sir,
Kindly load below code to the Arrduino board.
SAMPLE CODE:void setup()
{
Serial.begin(9600);
delay(5000);
}void loop()
{
Serial.println("AT");
delay(1000);
Serial.println("AT+CMGF=1");
delay(1000);
Serial.println("AT+CMGS=\"1234567890\""); //CHANGE TO DESTINATION NUMBER
delay(1000);
Serial.print("hi");
Serial.write(26);
delay(1000);
}Posted byon Monday, 12 September 2016 -
0voteA:
Dear Sir,
Kindly load below code to the Arrduino board.
SAMPLE CODE:void setup()
{
Serial.begin(9600);
delay(5000);
}void loop()
{
Serial.println("AT");
delay(1000);
Serial.println("AT+CMGF=1");
delay(1000);
Serial.println("AT+CMGS=\"1234567890\""); //CHANGE TO DESTINATION NUMBER
delay(1000);
Serial.print("hi");
Serial.write(26);
delay(1000);
}Posted byon Monday, 12 September 2016
-
0voteA:
Kindly click on the below link for the code.
http://researchdesignlab.com/rdl_gsm_gprs_code.html
Posted byon Tuesday, 14 June 2016
-
0voteA:
You have to give external power supply to Arduino uno. We will provide you the sample code.
Posted byon Saturday, 14 November 2015
-
0voteA:
Dear Customer
Please find the code below, also the same code can be used to on/off the pump.
int8_t answer;
int x;
char SMS[200];
void setup(){
Serial.begin(9600);
pinMode(8, OUTPUT);
digitalWrite(8, LOW);
power_on();
// turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
Serial.println("Network...");
while( (sendATcommand("AT+CREG?", "+CREG: 0,1", 500) ||
sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0 );
delay(300);
//Signal();
Serial.println("Setting SMS mode...");
sendATcommand("AT+CMGF=1", "OK", 1000); // sets the SMS mode to text
delay(300);
sendATcommand("AT+CMGD=1", "OK", 1000);
Serial.println("SEND SMS... TO READ");
}
void loop(){
answer = sendATcommand("AT+CMGR=1", "+CMGR:", 2000); // reads the first SMS
if (answer == 1)
{x=0;
memset(SMS, '\0', 100);
answer = 0;
while(Serial.available() == 0);
// this loop reads the data of the SMS
do{
// if there are data in the UART input buffer, reads it and checks for the asnwer
if(Serial.available() > 0){
SMS[x] = Serial.read();
x++;
// check if the desired answer (OK) is in the response of the module
if (strstr(SMS, "PUMP ON") != NULL)
{
digitalWrite(8, HIGH);
answer = 1;
}
if (strstr(SMS, "PUMP OFF") != NULL)
{
digitalWrite(8, LOW);
answer = 1;
}
if (strstr(SMS, "OK") != NULL)
{
answer = 1;
}
}
}while(answer == 0); // Waits for the asnwer with time out
SMS[x] = '\0';
Serial.print(SMS);
delay(200);
sendATcommand("AT+CMGD=1", "OK", 1000);
delay(100);
sendATcommand("AT+CMGD=1,4", "OK", 1000);
delay(200);
}
delay(1000);
}
void power_on(){
uint8_t answer=0;
// checks if the module is started
answer = sendATcommand("AT", "OK", 2000);
if (answer == 0)
{
// waits for an answer from the module
while(answer == 0){ // Send AT every two seconds and wait for the answer
answer = sendATcommand("AT", "OK", 2000);
}
}
}
int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout){
uint8_t x=0, answer=0;
char response[100];
unsigned long previous;
memset(response, '\0', 100); // Initialice the string
delay(100);
while( Serial.available() > 0) Serial.read(); // Clean the input buffer
Serial.println(ATcommand); // Send the AT command
x = 0;
previous = millis();
// this loop waits for the answer
do{
// if there are data in the UART input buffer, reads it and checks for the asnwer
if(Serial.available() != 0){
response[x] = Serial.read();
x++;
// check if the desired answer is in the response of the module
if (strstr(response, expected_answer) != NULL)
{
answer = 1;
}
}
// Waits for the asnwer with time out
}while((answer == 0) && ((millis() - previous) < timeout));
return answer;
}
void Signal()
{
answer = sendATcommand("AT+CSQ", "+CSQ", 2000); // reads the first SMS
if (answer == 1)
{x=0;
memset(SMS, '\0', 300);
answer = 0;
while(Serial.available() == 0);
// this loop reads the data of the SMS
do{
// if there are data in the UART input buffer, reads it and checks for the asnwer
if(Serial.available() > 0){
SMS[x] = Serial.read();
x++;
if (strstr(SMS, "OK") != NULL)
{
answer = 1;
}
}
}while(answer == 0); // Waits for the asnwer with time out
SMS[x] = '\0';
Serial.println(SMS);
delay(100);
}
}Posted byon Saturday, 22 August 2015
-
0voteA:
Dear Sir,
HTTPS is not supported by sim900a modems. It supports FTP/HTTP.
Posted byon Wednesday, 15 July 2015
-
0voteA:
Please go throught the below image for your query,
Posted byon Thursday, 22 January 2015
-
0voteA:
Dear Sir
Kindly go through the below links and the difference between the modems,
1. http://researchdesignlab.com/gsm-gprs-sim900a-modem-compatible-for-arduino.html
RDL/RGS/14/001/V1.0 -> This is a simple arduino shield which gets mounted on top or any arduino uno or arduino uno clone boards. Needs an adapter of 12V,2A to turn on this modem plugged into arduino uno DC socket. Other arduino shields could be mounted on top of this. No audio/mic jack are present on board.
2.http://researchdesignlab.com/gsm-modem-arduino-compatible.html
RDL/GSM-A/14/14/001/V3.0 -> This is a simple arduino shield which gets mounted on top or any arduino uno or arduino uno clone boards. Needs an adapter of 12V,2A to turn on this modem plugged into arduino uno DC socket. Other arduino shields can not mounted on top of this. Audio/mic jack are present on board.
3. http://researchdesignlab.com/gsm-gprs-shield.html
RDL/GSM-GPRS/14/001/V3.0 , -> is an industrial standard grade product with current controlling IC on board. This is also an arduino shield which gets mounted on top or any arduino uno or arduino uno clone boards. No need of external power supply for the arduino board.(USB power is enough). This has got inbuilt DC to DC converter.
Posted byon Monday, 29 December 2014