Inconsistent IoT data upload!

I’m running a battery powered Temperature, Humidity, Pressure, Battery status & Sea level pressure using an ESP32 for its power-saving modes. This device sleeps for 600 seconds & then wakes up, takes a set of readings & attempts to upload them to the IoT cloud.

However, I have noticed that from connection to the IoT cloud to the data upload has become very inconsistent!

Therefore I've set up a simple test running on another (different manufacturers) ESP32 to test this inconsistent data upload – see the code below -

/*
  Sketch generated by the Arduino IoT Cloud Thing "Connect_test"
  https://create.arduino.cc/cloud/things/3ba1a037-9244-4c28-88ed-6785004ebc5d

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  float test;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"

// Variables used for for millis time delay
int period = 2500;
unsigned long time_now = 0;

//  Variable used for setting an initial loop count.
int loopcount = 0;

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(1500);

  // Defined in thingProperties.h
  initProperties();

  // 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();

}

void loop() {

  // Wait for connection to IoT cloud
  while (ArduinoCloud.connected() == 0)
  {
    ArduinoCloud.update(); //required so things don't crash on us
  }


  // Update Arduino IoT Cloud - run multiple times to cut down on loops
  ArduinoCloud.update();
  ArduinoCloud.update();
  ArduinoCloud.update();
  ArduinoCloud.update();

  // Delay for 2.5 seconds
  time_now = millis();
  while (millis() < time_now + period) {
  }

  // random number for test
  test = random(10, 100);

  // Increment the loopcount
  loopcount++;

  Serial.print("Loopcount = "); Serial.print(loopcount); Serial.print("\r");

  // Check the loopcount
  if (loopcount == 100) {         // Exit if loopcount =

    Serial.print("\r Stopped! \r");

    // Normally at this point we'd be sending the ESP32 to sleep, so we'd never arrive here
    // Halt
    while (1);

  }

}

A debug output on the serial monitor shows the following when is working OK

***** Arduino IoT Cloud - configuration info *****
Device ID: f174feb6-a464-4a21-8bd1-2c20791ac4f5
MQTT Broker: mqtts-up.iot.arduino.cc:8884
WiFi status ESP: 255
Connection to "OMNI" failed
Retrying in  "500" milliseconds
Connection to "OMNI" failed
Retrying in  "500" milliseconds
Connection to "OMNI" failed
Retrying in  "500" milliseconds
Connected to "OMNI"
Loopcount = 1
Connected to Arduino IoT Cloud
Thing ID: 3ba1a037-9244-4c28-88ed-6785004ebc5d
Loopcount = 2
Loopcount = 3
Loopcount = 4
Loopcount = 5
Loopcount = 6
Loopcount = 7
ArduinoIoTCloudTCP::setTimeZoneData tz_offset: [-14400]
ArduinoIoTCloudTCP::setTimeZoneData tz_dst_unitl: [1667714400l]
Loopcount = 8
Loopcount = 9
Loopcount = 10

The two crucial IoT cloud parts from the above log are as follows -

Connected to Arduino IoT Cloud
Thing ID: 3ba1a037-9244-4c28-88ed-6785004ebc5d   

This we are connected to the IoT cloud OK

ArduinoIoTCloudTCP::setTimeZoneData tz_offset: [-14400]
ArduinoIoTCloudTCP::setTimeZoneData tz_dst_unitl: [1667714400l`

It is at this point data upload to the IoT cloud starts.

Now up until recently, I have been seeing the

ArduinoIoTCloudTCP::setTimeZoneData tz_offset: [-14400]
ArduinoIoTCloudTCP::setTimeZoneData tz_dst_unitl: [1667714400l]

messages occurring around my loop count of between 4 & 7
However now on most days of the week, I see the following

***** Arduino IoT Cloud - configuration info *****
Device ID: f174feb6-a464-4a21-8bd1-2c20791ac4f5
MQTT Broker: mqtts-up.iot.arduino.cc:8884
WiFi status ESP: 255
Connection to "OMNI" failed
Retrying in  "500" milliseconds
Connection to "OMNI" failed
Retrying in  "500" milliseconds
Connection to "OMNI" failed
Retrying in  "500" milliseconds
Connected to "OMNI"
Loopcount = 1
Connected to Arduino IoT Cloud
Thing ID: 3ba1a037-9244-4c28-88ed-6785004ebc5d
Loopcount = 2

Loopcount = 100
 Stopped!

So we are getting the connection to the IoT cloud, but no data upload is occurring because we are missing the

ArduinoIoTCloudTCP::setTimeZoneData tz_offset: [-14400]
ArduinoIoTCloudTCP::setTimeZoneData tz_dst_unitl: [1667714400l]

messages. I have even run the loopcount up to a 1000 loops with no ArduinoIoTCloudTCP messages showing!!

I would really appreciate it if anyone from the Arduino IoT cloud Dept. could shed any light of help with this issue?

It would also be very useful if there was a way of detecting the ArduinoIoTCloudTCP messages as this would save running around in loops!

Many thanks.

Rob

Not quite sure if anyone from the IoT team did something yesterday, but shortly after my post above my outside stats monitor started to upload data to the IoT cloud reliably every 600 seconds & has continued to do so for +25 Hrs now as shown below -

So if anyone did do something, it is now working, so thanks :+1: :slightly_smiling_face: