GPS unit -> arduino <-> Processing | serial help needed

Hello,

I am currently making a GPS navigation colour orb (a user held item that changes colour depending on where you are). I have a processing sketch that does some curl scraping to get images and then pixel analysis of those images to get RGB values. From here I then want to send these rgb values over serial to my arduino board. I am currently using a parallax GPS module utilising the NSS library to create virtual serial bridge separate from the arduino to PC one.

User scenario:

My gps unit is sending data every 5 seconds to update the location. My user is to take this orb and plug it into the laptop to download the latest RGB values (they run a processing sketch which sends the data over serial). When the arduino receives these values it pairs them to 5 lon/lat coords which were created on the arduino sketch at compile time.

Note: I am using a 220uF capacitor jumper between the reset and GND pins to stop the the reset when my cable is plugged in/taken out, this is so I can send variables from processing to my arduino without losing the data

Problem:

I am trying to set it up so that when the cable is plugged into the arduino my processing sketch waits for an expected byte to be sent over. When it receives this it starts chucking the RGB data across using a start and endof msg breaks “:” and “<” respectively. Once the data is sent it closes the connection.

Can anyone please enlighten me and tell me if this will work or not? My biggest fear is that the GPS serial bridge will interfere with the arduino > processing one :confused:

Just discovered that While (Serial.available() > 0) doesn’t seem to work when using the capacitor jumper to stop arduino resets :S can anyone explain to me perhaps an alternative method to stop me losing my variables when I unplug the arduino?

I am currently using a parallax GPS module utilising the NSS library to create virtual serial bridge separate from the arduino to PC one.

I don’t understand this statement. Is the GPS connected to the Arduino, and being read using NewSoftSerial?

Rather than try to stop the Arduino from resetting when connected to the PC, why not let it reset. If the Arduino resets, it can send a message to the PC that it is ready to receive data, in setup(). Then, using a while loop, collect any serial data that arrives within some specified amount of time:

while(millis() < someAmount)
{
while(Serial.available() > 0)
{
// read the serial data
}
}

If any serial data was received, process it, and store it in EEPROM.

Then, read what is stored in EEPROM. The loop() function will do its thing based on what was read from EEPROM.

When the Arduino is unplugged, it will reset, but it won’t wait forever for serial data. When none arrived, it will read data from EEPROM, and start loop().

Thanks Paul, being a total amateur I completely forgot about the EEPROM, and yes you understood my poorly written statement perfectly :)