MKR WiFi 1010 Cloud Low Power

The MKR WiFi 1010 and the ENV-Shield are connected to the Arduino IoT cloud. I'd like to test the low power mode with the IoT cloud.

Code

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


void setup() {
  Serial.begin(9600);

  initProperties();

  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  
    if (!ENV.begin()) {
      Serial.println("Failed to initialize MKR ENV shield!");
    while (1);
    
  }
  
}


void loop() {
  
  temperature = round((ENV.readTemperature()-2.5) * 10)/10 ;
  humidity    = round(ENV.readHumidity());
  pressure    = round(ENV.readPressure() * 10);
  illuminance = round(ENV.readIlluminance());
  ArduinoCloud.update();
  
  LowPower.sleep(8000);
}

I expected the MKR WiFi 1010 to go to sleep for 8 seconds but it does not. What is the propper way to enable some power savig with the IoT cloud?.

What happens? Does it sleep for more than 8 seconds? Less than 8 seconds? Not at all?

Well, it seems not to go to sleep at all. It sends data to the IoT cloud all the time. With the ENV shield it is easy to see with the illuminance variable. I keep a hand over the ENV shield and the illuminance goes up and down all the time. I expected the MKR WiFi 1010 to stop sending data after the LowPower.sleep(8000), because the WiFi should be stopped by then.

The actual goal is to save power consumption, because I’d like to power the Arduino MKR WiFi 1010 from a battery. Since the method LowPower.sleep(8000) does not work, I tried something else.
There is also a method WiFi.lowPowerMode() of the WiFiNINA library, that automatically manages the power drain. It’s been accepted by the online Arduino editor but it is hard to say if it is even used. The IoT cloud code is somewhat like a black box. It is not clear if it even uses the WiFiNINA library to establish the WiFi connection.

Code

#include "thingProperties.h"
#include <Arduino_MKRENV.h>

void setup() {
  Serial.begin(9600);

  initProperties();

  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  
    if (!ENV.begin()) {
      Serial.println("Failed to initialize MKR ENV shield!");
    while (1);
    
  }

 // ENABLE WiFi Low Power Mode  
  WiFi.lowPowerMode();
}

void loop() {
  temperature = round((ENV.readTemperature()-2.5) * 10)/10 ;
  humidity    = round(ENV.readHumidity());
  pressure    = round(ENV.readPressure() * 10);
  illuminance = round(ENV.readIlluminance());
  ArduinoCloud.update();  
}

There is some information related to sleep and Arduino IoT Cloud here:

Note especially this:

https://github.com/arduino-libraries/ArduinoIoTCloud/issues/274#issuecomment-900860287

as of right now Low Power/Deep Sleep is not supported by the Arduino IoT Cloud firmware stack.