10-12-2015, 16:54
(Ten post był ostatnio modyfikowany: 10-12-2015, 16:58 przez karolen1@o2.pl.)
A czujnik ten kabel pobudzeniowy gdzie ma być podłączony 2 lub 3 gniazdo? gdzie wpisać numer żeby wysłało sms bo nie czaje
Ocena wątku:
Alarm powiadomienie sms aktywacja sms
|
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
SMSGSM sms;
int pin=1;
void setup()
{
pinMode(pin,INPUT);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
if (gsm.begin(2400))
Serial.println("\nstatus=READY");
else Serial.println("\nstatus=IDLE");
sms.SendSMS("numer telefonu", "Arduino SMS testowy");delay(2000);
}
void loop()
{
if ( digitalRead(2) == LOW ){sms.SendSMS("numer telefonu","czujnik_1"); delay(1000);}
if ( digitalRead(3) == LOW ){sms.SendSMS("numer telefonu", "czujnik_2"); delay(1000);}
}
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
int sms = 0 ;
void setup()
{
SIM900.begin(19200);
SIM900power();
delay(20000);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
}
void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(5000);
}
void loop()
{
if ( digitalRead(2) == LOW ){sms = 1;sendSMS();}
if ( digitalRead(3) == LOW ){sms = 2;sendSMS();}
}
void sendSMS()
{
SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
delay(100);
SIM900.println("AT + CMGS = \"+12128675309\""); // recipient's mobile number, in international format
delay(100);
if (sms == 1)SIM900.println("sms czujnika 1"); // message to send
if (sms == 2)SIM900.println("sms czujnika 1");
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power();
sms = 0; // turn off module
}