Strange behaviour with IoT data

Using a Nano 33 IoT board and a temperature sensor in an IoT-setup:

#include "thingProperties.h"
#include <OneWire.h>
#include <DallasTemperature.h>

float temperature is automatically generated and used on a dashboard. This works fine. But in the download of the data, temperature has intermittently the correct and incorrect value:

**time                                         temperature**
2022-01-06T09:36:07.256Z	24.5
2022-01-06T09:36:08.280Z	2.460.000.038.146.970.000
2022-01-06T09:36:12.377Z	24.5
2022-01-06T09:36:13.400Z	2.460.000.038.146.970.000
2022-01-06T09:36:14.425Z	24.5
2022-01-06T09:36:16.473Z	2.460.000.038.146.970.000
2022-01-06T09:36:17.497Z	24.5
2022-01-06T09:36:39.923Z	2.439.999.961.853.020.000

Also, the timestamps are irregular, given that the loop runs once each second. Here's my code:

void loop() {
    ....
    sensors.requestTemperatures();
    float temp_f = sensors.getTempCByIndex(0);
    temp_f *= 10;
    int temp_i = (int) temp_f;
    temperature = ((float) temp_i)/10;  //temp with 1 decimal
    ....
    ArduinoCloud.update();
}

So there's only one assignment to temperature, but in the datalog it seems as if also intermediate/raw sensor data is assigned to temperature. I do not understand how this could be.

The problem is most likely in the code you did not post.

Yes, could be. But I can assure you, that the code I'd shown, is the only place where I assign to or even use the variable 'temperature'. And on the dashboard, everything looks fine. It is only in the collected/recorded data that I subsequently downloaded, that I see this strange behaviour. So that makes me wonder, if there's something special going on in the framework.
But to be absolutely sure, I will try a sketch with nothing more than the snippets I posted above.

Have you taken in account that things like

  • out of boundeary writing to arrays
  • improper use of variable-type String can cause very weird and very hard to find mailfunctions in code?

And are you that one super-expert that can say "all details right" with my code?

if you haven't signed a non disclosure agreement about the code simply post the complete sketch

You should post code by using code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

best regards Stefan

I'm not pretenting to be a super expert; just trying to save you the trouble of having to trawl through too much code.
So I've done the experiment, with downsized but complete code. Here it is:

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Vloerverwarming"
  https://create.arduino.cc/cloud/things/356524a7-06cd-4028-9b65-bf1ba069e6dc 

  Arduino IoT Cloud Variables description

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

  String mode;
  float temperatuur;
  int dutyCycle;
  int hoog;
  int laag;
  bool alive;
  bool vloerverwarming;

  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"
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 4

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

unsigned long previousMillis = 0;
const long interval = 1000;// loop period in msec

void setup() {
  // Defined in thingProperties.h
  initProperties();

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

  sensors.begin();
}
void loop() {
  unsigned long currentMillis = millis(); // use millies for exact loop frequency
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

    sensors.requestTemperatures();
    float temp_f = sensors.getTempCByIndex(0);
    temp_f *= 10;
    int temp_i = (int) temp_f;
    temperatuur = ((float) temp_i)/10;  //temp with 1 decimal

    ArduinoCloud.update();
  }
}

Note that I've changed (w.r.t. my first posting) the variable name 'temperature' into 'temperatuur', because maybe there was a name conflict - which there wasn't.

If I inspect the output via the dashboard, again all looks OK; see image

But if I download (what is called) historical data for the same time period as in the image, I see the same, strange result as before:

