Hello,
does anyone know how to make the Arduino MKR 1400 reconnecting automatically , when it lost connection to cayenne cloud?
moreover, I havent received any data yet…
/*
This example shows how to connect to Cayenne using a GSM device and send/receive sample data.
The CayenneMQTT Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.
Steps:
- Install the TinyGSM library (GitHub - vshymanskyy/TinyGSM: A small Arduino library for GSM modules, that just works) from the Arduino Library Manager.
- Set the Cayenne authentication info to match the authentication info from the Dashboard.
- Uncomment the correct GSM modem type and set the GSM connection info, if needed.
- Compile and upload the sketch.
- A temporary widget will be automatically generated in the Cayenne Dashboard. To make the widget permanent click the plus sign on the widget.
*/
#define CAYENNE_DEBUG // Uncomment to show debug messages
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#define VIRTUAL_CHANNEL 1
// Uncomment your modem type:
//#define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM900
#define TINY_GSM_MODEM_UBLOX
// #define TINY_GSM_MODEM_BG96
// #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590
// #define TINY_GSM_MODEM_ESP8266
// #define TINY_GSM_MODEM_XBEE
#include <CayenneMQTTGSM.h>
// Increase RX buffer if needed
//#define TINY_GSM_RX_BUFFER 512
#include <TinyGsmClient.h>
// Uncomment this if you want to see all AT commands
//#define DUMP_AT_COMMANDS
// Set serial for debug console (to the Serial Monitor, default speed 115200)
#define SerialMon Serial
// Use Hardware Serial on MKR GSM
#define SerialAT SerialGSM
// GSM connection info.
char apn = “internet.telekom”; // Access point name. Leave empty if it is not needed.
char gprsLogin = “t-mobile”; // GPRS username. Leave empty if it is not needed.
char gprsPassword = “tm”; // GPRS password. Leave empty if it is not needed.
char pin = “9456”; // SIM pin number. Leave empty if it is not needed.
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “26130510-75e6-11ea-883c-638d8ce4c23d”;
char password = “499e54d4279e0fbb6c9ff7c55b22cad02fd6934e”;
char clientID = “45d423c0-75e6-11ea-93bf-d33a96695544”;
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
TinyGsmClient client(modem);
void setup() {
// Set console baud rate
SerialMon.begin(115200);
while (!SerialMon) {}
// Set GSM module baud rate
SerialAT.begin(115200);
// FOR THE MKR GSM 1400
// reset / powerup the modem
pinMode(GSM_RESETN, OUTPUT);
digitalWrite(GSM_RESETN, HIGH);
delay(100);
digitalWrite(GSM_RESETN, LOW);
// Restart takes quite some time
// To skip it, call init() instead of restart()
SerialMon.println(F(“Initializing modem…”));
modem.restart();
String modemInfo = modem.getModemInfo();
SerialMon.print(F("Modem: "));
SerialMon.println(modemInfo);
Serial.begin(9600);
// Auto-detect the GSM serial baud rate. You can manually set it instead if you want to save a bit of space.
//TinyGsmAutoBaud(gsmSerial);
Cayenne.begin(username, password, clientID, SerialGSM, apn, gprsLogin, gprsPassword, pin);
}
void loop() {
Cayenne.loop();
}
// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT(VIRTUAL_CHANNEL)
{
// Read data from the sensor and send it to the virtual channel here.
// You can write data using virtualWrite or other Cayenne write functions.
// For example, to send a temperature in Celsius you can use the following:
Cayenne.virtualWrite(VIRTUAL_CHANNEL, 25.5, TYPE_TEMPERATURE, UNIT_CELSIUS);
}