3 Replies Latest reply on Aug 19, 2015 10:40 AM by Intel_Peter

    SIM 900 GSM Module on Edison

    KKVP

      Reading through different links and 'Galileo-Edison_ShieldTestReport_330937-002.pdf', I understand the GSM library in Arduino does not work for Edison yet.

      I want to send/receive GPRS data (using SIM 900A module) and looks like sending individual AT commands is the only option now.

      I plan to use Eclipse + C and modify the MRAAA URAT example mraa/examples/uart.c and use series of AT commands for now. Is that the only way or did I miss locating some nice library which can help me ?

        • 1. Re: SIM 900 GSM Module on Edison
          Intel_Peter

          Hello KKVP,

           

          I haven't heard of any other library for this sensor. I also believe that the best way to interact with the sensor is using MRAA + C, Node or Python.

          By the way, after you finish your project, I invite you to share your results with community. They may help other users that want to create projects similar to yours.

           

          Peter.

          • 2. Re: SIM 900 GSM Module on Edison
            KKVP

            I am trying MRAA + C

            Connection:

            0(Rx)of Edison Arduino breakout board to Tx of GSM Module

            1(Tx)of Edison Arduino breakout board to Rx of GSM Module

            Ground to Ground

             

            Code:

            mraa_uart_context uart;

            mraa_init();

            uart = mraa_uart_init(0);

              if (uart == NULL) {

              fprintf(stderr, "UART failed to setup\n");

              return EXIT_FAILURE;

              }

            if(mraa_uart_set_baudrate(uart,2400)!=MRAA_SUCCESS)

              {

              fprintf(stderr,"Set Baud Failed\n");

              }

            cmd = "AT\r";

            mraa_uart_write(uart,cmd, sizeof(cmd));

            GSMResponse();

             

            void GSMResponse()

            {

            char buff[]="JJJJJJJJ";//some data to make sure this is being changed by read

            char data;

            bool yes;

            int bytesread=0;

             

            yes = mraa_uart_data_available(uart,10000);

              fprintf(stderr,"Data available = %d\n",yes);

              if(yes)

              {

              bytesread = mraa_uart_read(uart,buff,10);

             

              fprintf(stderr,"Number of bytes read = %d\n",bytesread);

              fprintf(stdout,"ASCII - %d\n",buff[0]);

              fprintf(stdout,"Character - %c\n",buff[0]);

              fprintf(stderr,"%s\n",buff);

              }

              else

              {

              fprintf(stderr,"No response from GSM\n");

              }

             

            Two Issues:

            1) When I run this initially on power on, I always get "No response from GSM". When I run an arduino program to communicate with GSM module arduino program works well. And then when I run this program after the arduino program is run once, I get a value 4 for bytesread and I guess the GSM is responding. ("OK" is expected, so 4 seems right along with linefeed)

            2)But even when I get the GSM responding I see I get ASCII -1 as values for mraa_uart_read(uart,buff,10);

            Is mraa_uart_read not working right?

            Also, when an arduino sketch is present in /sketch folder and I work on C program(eclipse), will the arduino sketch also keep running along with the C program or will eclipse download process make sure the sketch is not running?

            • 3. Re: SIM 900 GSM Module on Edison
              Intel_Peter

              I don't have access to a SIM 900 GSM module, so I'm uncertain of what's the root of this issue. However, as you can see in tx/ rx pin not working, Edison presents issues when receiving data if the ASCII values for the carriage return and the newline are not sent. This might be what's happening to you; maybe your Edison is waiting for these two signals and fails to communicate because of this. I suggest you to check the thread I mentioned before for more information about it.

              Regarding the Eclipse/Arduino IDE question. When you upload a script through Eclipse the Arduino sketches are not erased and usually they keep priority, so if you are going to upload a script from Eclipse, I suggest you to erase everything under /sketch.

               

              Peter.