Go Down

Topic: Arduino Serial Problems (Read 1 time) previous topic - next topic


Oct 05, 2010, 12:48 pm Last Edit: Oct 05, 2010, 02:43 pm by tomfleet Reason: 1
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)
 // Serial.print("&");
   for (int i = 0; i<6;){
 // Serial.print("T=");

And the main program flow...


void loop()                        //MAIN PROGRAM

  get_data();                      // Poll Analog Inputs
  transmit_packet(RH, temp);       // Pass data to xBee for transmission
  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,



Here's your problem:

Code: [Select]
void loop()                        //MAIN PROGRAM
 get_data();                      // Poll Analog Inputs
 transmit_packet(RH, temp);       // Pass data to xBee for transmission
 loop();                          // Loop Around [glow]<---- NOOOOO!!!!!!![/glow]

You should not have loop() calling itself as you will eventually smash the available stack space on the processor. loop() is called in a loop anyways...there is no need for you to keep calling it.

The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons


Hi there.

I have a similar problem ith a NANO-board. That is that when I run a program that sends out strings (regular intervals ~ 1sec) the program seems to halt after a while when I don't read the data.
The program flow is monitored by an activity-led (13) when the data is sent. When I plug the USB back in or read data the program resets (values are re-initialized!)
The problem is that the board is intended for stand-alone use and sometimes can be monitored for correct functioning.

Anyone an idea?

Coding Badly

Anyone an idea?

Create a new topic in the Software section where your problem can be discussed.

Post your entire Sketch using code tags.

Include a detailed description of what is happening and what you expect to happen.

Go Up