Hello. I have a problem that i am unable to solve. I believe there is something that i don't see so i am waiting for your suggestions.
I am connecting an arduino with a mega through serial and getting data. Sometimes the message (1-2 times per day) arrives "corrupted". As for example i can see the outside temperature has the barometric pressure. So i decided to drop those measurements, because at the next message it will be the correct one. Somehow it doesn't work.
Yeap. I 've read about it, but it is not for me right now.
The problem here is that the message is something like:
<19.1,44.3,951.3,60>
and when parsing data may lost the start point. I realized this when i started to use it and capture everything back then. If you think that this matter, let me capture all the messages again for 24 hours to find it. The measurements arrives every second so you understand that i have an error in 45k cycles. It is not important, but it destroys my graphs.
I can understand you but think that not everyone thinks and acts like you. My project has 70 variables, organized by tenths and more. I could use something like board1_outside_north_temperature but i cannot use it to mysql (especially when i call it from multiple php pages). So when i use an "S13" name, it is global. In arduinos, in mysql, in php.
Yes. I realized it, as i said, when i started coding it. I eliminated all delays in my project with the help of Robin2 back then. It is a mega that collects from 4 other mega and nano through serial.
The processing has no bug. It may be the distance, the weather, the parallel cables or whatever. This is happening one or two times per day, so there is no bug in my code. However, i re-program tomorrow to start collecting the data.
This buffer is max 23. The method is "Serial Input Basics" you can find here
The "l" you see in my code is a counter for each loop that i use it for many jobs. One of them is the first 10 loops to collect the current data and after that (10th loop) if something is wrong to drop it. Of course it resets back to 10 when reaches 32767.
You don't give values to SXXt. I am giving values to "t" so to compare to the existing ones.
Yeap. Tested and not worked. Only errors. It can work great in small environment, but unfortunately not in long distances, many variables and complex programming.
I 've tested on my desk with 4 floats. Worked great. I reprogram with 8 floats, only send (not receive - full duplex), about 22meters cable and i got only errors.
It is a very big conversation how to eliminate the errors. This is not what i am looking for. I 've done my research a long ago and decided that it is not possible to clear all in real conditions. It would be very difficult to determine if the errors become from a noisy environment or something else. My next upgrade is to revert Serial Connections to RS485 to test with 4 cables (full duplex), which has higher voltages, to see if there would be zero errors. As you can see in my graph some posts before you will notice 2 error per day, with cycles per second. It is 2 per 86400. It is small. And definitely i can drop these 2 errors. This is what i am looking for.
As i said i am taking measurements from another 3 arduinos, i have a "threshold" error (depends the sensor) and drops it if it arrives outside of this. This is working fine for my project, because in the next second i will have the right value.
Anyway, thank you all for your answers.
gcjr i logged the entire message to mysql and did some research today. First of all my code...
Inside loop:
board4_receive();
if (newData4 == true) {
data_log (); //this is temporary to capture the message
strcpy(tempChars, receivedChars);
b4_parseData();
newData4 = false;
start4 = millis();
}
else {
//some functions to alert me of not working
}
What i see here is that i am missing 5 chars from the beginning.
Let me explain what are these values.
The first is outside temp, which can have values between -10.0 to 38.0 (3 to 5digits max)
The second is outside Humidity, which have values between xx.x to 100.0 (5digits)
The third is barometric which is a bit stable around 960.0 (5 digits)
The last one is lumnicance, which have values between 0 to 10000 (1 to 5 digit max)
So we have minimum 14 and maximum 20 (so i am using const byte numChars4 = 22;)