• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Arduino UNO + SIM900A
#5
Cześć, trochę poprawiłem kod i usunąłem większość delay() Smile

Ale nadal nie mam pomysłu jak ogarnąć załączanie alarmu i jednoczesne odbieranie smsów.
Musze pokombinować i jakoś ułożyć to sobie w głowie Smile

Powoli małymi krokami Wink


Kod:
#include <GSM.h>
GSM gsmAccess;
GSM_SMS sms;

char remoteNumber[20];  // Holds the emitting number
char phone[20] = "XXXXXXXXX";
String txtMsg = "";

void setup()
{
  Serial.begin(9600);

  // connection state
  boolean notConnected = true;

  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while(notConnected)
  {
    if(gsmAccess.begin()==GSM_READY)
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("GSM initialized");
  smsSend(phone,"START SYSTEMU");
}


void loop()
{
  char c;

  // If there are any SMSs available() 
  if (sms.available())
  {

    // Get remote number
    sms.remoteNumber(remoteNumber, 20);
    Serial.println(remoteNumber);

    // This is just an example of message disposal   
    // Messages starting with # should be discarded
    if(sms.peek()=='#')
    {
      Serial.println("Discarded SMS");
      sms.flush();
    }

    // Read message bytes and print them
    while(c=sms.read())
      txtMsg += c;
    Serial.println(txtMsg);

    // delete message from modem memory
    sms.flush();
  }

  delay(1000);

}


void smsSend(char phone[20], String message)
{
  // send the message
  sms.beginSMS(phone);
  sms.print(message);
  sms.endSMS();
}
 
Odpowiedź
  


Wiadomości w tym wątku
Arduino UNO + SIM900A - przez hugobossbb - 11-03-2020, 21:54
RE: Arduino UNO + SIM900A - przez MERASerwis - 12-03-2020, 11:31
RE: Arduino UNO + SIM900A - przez hugobossbb - 12-03-2020, 13:21
RE: Arduino UNO + SIM900A - przez MERASerwis - 12-03-2020, 14:17
RE: Arduino UNO + SIM900A - przez hugobossbb - 15-03-2020, 16:14
RE: Arduino UNO + SIM900A - przez Agregacik - 15-03-2020, 19:13
RE: Arduino UNO + SIM900A - przez hugobossbb - 18-03-2020, 15:59

Skocz do:


Przeglądający: 2 gości