1 Reply Latest reply on Nov 5, 2015 3:00 PM by PabloM_Intel

    Help!? GSM Galileo Gen2 Switch Led

    AScallywag

      Hi so basically want to switch a io pin high or low by sms being received the problem is i dont understand how to store a message to compare to a pre set string which i would use as a command like for example char A ="on"... when smsreceived == A turn the led on but in my case im using Relays so off but same thing really.. ive been basically just trying different things ... heres what ive got so far any help would be Greatly appreciated.

       

      /################################################################################

       

      #include <String.h>

       

       

      char incoming_char[] = {"on"};

      int led = 13;

      void setup()

      {

      pinMode(led,OUTPUT);

        Serial.begin(9600);    // the GPRS baud rate

        Serial1.begin(9600);

       

      }

       

       

      void loop() {

        // put your main code here, to run repeatedly:

      digitalWrite(led,HIGH);

      SendTextMessage();

       

        ReceiveTextMessage();

        incoming_char=Serial1.println("AT++CPMS=\"SM\"");

        if (incoming_char=='on')

        {

          digitalWrite(led,LOW);

          delay(500);

        }

        delay(5000);

       

      }

       

      void SendTextMessage()

      {

      Serial1.print("AT+CMGF=1\r");    //Because we want to send the SMS in text mode

      delay(1000);

      Serial1.println("AT+CMGS=\"+353876373466\"");

      delay(1000);

      Serial1.println("Ready");

      delay(1000);

      Serial1.println((char)26);  //the ASCII code of the ctrl+z is 26 (0x1A)

      delay(1000);

      Serial1.println();

      }

       

       

      void ReceiveTextMessage()

      {

      Serial1.println("AT+CMGF=1");    //Because we want to receive the SMS in text mode

      delay(1000);

      Serial1.println("AT+CPMS=\"SM\"");

      delay(1000);

      Serial1.println("AT+CMGL=\"ALL\""); // show message

      }