Arduino GPRS

Hello all, I have a Seeedstudio GPRS V2.0 that I am using right now connected to an Arduino Uno. I have the text messages working, I can send out messages. But what I want to do is turn on an output when I get confirmation that a message has been sent.

When a messages has been sent out properly, I get a response from the GPRS shield on the Serial monitor that says +CMGS: xxx .

xxx is the message number that increments up every time I send one out.

I am not concerned with the message number but I would like to turn on output 5 when I get +CMGS: from the shield.

Any help is appreciated, I have been struggling with this for days.

Thanks,

Edm

if(digitalRead(3) == HIGH){
Serial.println(“Sending Text…”);
gprsSerial.print(“AT+CMGF=1\r”); // Set the shield to SMS mode
delay(100);
// send sms message, the phone number needs to include the country code e.g. if a U.S. phone number such as (540) 898-5543 then the string must be:
// +15408985543
gprsSerial.println("AT+CMGS = “+17802923786"”);
delay(100);
gprsSerial.print("Driver ");
gprsSerial.println(rxBuf[i-9], DEC);
gprsSerial.print((char)26);//the ASCII code of the ctrl+z is 26 (required according to the datasheet)

Showing the code that sends a message, but not showing the code that reads a response, means that you get no help.

PaulS the reason I didn’t put the full code on their is that I didnt want to confuse people, what I have is the GPRS Shield and a CAN-BUS Shield, and I have combined the code to create my program. Its all a bit convoluted, but it works to send out the messages I need. Only thing I need at this point is the ability to turn on an output to signal another piece of hardware connected to the Arduino stack when a message has been sent out properly.

I am not asking for much, and this is also somewhat proprietary as I am trying to get a whole system to work based on this.

Again, I would appreciate any help that can be offered, I hope you can appreciate my position.

Thank you.

Perhaps this thread might be of assistance:

Edmhydraulics:
and this is also somewhat proprietary

A guy walks into the doctor's office. He says, "Hey doc, my wife is sick she's getting headaches and I can't figure out why. Can you tell me?"

Doctor says, "Well, why don't you bring your wife in and we'll have a look."

Guy says, "The thing is doc, I want to keep it a secret who my wife is, so I can't bring her to you. So can you tell me what's wrong with her?"

Do you see where this is going?

This is an open source community. If your code is secret, then it is yours to figure out if for no other reason than that we can't possibly diagnose code that we can't see.

Okay then fine, I guess it wont hurt. Now dont laugh at my code, I took several different sketches and mashed them together to get to this point, I am not a good C++ programmer at all, preferring to work in the realm of PLC’s. Using the GPRS Shield gives me a low cost text message modem for my project, which is only part of it.

Any suggestions you can give me will help, but mainly I need to be able to set pin 5 HIGH once I get “+CMGS:” from the GPRS Shield.

Thanks again.

Edm

int ledDelay; // Set a delay period LED Change
int delayData = 80; // Set a delay period for the data transferred to Excel and attempt to reduce data volumes
unsigned long changeTime;

//DAQ
#include <mcp_can.h>
#include <SPI.h>
#include <SoftwareSerial.h>
#include <String.h>
long unsigned int rxId;
unsigned char len = 0;
unsigned char rxBuf[8];
MCP_CAN CAN0(9); // Set CS to pin 9
SoftwareSerial gprsSerial(7,8);
//---------------------------------------------------------------------------------------------------------
// Set up the Arduino Serial port rate, clear all previous data and send the headings for the data transfer to excel
void setup() {
Serial.begin(19200); // opens serial port, sets data rate 9600 bps
gprsSerial.begin(19200); // GPRS shield baud rate
delay(500);
CAN0.begin(CAN_250KBPS); // init can bus : baudrate = 250k
pinMode(2, INPUT);// Setting pin 2 for /INT input
pinMode(5, OUTPUT);
}

void loop() {
if ((millis() - changeTime) > ledDelay) { // if it has been ledDelay ms since last change
changeLED();
changeTime = millis();
{

if (Serial.available()) // if there is incoming serial data
switch(Serial.read()) // read the character
{
case ‘t’: // if the character is ‘t’
SendTextMessage(); // send the text message
break;
}

if (gprsSerial.available()){ // if the shield has something to say
Serial.write(gprsSerial.read()); // display the output of the shield
}
}
}
}
void changeLED() {
for (int x=0; x<10; x++) { // turn off all LED’s
}
//CAN
if(!digitalRead(2)) // If pin 2 is low, read receive buffer
{
CAN0.readMsgBuf(&len, rxBuf); // Read data: len = data length, buf = data byte(s)
rxId = CAN0.getCanId(); // Get message ID
Serial.print("ID: “);
Serial.print(rxId, DEC);
//Serial.print(” Data: ");
for(int i = 0; i<len; i++) // Print each byte of the data
{
if(rxBuf < 0x10) // If data byte is less than 0x10, add a leading zero

_ Serial.print(“0”);_
if(int i =9)
if(rxId = 101)
if(digitalRead(3) == HIGH){
Serial.println(“Sending Text…”);

  • gprsSerial.print(“AT+CMGF=1\r”); // Set the shield to SMS mode*
  • delay(100);*
  • // send sms message, the phone number needs to include the country code e.g. if a U.S. phone number such as (540) 898-5543 then the string must be:*
  • // +15408985543*
  • gprsSerial.println(“AT+CMGS = “+1xxxxxxxxx””);*
  • delay(100);*
  • gprsSerial.print("Driver ");*
  • gprsSerial.println(rxBuf[i-9], DEC);*
  • gprsSerial.print("Truck ");*
  • gprsSerial.println(rxBuf[i-8], DEC);*
  • gprsSerial.print("OnDuty ");*
  • gprsSerial.println(rxBuf[i-7], DEC);*
  • gprsSerial.print("OffDuty ");*
  • gprsSerial.println(rxBuf[i-6], DEC);*
  • gprsSerial.print("RegHrs ");*
  • gprsSerial.println(rxBuf[i-5], DEC);*
  • gprsSerial.print("OT Hrs ");*
  • gprsSerial.println(rxBuf[i-4], DEC);*
  • gprsSerial.print("IdleHrs ");*
  • gprsSerial.println(rxBuf[i-3], DEC);*
  • gprsSerial.print("RunHrs ");*
  • gprsSerial.println(rxBuf[i-2], DEC);*
  • gprsSerial.print("Faults ");*
  • gprsSerial.println(rxBuf[i-1], DEC);*
  • delay(100);*
  • gprsSerial.print((char)26);//the ASCII code of the ctrl+z is 26 (required according to the datasheet)*
  • delay(100);*
    }
    }
    }
    }
    /*
    * Name: SendTextMessage
    * Description: Send a text message to a number
    */
    void SendTextMessage()
    {
    _ Serial.println(“Sending Text…”);_
  • gprsSerial.print(“AT+CMGF=1\r”); // Set the shield to SMS mode*
  • delay(100);*
  • //send sms message, the phone number needs to include the country code e.g. if a U.S. phone number such as (540) 898-5543 then the string must be:*
  • //+15408985543*
  • gprsSerial.println(“AT+CMGS = “+1xxxxxxxxx””);*
  • delay(100);*
  • gprsSerial.println(" "); //the content of the message*
  • delay(100);*
  • gprsSerial.print((char)26);//the ASCII code of the ctrl+z is 26 (required according to the datasheet)*
  • delay(100);*
  • gprsSerial.println();*
    _ Serial.println(“Text Sent.”);_
    }
    [/quote]
 if (gprsSerial.available()){ // if the shield has something to say
    Serial.write(gprsSerial.read()); // display the output of the shield
  }

If the shield has something to say, it goes in one ear and out the other.

You need to SAVE the data. You need to parse the data when the end of packet marker arrives. You need to make decisions regarding what to do based on the results of the parsing.

Obviously, the first thing you need to figure out is what represents and end of packet marker. What says that this is the end of a response? Is there a carriage return? A line feed? Both?

Okay I thought all these 2 lines did was set up for printing the response from the GPRS shield. As for the line terminator, I would assume its a carriage return. I will do more research and see what I come up with.

Thanks,

can i help me i want to add ultrasonic hc04 sensor this code