Coder Social home page Coder Social logo

Comments (9)

podhrmic avatar podhrmic commented on June 7, 2024 2

Hi! What is the status of this feature?
I have an application that needs to sleep for extended periods of time between updates (~10min), and I am not sure if the Arduino can reconnect with the cloud after the deep sleep (using Arduino Low Power library on MKR GSM board).
Is that currently possible?

from arduinoiotcloud.

ubidefeo avatar ubidefeo commented on June 7, 2024

hi @generationmake
You have a really good point there.
We have been working on an update which will allow better control of connection/disconnection.
Of course our goal is to work on something which won't introduce breaking changes, but we're getting there.
Stay tuned :)

from arduinoiotcloud.

aentinger avatar aentinger commented on June 7, 2024

Hi @generationmake
Thank you very much for raising this issue. If you have already a complete implementation feel free to create a pull request. I'll have to advise you though that currently refactoring efforts are under way which might render your PR obsolete, so I suggest the best course of action is to wait it out a bit and then create a PR with your suggested changes.

from arduinoiotcloud.

generationmake avatar generationmake commented on June 7, 2024

Hi @ubidefeo and @lxrobotics.
Thank you for your answers.
I will stay patient and see what comes up next.

from arduinoiotcloud.

ubidefeo avatar ubidefeo commented on June 7, 2024

hi @podhrmic
I have successfully used the automatic reconnect on IoT Cloud using MKR GSM waking up from deep sleep.
I have occasionally had reconnection issues when coverage wasn't available but it worked once signal was fine again

from arduinoiotcloud.

podhrmic avatar podhrmic commented on June 7, 2024

Thanks for the quick reply!

from arduinoiotcloud.

ubidefeo avatar ubidefeo commented on June 7, 2024

my pleasure, @podhrmic
just make sure you give the board enough time to reconnect before it goes back to sleep ;)

from arduinoiotcloud.

andreacosti avatar andreacosti commented on June 7, 2024

hi @ubidefeo
I have the same problem. I have a MKRGSM1400 with a MKRENV shield and I want to send dato to cloud.
I use Arduino low power library to put the MKRGSM in deep sleep but after some times it stop working. For example with deep sleep time of 15 minutes it works for a while then it stop working. In my last test it worked for 4 hours then it stop working.
With a sleep time of 30 minutes or 1 hour it stop working immediately.

This is my simple sketch:

#include <Arduino_MKRENV.h>
#include <ArduinoLowPower.h>

#include "thingProperties.h"

GSM_SMS sms;

unsigned long tempo;

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1000*30); 

  // Defined in thingProperties.h
  initProperties();

  // Imposto Callback per invio SMS informativo alla prima connessione
  ArduinoIoTPreferredConnection.addConnectCallback(onNetworkConnect);

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(4);
  ArduinoCloud.printDebugInfo();

  // Inizializzo MKRENV
  if (!ENV.begin()) {
    Serial.println("Failed to initialize MKR ENV shield!");
    while (1);
  }

  // Imposto funzione da richiamare al risveglio
  LowPower.attachInterruptWakeup(RTC_ALARM_WAKEUP, onWakeUp, CHANGE);

  tempo = millis();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 

  // read sensor values
  temperatura = ENV.readTemperature();
  umidita     = ENV.readHumidity();
  pressione   = ENV.readPressure();

  if (millis() - tempo > 90000) {
    // Triggers a 300 seconds sleep (the device will be woken up only by the registered wakeup sources and by internal RTC)
    // The power consumption of the chip will drop consistently
    LowPower.deepSleep(900000);

    delay(10000);

    tempo = millis();
  }
}

void onNetworkConnect(void *_arg) {
  static int SMSConnessione = 0;

  if (SMSConnessione == 0) {
    // Invio SMS di conferma inizializzazione scheda
    sendSMS("xxxxxxxxxx", "Scheda Inizializzata");
    SMSConnessione = 1;
  }
}

void sendSMS(char numero[], char testoSMS[]){
  sms.beginSMS(numero);
  sms.print(testoSMS);
  sms.endSMS();
}

void onWakeUp() {
  // This function will be called once on device wakeup
  // You can do some little operations here (like changing variables which will be used in the loop)
  // Remember to avoid calling delay() and long running functions since this functions executes in interrupt context
  //ArduinoIoTPreferredConnection.connect();
  
  //tempo = millis();
}

Thanks

from arduinoiotcloud.

podhrmic avatar podhrmic commented on June 7, 2024

Just FYI I had a similar problem - I have Arduino MKR GSM shield with a number of I2C sensors, and it all works nicely until Arduino goes to sleep. After spending some time trying to debug what is going on, I used Arduino Uno to turn Arduino MKR GSM on and off (and Uno sleeps in between) and that works as expected.

from arduinoiotcloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.