probably a very dumb question about TXing to a GPS

I have an Arduino Mega and a USGlobalSat EM-408 GPS hooked up to pins 16 and 17 on the arduino. I know I have the TX and RX lines right, as I've gotten GPS streams before. Everytime the GPS loses power (for extended periods of time) it resets and displays five different NMEA streams. How do I send a command over the TX2 line to the GPS? I know Serial2.available() and Serial2.read() are inputs, but can Serial2.println() send commands to the module or just the COM port?

I've got an arduino mega as-well and as far as i can tell you can use every serial port the same as the first one. So Serial.print, Serial1.print etc.

Jeroen

no I understand that. My question is which command would I use to send the GPS data from the Arduino. Would I say:

Serial2.println("$PSRF103,00,00");

Or something else?

My question is which command would I use to send the GPS data from the Arduino.

That could very well be a Serial.print. Thing is; where to? If you want to send to a computer then you have to make something to interpret the gps data.

How do I send a command over the TX2 line to the GPS? ........ can Serial2.println() send commands to the module or just the COM port?

Serial2.print does not care where it sends to. If you want to send a command to the gps unit you have to look up what command to send. That should be in the datasheet somewehere. Keep in mind that Serial.print[u]ln/u adds a carriage return to the end of the string you send. You may/may not want that.

Jeroen

edit. Anwer was incomplete From the reference.

println Prints a data to the serial port, followed by a carriage return character(ASCII 13, or '\r') and a newline character (ASCII 10, or '\n').

I know exactly what to send the GPS...it's plugged into TX2 pin 16 operating at 4800 baud. Anyone know what command TX's to a digital pin?

it's plugged into TX2 pin 16 operating at 4800 baud. Anyone know what command TX's to a digital pin?

I don't understand what you mean by 'a digital pin' in this context. If TX2 is operating at 4800 baud means that you've done Serial2.begin(4800). After that you can use Serial2.print() to send something over that port/pin.

Jeroen

Serial.print is probally for the first serial port.

Serial1.print is probally for the second serial port.

Serial2.print would be for a third serial port (which the mega dosent have)

In computer world everything starts from 0.

So the first port would be 0, and the second would be 1.

Just a guess, I have never used a mega before.

Here's a naive question for you... What exactly can you send into the GPS module? I've seen the NMEA message lists of the things that come out of GPS'es. Is there a list somewhere of things you can send in?

I've seen the NMEA message lists of the things that come out of GPS'es. Is there a list somewhere of things you can send in?

NMEA serial messages outputted from most GPSs are pretty standard, however serial commands sent to a GPS are specific for any given GPS device. That information is best found in the datasheet or operating manual for your specific GPS model. Some manufacturers of GPSs keep commands pretty common between their units, but still each model might have some different command tricks. As they say, you have to RTFM ;)

Lefty

lol you guys. I know exactly WHAT I need to tell the GPS. I just need to know HOW to tell the GPS from the arduino...

I just need to know HOW to tell the GPS from the arduino...

Have you read the Arduino reference section on serial communications? http://arduino.cc/en/Reference/Serial

Lefty

you are correct, just send the string that you thought you should to the serial port that the gps is connected to using serialX.print() with X being the serial port the gps is connected to, if you are streaming data back from the gps you will likely see a little pause in the stream, maybe some feedback and hopefully it will do what you want. Don't expect a lot from it, it may or may not tell you if the command failed or suceeded.

Arduino mega has 4 serial ports I believe, but with newsoftserial library you can have as many ports as you have pairs of pins, caveat being that you should only really try and handle one port at a time, upside is its better for timing and interrupts apparently.

If you didn't know which commands to send you could do something like this, use an app. that you would usually use to monitor the data instead of the arduino serial console, then setup the gps as you would, you can see the data going into the arduino, and log it, then look at the command structure for how they do it, saves a lot of time and effort trying to decipher a data sheet that doesn't have much of an explanation.

retrolefty: "The Arduino Mega has three additional serial ports: Serial1 on pins 19 (RX) and 18 (TX), Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). To use these pins to communicate with your personal computer, you will need an additional USB-to-serial adaptor, as they are not connected to the Mega's USB-to-serial adaptor. To use them to communicate with an external serial device, connect the TX pin to your device's RX pin, the RX to your device's TX pin, and the ground of your Mega to your device's ground. "

Totally missed that paragraph somehow :-?

Reggie: Thanks for the heads up.

I'll definitely try that and get back to you guys.