5 Replies Latest reply on May 20, 2014 9:45 AM by flummer

    RECEIVE SMS

    G0rdon

      Hello Guys

       

      I have the GPRS Shield V2.0 and the Intel Galileo Board.

       

      How can I receive an sms to my GPRS Shield and be able to recognize the number of the sender and the body of the message?

       

      I tried to use the sotwareserial but it doesn't work on Galileo.

       

      I have to simulate another UART and communicate with the shield by the AT command or there is another way?

       

      Thanks a lot.

        • 1. Re: RECEIVE SMS
          flummer

          Hi G0rdon,

           

          Depending on which shield you have, you might be able to simply use the regular serial port on Arduino pin 0 and 1 - called Serial1 in the Arduino IDE and get rid of all the softserial code.

           

          Contrary to the regular Arduinos, this serial port just connects to the quark chip (the linux system and your sketch code). You will still have the other serial connection that you can use to send back messages to your computer and read in the terminal of the Arduino IDE - simply called Serial in the IDE.

           

          Using AT commands, you should be able to get both sender number and message without any problems... but you will probably need to look in the data sheet for your GPRS shield/module to find the exact AT commands, especially to find the sequence for initializing the module and maybe entering SIM PIN, etc. if needed, to be allowed to communicate with the module at all.

           

          If you want to play with AT commands from your computer, it should be possible to make a simple Arduino sketch for the Galileo, that passes all data from one serial port to the other.

           

          Hope it helps.

           

          /Thomas

          • 2. Re: RECEIVE SMS
            G0rdon

            Thank you very much

             

            I think that I have to use the Serial not the Serial1

             

            My problem now is how can I make the sketch for Galileo that passes all data from one serial port to the other.

             

            Let me explain.. one time that a new data comes in the hardware serial RX I have to save the new byte in a string and I can realized it


            void serialEvent() {

              while (Serial.available()) {

                    char inChar = (char)Serial.read();

            }

              }

             

            But how can I send the data to the other Serial that is connect with the GPRS Shield?

             

            I think I have to use the IO7 and IO8 pin but I dont now how!

             

            Thanks a lot again!

            • 3. Re: RECEIVE SMS
              flummer

              Well, you will have to use both Serial AND Serial1.

               

              Serial connects the code to your computer and Serial1 connects to your GPRS shield.

               

              What shield are you using? You won't be able to use serial communication on the Galileo board on digital I/O 7 and I/O 8. These pins are driven via the I/O expander and it's too slow for bit banging serial communications at a usable speed.

               

              If you can configure the shield (maybe via jumpers or similar) to use digital pin 0 and pin 1, that is what you should do.

               

              To hook up the two serial ports so that the code does a pass through, you can use one of the examples in the Arduino IDE (Examples -> 04.Communications -> MultiSerialMega)

               

              I have pasted in the code below:

               

              /*

                Mega multple serial test

               

              Receives from the main serial port, sends to the others.

              Receives from serial port 1, sends to the main serial (Serial 0).

               

              This example works only on the Arduino Mega

               

              The circuit:

              * Any serial device attached to Serial port 1

              * Serial monitor open on Serial port 0:

               

              created 30 Dec. 2008

              modified 20 May 2012

              by Tom Igoe & Jed Roach

               

              This example code is in the public domain.

               

              */

               

              void setup() {

                // initialize both serial ports:

                Serial.begin(9600);

                Serial1.begin(9600);

              }

               

              void loop() {

                // read from port 1, send to port 0:

                if (Serial1.available()) {

                  int inByte = Serial1.read();

                  Serial.write(inByte);

                }

               

                // read from port 0, send to port 1:

                if (Serial.available()) {

                  int inByte = Serial.read();

                  Serial1.write(inByte);

                }

              }

               

              I hope this helps you out.

               

              /Thomas

              • 4. Re: RECEIVE SMS
                G0rdon

                This code is very good but is only for Arduino Mega and I have the Intel Galileo!

                 

                I use GPRS Shiel V2.0 with the SIM900.

                 

                How can I reuse this code for Intel Galielo?

                 

                Arduino Mega uses that pins 19(RX) and 18(TX) for the Serial1 but Intel Galileo uses pins 1(TX) and 0(RX)

                 

                How can I configure the shield via jumpers or similar to use digital pin 0 and pin 1?

                 

                • 5. Re: RECEIVE SMS
                  flummer

                  Hi G0rdon.

                  This code is very good but is only for Arduino Mega and I have the Intel Galileo!

                  Have you tried it on the Galileo board? The comment in the code is written way before anybody knew there would be a Galileo board or any of the newer Arduino board.

                   

                  I'm traveling, so I don't have a Galileo board to run the code on but it compiles fine and should work perfectly on the Galileo, I have used both serial ports at the same time before.

                   

                  I use GPRS Shiel V2.0 with the SIM900.

                  I have had a look at the wiki page (GPRS Shield V2.0 - Wiki) for this board (It's the one from seed studio, right?)

                   

                  How can I configure the shield via jumpers or similar to use digital pin 0 and pin 1?

                  There is two jumpers (circled in this image: File:GPRSserial.JPG - Wiki) that can set the shield to use either the hardware serial (pin 0 and 1) or software serial (pin 7 and 8). I can't se exactly, but it looks like you have to put both jumpers furthest in the direction of the lower pin numbers. The drawings on the PCB should explain how. It's hardware serial that you will want to use on the Galileo board.

                   

                  If you want to use the code examples on the wiki, you should replace all software serial with Serial1, when you use the Galileo board, like here for the test code:

                   

                  //Serial Relay - Arduino will patch a

                  //serial link between the computer and the GPRS Shield

                  //at 19200 bps 8-N-1

                  //Computer is connected to USB UART on Galileo board

                  //GPRS Shield is connected to the hardware UART on Galileo board

                   

                   

                  unsigned char buffer[64]; // buffer array for data recieve over serial port

                  int count=0;     // counter for buffer array

                  void setup()

                  {

                    Serial1.begin(19200);               // the GPRS baud rate  

                    Serial.begin(19200);             // the Serial port of Arduino baud rate.

                   

                  }

                   

                  void loop()

                  {

                    if (Serial1.available())              // if date is comming from softwareserial port ==> data is comming from gprs shield

                    {

                      while(Serial1.available())          // reading data into char array

                      {

                        buffer[count++]=Serial1.read();     // writing data into array

                        if(count == 64)break;

                    }

                      Serial.write(buffer,count);            // if no data transmission ends, write buffer to hardware serial port

                      clearBufferArray();              // call clearBufferArray function to clear the storaged data from the array

                      count = 0;                       // set counter of while loop to zero

                   

                   

                    }

                    if (Serial.available())            // if data is available on hardwareserial port ==> data is comming from PC or notebook

                      Serial1.write(Serial.read());       // write it to the GPRS shield

                  }

                  void clearBufferArray()              // function to clear buffer array

                  {

                    for (int i=0; i<count;i++)

                      { buffer[i]=NULL;}                  // clear all index of array with command NULL

                  }

                   

                  I hope you get it up and running!

                   

                  /Thomas