mercoledì 30 gennaio 2019

SMS + DeepSleep + Interrupt in Particle Electron

Prendendo spunto dal post precedente in questo caso l'SMS e' inviato da una Particle Electron generato da un interrupt su pin D2 (in questo caso pero' mandando il pin a GND) partendo pero' da una condizione di Deep Sleep

===============================================================
#include "application.h"
#include "cellular_hal.h"
STARTUP(cellular_credentials_set("TM", "", "", NULL));

const char* phNum = "+39347107xxxx";
const char* msg = "Interrupt fired";
int  ret;


void setup()
{
 pinMode(D7, OUTPUT);
 pinMode(D2, INPUT_PULLDOWN);    // sets pin as input
}

void loop()
    {
    digitalWrite(D7, HIGH);

    System.sleep(D2,FALLING);
    Cellular.on();
    Cellular.connect();
    delay(20000);
    if (Cellular.ready() == true)
    {
      ret = Cellular.command("AT+CMGF=1\r\n");
      ret = Cellular.command("AT+CMGS=\"%s%s\",129\r\n",(phNum[0] != '+') ? "+" : "", phNum); //
      ret = Cellular.command("%s\x1a", msg);
      digitalWrite(D7, LOW);
      delay(5000);

    }

}

Nessun commento:

Posta un commento

NRDE

        Questa e' una estensione di questo post usando come parametro indice NRDE al posto di NDVI. Questo indice puo'essere calcola...