hello every one. i'm making a simple program to be able to display data from ds18b20 on labview. the data in Labview is successfully displayed but I have a problem when I want to save the data in a txt file, the record results show that the data is always lost for 1 second. has anyone encountered such a problem? please solution.
Now I know the difference is small but instead of samplingTime_serial = currentTime; which is an old time. Consider the time it takes to print Serial.println(value_temperature); plus/minus the +/-5micro second millis() error and eventually the time will slip away.
The same may be said for the above, no telling how long the DS18B20.getTempCByteIndex(100) takes plus/minus 5 micro seconds millis() drift.
What I've done in the past when using millis() and to account for code latency time is to, at the start of loop() store the starting loop() millis(), at the end of the loop() subtract current millis() from the starting loop millis and use the difference to adjust the desired timing rates.
This looks more like a LabView question/issue. Is the problem readily repeatable? If so, do you see the same problem if you use the Arduino IDE serial monitor (or any other serial monitor program) if you take LabView out of the equation?
currently I don't have a datalogger device, but when I used a datalogger this problem also appeared when using the ds18b20. for normal data analog type sensors nothing disappears
Ok, I think I may know what is happening. I connected up an old 328P based board that has a DS18B20 on it and ran your code from post #1 but modified to reflect the pin I have my DS18B20 wired to. This is a section of what I saw on the serial monitor:
Note the apparently "missing" reading from 15:01:02.
It's not really missing. If you look carefully at the previous reading, the timestamp is almost 15:02:00 but not quite. There is slightly over 1 second between readings. So what I think is happening is that the next reading after 15:01:01.985 + slightly more than 1 second shows up as 15:01:03.010.
You are probably seeing something similar in your LabView logging but it's not that obvious because the log is showing whole seconds.
Something to take into account with your timing is that requestTemperatures takes 750mS. By the look of your data, either the library or the sensors take care of ignoring another request if one is in progress.