It was repeatable.
But I changed timing to call that function (20 sec instead of 60 sec) and the error didn't occur.
So I rechanged to 60 sec and no more error.
I don't understand pfffffffffffffff
Impossible to say for sure from a snippet, but it could be a memory overflow error so where, or a simple pointer write stomping on memory it shouldn't.
Post your code.
Putting Serial.write first won't matter -- because the output you send to Serial.write is buffered. When you Serial.write, it buffers your output (presuming there's room) and starts up an interrupt-driven activity to print your output from the buffer, then returns to you immediately.
So the hypothess is that your relay is firing during the printing, in the error case, causing the glitch. The fact that it's just a few characters (=milliseconds) into the string is the giveaway.
You could use Serial.flush() to force all the characters to be transmitted before you turn the relay on, but the glitch is telling you your power suppy is not adequate or not adequately decoupled, and you should fix it properly or you will just be facing it in another form shortly down the road.
This is probably a good time to ask if you have the relay connected directly to the Arduino output pin, which is not usually a good idea because relays use too much power and cause glitches like this or worse (like frying your board).
Thank you for help.
It's a mini-kit relais. Pin 31 command the relais.
But relais seems to pose problems.
Another one :
2 temperature sensors are connected : BMP085 (BOSH) and DS18B20 (DALLAS)
Dallas sensor is plug into Pin 02 (Arduino Mega)
If this command is excecuted (float temperatureExt = sensors.getTempCByIndex(0) Pin 31 becomes HIGH
It is very dissapointing.
I search what's wrong in my code.. Just 3 days I use arduino language
Code for Dallas sensor comes directly from manufacturer.
If you have 31 pins, you must have a Mega. The library may need adjustment for use on Mega - look in the library files for documentation, or search the forum here.
thierry_b:
It's a mini-kit relais. Pin 31 command the relais.
But relais seems to pose problems.
What relay? Post a link please. Are you using a transistor to turn it on?
thierry_b:
It is very dissapointing.
I search what's wrong in my code.. Just 3 days I use arduino language
Code for Dallas sensor comes directly from manufacturer.
Please post all your code, not just tiny snippets.