Go Down

Topic: Problem with two way xbee communication (Read 489 times) previous topic - next topic

afremont

Ok sorry, I have the red one from Sparkfun.  What pins are your xbee serial comms on?
Experience, it's what you get when you were expecting something else.

PaulS

Quote
Basically I want to send GPS co-ordinates serially at every one second interval & in the remaining time Arduino should listen for any serially incoming characters that will trigger the Camera Pin.

How often does your GPS send data? Often, it is only once a second. So, the method you have for collecting serial data for a period of time is wrong.

ashubhatt

okay.. Got your point..!!
GPS sends data at a rate of 1 Hz i.e. every 1 second it transmits data.
Then how to program my arduino, so that whenever the data from GPS is available, it should transmit it via XBee and for the remaining time it should Listen to the Serial Port.
Can you help me with the programming part?
An example program will be helpful.
Thanks for the replies.

PaulS

Quote
Then how to program my arduino, so that whenever the data from GPS is available, it should transmit it via XBee and for the remaining time it should Listen to the Serial Port.

It isn't an either/or situation. That's what I'm trying to tell you.

On every pass through loop(), you collect any GPS data. Most of the time there will be none, but occasionally, there will be. You collect that data, each time checking to see if that is the last of the data. If it is, you send that data and clear the array.

On every pass through loop(), you collect any Serial data. Most of there time, there will be none, but occasionally, there will be. If there is, deal with it.

Your loop() function will look like:
Code: [Select]
void loop()
{
   while(uart_gps.available() > 0)
   {
      // Collect the data

      // If the end of a sentence has arrived, send it
   }

   if(Serial.available() > 0)
   {
      // Read that data

      // Do something with it
   }
}


Notice that there is no mention of time. If time WERE a factor, it would be in the "If the end of the sentence" part, where you would decide that the GPS is sending data to you more often (not the case with your GPS) than you want to forward it.

The code that you already have will go after the appropriate comments above.

ashubhatt

Thanks buddy..
It worked like a charm..  :D

Go Up