Buongiorno
Ho fatto uno sketch di monitoraggio di voltaggio batteria e accensione led come allarmi su chiusura di contatti, il codice gira su arduino nano e invia il dato del voltaggio sull'app blynk tramite modulo gsm Sim800L.
Il tutto funziona perfettamente finchè c'è connessione gprs, quello che vorrei è che la parte led diciamo visiva funzionasse anche senza connessione.
Girando sul forum di blynk ho capito che devo passare da Blynk.begin() a Blynk.config() ( C++ Blynk (Legacy) - Code Examples for Basic Tasks - #20 by Gunner - Projects made with Blynk - Blynk Community ), ma non riesco a capire come far partire la connessione gprs e/o fare riferimento a quella connessione in Blynk.config()
Di seguito metto il codice base che ho usato per partire per non mettere tutto il codice finale:
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#define TINY_GSM_MODEM_SIM800
// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30
#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[] = "YourAPN";
char user[] = "";
char pass[] = "";
// Hardware Serial on Mega, Leonardo, Micro
#define SerialAT Serial1
// or Software Serial on Uno, Nano
//#include <SoftwareSerial.h>
//SoftwareSerial SerialAT(2, 3); // RX, TX
TinyGsm modem(SerialAT);
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, millis() / 1000);
}
void setup()
{
// Debug console
Serial.begin(9600);
delay(10);
// Set GSM module baud rate
SerialAT.begin(115200);
delay(3000);
// Restart takes quite some time
// To skip it, call init() instead of restart()
Serial.println("Initializing modem...");
modem.restart();
// Unlock your SIM card with a PIN
//modem.simUnlock("1234");
Blynk.begin(auth, modem, apn, user, pass);
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}
Qualche anima pia che mi dia una mano?
Grazie