/* Uno
Serial Hardwareserial Rx= 0 TX= 1
*/
/* R4
Serial Hardwareserial Rx= 0 TX= 1
Serial1 Hardwareserial RX= 0 TX= 1
*/
/* Mega
Serial Hardwareserial Rx= 0 TX= 1
Serial1 Hardwareserial RX=19 TX=18
Serial2 Hardwareserial RX=17 TX=16
Serial3 Hardwareserial RX=15 TX=14
*/
//#include <SoftwareSerial.h>
//SoftwareSerial mySoftSerial(10, 9); //RX, TX R4(8,9) Mega(10,9)
#include "TEST_by_Murri.h"
//SIM800L sim(mySoftSerial);
SIM800L sim(Serial1);
bool connected;
bool simPowrOn;
bool send;
char *text = "blah blah blah";
void setup() {
Serial.begin(115200);
Serial1.begin(4800);
// mySoftSerial.begin(4800);
pinMode(2, INPUT_PULLUP);
pinMode(7, OUTPUT);
}
void loop() {
static bool test = false;
if (!digitalRead(2)) test = true;
if (test) simPowrOn = true;
if (connected & test) {
send = true;
test = false;
}
sim800L();
}
void sim800L() {
static unsigned long powerOn = millis();
if (send | !connected) powerOn = millis();
else if (millis() - powerOn > 30000) simPowrOn = false;
digitalWrite(7, simPowrOn);
connected = sim.connect(simPowrOn, 10);
sim.maxnr = 1;
sim.sendSms(1, &send, "+639497805263", text);
}