2022-01-07T14:58:15.319Z 2.060.000.038.146.970.000
2022-01-07T14:58:16.252Z 2.070.000.076.293.940.000
2022-01-07T14:58:17.276Z 2.060.000.038.146.970.000
2022-01-07T14:58:18.267Z 2.070.000.076.293.940.000
2022-01-07T14:58:19.278Z 2.060.000.038.146.970.000
2022-01-07T14:58:57.167Z 2.070.000.076.293.940.000
2022-01-07T14:58:59.214Z 2.079.999.923.706.050.000
2022-01-07T14:59:02.285Z 2.089.999.961.853.020.000
2022-01-07T14:59:03.309Z 21
2022-01-07T14:59:06.382Z 2.110.000.038.146.970.000
2022-01-07T14:59:08.429Z 2.120.000.076.293.940.000
2022-01-07T14:59:09.453Z 2.129.999.923.706.050.000
2022-01-07T14:59:11.501Z 2.139.999.961.853.020.000
2022-01-07T14:59:12.526Z 21.5
2022-01-07T14:59:13.549Z 2.160.000.038.146.970.000
2022-01-07T14:59:15.602Z 2.170.000.076.293.940.000
2022-01-07T14:59:16.622Z 2.179.999.923.706.050.000
2022-01-07T14:59:18.670Z 22
2022-01-07T14:59:20.721Z 2.210.000.038.146.970.000
2022-01-07T14:59:21.742Z 2.220.000.076.293.940.000
2022-01-07T14:59:22.766Z 2.229.999.923.706.050.000
2022-01-07T14:59:24.816Z 2.239.999.961.853.020.000
2022-01-07T14:59:25.735Z 22.5
2022-01-07T14:59:27.886Z 2.260.000.038.146.970.000
2022-01-07T14:59:28.807Z 2.270.000.076.293.940.000
2022-01-07T14:59:30.958Z 2.279.999.923.706.050.000
2022-01-07T14:59:32.905Z 23
2022-01-07T14:59:35.976Z 2.310.000.038.146.970.000
2022-01-07T14:59:36.998Z 2.320.000.076.293.940.000
2022-01-07T14:59:39.047Z 2.329.999.923.706.050.000
2022-01-07T14:59:41.096Z 2.339.999.961.853.020.000
2022-01-07T14:59:42.120Z 23.5
2022-01-07T14:59:44.169Z 2.360.000.038.146.970.000
2022-01-07T14:59:47.239Z 2.370.000.076.293.940.000
2022-01-07T14:59:48.265Z 2.379.999.923.706.050.000
2022-01-07T14:59:49.289Z 2.389.999.961.853.020.000
2022-01-07T14:59:51.337Z 24
2022-01-07T14:59:53.383Z 2.410.000.038.146.970.000
2022-01-07T14:59:55.434Z 2.420.000.076.293.940.000
2022-01-07T14:59:56.456Z 2.429.999.923.706.050.000
2022-01-07T14:59:59.531Z 2.439.999.961.853.020.000
2022-01-07T15:00:00.553Z 24.5
2022-01-07T15:00:02.600Z 2.460.000.038.146.970.000
2022-01-07T15:00:04.651Z 2.470.000.076.293.940.000
2022-01-07T15:00:05.680Z 2.479.999.923.706.050.000
2022-01-07T15:00:08.746Z 2.489.999.961.853.020.000
2022-01-07T15:00:09.768Z 25
2022-01-07T15:00:12.841Z 2.510.000.038.146.970.000
2022-01-07T15:00:15.912Z 2.520.000.076.293.940.000
2022-01-07T15:00:17.960Z 2.529.999.923.706.050.000
2022-01-07T15:00:20.007Z 2.539.999.961.853.020.000
2022-01-07T15:00:21.031Z 25.5
2022-01-07T15:00:24.103Z 2.560.000.038.146.970.000
2022-01-07T15:00:27.176Z 2.570.000.076.293.940.000
2022-01-07T15:00:29.225Z 2.579.999.923.706.050.000
2022-01-07T15:00:31.271Z 2.589.999.961.853.020.000
2022-01-07T15:00:33.319Z 26
2022-01-07T15:00:36.390Z 2.610.000.038.146.970.000
2022-01-07T15:00:40.487Z 2.620.000.076.293.940.000
2022-01-07T15:00:41.511Z 2.629.999.923.706.050.000
2022-01-07T15:00:45.609Z 2.639.999.961.853.020.000
2022-01-07T15:00:48.681Z 26.5
2022-01-07T15:00:51.764Z 2.660.000.038.146.970.000
2022-01-07T15:00:55.855Z 2.670.000.076.293.940.000
2022-01-07T15:00:58.921Z 2.679.999.923.706.050.000
2022-01-07T15:01:03.020Z 2.689.999.961.853.020.000
2022-01-07T15:01:04.040Z 27
2022-01-07T15:01:09.056Z 2.710.000.038.146.970.000
2022-01-07T15:01:13.168Z 2.720.000.076.293.940.000
2022-01-07T15:01:14.176Z 2.729.999.923.706.050.000
2022-01-07T15:01:16.225Z 2.739.999.961.853.020.000
2022-01-07T15:01:18.274Z 27.5
2022-01-07T15:01:21.346Z 2.760.000.038.146.970.000
2022-01-07T15:01:24.417Z 2.770.000.076.293.940.000
2022-01-07T15:01:25.440Z 2.779.999.923.706.050.000
2022-01-07T15:01:29.551Z 2.789.999.961.853.020.000
2022-01-07T15:01:30.561Z 28
2022-01-07T15:01:33.651Z 2.810.000.038.146.970.000
2022-01-07T15:01:36.706Z 2.820.000.076.293.940.000
2022-01-07T15:01:38.752Z 2.829.999.923.706.050.000
2022-01-07T15:01:41.826Z 2.839.999.961.853.020.000
2022-01-07T15:01:42.849Z 28.5
2022-01-07T15:01:46.955Z 2.860.000.038.146.970.000
2022-01-07T15:01:51.042Z 2.870.000.076.293.940.000
2022-01-07T15:01:53.089Z 2.879.999.923.706.050.000
2022-01-07T15:01:56.167Z 2.889.999.961.853.020.000
2022-01-07T15:01:58.211Z 29
2022-01-07T15:02:01.281Z 2.910.000.038.146.970.000
2022-01-07T15:02:03.342Z 2.920.000.076.293.940.000
2022-01-07T15:02:05.378Z 2.929.999.923.706.050.000
2022-01-07T15:02:07.406Z 2.939.999.961.853.020.000
2022-01-07T15:02:08.383Z 29.5
![image 90x500](upload://eUVFP52GQDaaaB0CIhlc0Ja2wev.png)

There is some regularity in the "madness" : whole and half numbers (e.g. 29.0 end 29.5) are represented correctly, anything in between is representated as a big interger number, where one can recognize the correct temperature in the first few digits.

I think that I have to be a whole lot more clever than I actually am were I to program a sketch that does this on purpose! Don't you agree that this smells as if something in the Arduino IoT framework is not completely right?

without seeing the properties.h nothing can be said where this error might come from

If there is a GitHub-repo for this ArduinoCloud-thing

I would post there a new issue about this.
In the code you posted not even the variable "temperatuur" is defined

I can only do wild guessings:

maybe there is a difference between the variable types that must be defined in the Arduino-IoT-Cloud webforms.

Maybe one variabletype is not allowed for this.

Maybe how definitions between how the data is interpreted by the graphic is different from the historical data.

If there is some more special support of the Arduino-IoT-Cloud I would ask there

best regards Stefan