Hi all,
I've got some code (there's a lot of it, hence why I'm not posting straight away) that polls two analog inputs, stores the values temporarily in RAM, then serves up a serial string consisting of a S/N and the two archived values.
Now, the code works, for a few minutes, then just seems to flake out, mid-string.
I'm using the default serial rate of 9600 bps, with a FT-232 Adapter board.
I've tried the code on a variety of boards (MEGA 1280, Mini Pro 328, Demilunovae and a selection of hand-built boards), to no avail...
Changing the program cycle frequency seems to have no effect, with the code eventually halting abruptly mid-string, every time(!).
Here's the function for sending the data string...
void transmit_packet(int RH,int temp)
{
xb_awake();
xb_init();
// Serial.print("&");
for (int i = 0; i<6;){
Serial.print(serial);
i++;}
Serial.print(",");
// Serial.print("T=");
Serial.print(temp);
Serial.print(",");
Serial.print(RH);
Serial.println("");
xb_sleep();
}
And the main program flow...
void loop() //MAIN PROGRAM
{
get_data(); // Poll Analog Inputs
transmit_packet(RH, temp); // Pass data to xBee for transmission
delay(transmission_delay);
check_serial_num();
loop(); // Loop Around
}
I haven't included the get_data function, as I don't think it's causing any problems, but its pretty simple, read A0 and A1, store to variables RH and temp.
The code seems to be breaking mid-flow of transmit_packet, and it's left me at a loss... :-/
Has anyone experienced anything similar when going heavy on the Serial.print function?
Thanks all,
Tom