28-02-2020, 21:16
To może wyglądać tak? Czy coś źle?
Kod:
#include <BareBoneSim800.h>
BareBoneSim800 sim800;
int koniec = 0;
int koniecSMS = 0;
unsigned long aktualnyCzas = 0;
unsigned long zapamietanyCzasSMS = 0;
void setup() {
Serial.begin(9600);
sim800.begin();
while(!Serial);
pinMode(5, INPUT);
Serial.println("Testing GSM module For SMS Sending");
delay(8000); // this delay is necessary, it helps the device to be ready and connect to a network
Serial.println("Should be ready by now");
bool deviceAttached = sim800.isAttached();
if (deviceAttached)
Serial.println("Device is Attached");
else
Serial.println("Not Attached");
const char* number = "+48xxxxxxxxx";
char* message2 = "GSM dziala poprawnie. SMS testowy";
delay(2000);
bool messageSent = sim800.sendSMS(number, message2);
if(messageSent)
Serial.println("Message Sent");
else
Serial.println("Not Sent, Something happened");
}
void loop()
//====================================================================================
{
aktualnyCzas = millis();
if (((aktualnyCzas - zapamietanyCzasSMS) >= 2629743830UL)&& koniecSMS == 0) {
bool messageSent = sim800.sendSMS("+48xxxxxxxxx","SMS testowy co miesiac");
if((messageSent)&&(koniecSMS == 0))
koniecSMS = 1;
else
koniecSMS = 0;
}
//====================================================================================
{
if ((digitalRead(5) == LOW)&&(koniec == 0)) { //Jeżeli czujnik zadziałął
bool messageSent = sim800.sendSMS("+48xxxxxxxxxx","UWAGA!!! WODA w lazience. Prosze o szybkie sprawdzenie.");
if((messageSent)&&(koniec==0))
koniec = 1;
else
Serial.println("Not Sent, Something happened");
}
if (digitalRead(5) == HIGH) {
koniec = 0;
}
delay(5000);
}
}