Hello. I am a neophyte who has done just a few simple things with my Uno. I have a Trimble Thunderbolt GPS Disciplined Oscillator that runs by itself, however it can put out status on its RS-232 port such as whether it is locked, or not. An amateur radio guy put a nice video on YouTube in which he used a PIC-based controller to read and display the status from his Thunderbolt:
I'd like to try to use my Uno to do something similar. I have an LCD1602 display from an Electronic Brick starter kit that runs off of Bus 2 on the seeedstudio interface shield. If I buy a TTL-to-RS232 level converter, can I send/receive simple NMEA-like commands on the Uno hardware serial interface (Pins 1 and 2, as I understand it), and then receive, decode, and display a simple message on the LCD such as an Alarm condition or Receiver is Locked? Will writing the LCD conflict with TX/RX on the serial port? I assume the Uno is as powerful as the PIC and has the bandwidth, but is that a rash assumption? Any ideas or coding suggestions would be greatly appreciated. Thanks in advance.
Should work. But don't connect the GPS to arduino's hardware serial. The TTL-USB chip 8u2 and the main atmega328 are both connected to these and you should use other pins and soft serial.
Google NewSoftSerial and TinyGPS. They're at the same site, the inventor of reverse geocaching box. I've been using these libraries and a different GPS for quite a while. Here it is! Your GPS should be very similar. You need to be sure that it is outputting real RS-232 voltages, -12V, and +12V. If it is already outputting 5V TTL, then it's easier, no conversion. To convert between RS-232 and TTL, you need a chip like MAX232 or ADM233LJN. There might also be reversed polarity issues that can be addressed by TinyGPS.
I tried the NewSoftSerial and bombed out. I downloaded it and unzipped it to a folder in my Libraries folder (which is inside my Arduino0021 folder). This action put a NewSoftSerial.h file and a NewSoftSerial.cpp file and a Keywords.txt file in that folder.
I then made a sketch using the NewSoftSerialTest example from the download:
``#include <NewSoftSerial.h>
// set the data rate for the NewSoftSerial port
mySerial.begin(4800);
mySerial.println("Hello, world?");
}
void loop() // run over and over again
{
if (mySerial.available()) {
Serial.print((char)mySerial.read());
}
if (Serial.available()) {
mySerial.print((char)Serial.read());
}
}
When I compiled it, I got the following errors:
NewSoftSerialTest.cpp:2:27: error: NewSoftSerial.h: No such file or directory
NewSoftSerialTest:3: error: 'NewSoftSerial' does not name a type
NewSoftSerialTest.cpp: In function 'void setup()':
NewSoftSerialTest:11: error: 'mySerial' was not declared in this scope
NewSoftSerialTest.cpp: In function 'void loop()':
NewSoftSerialTest:18: error: 'mySerial' was not declared in this scope
NewSoftSerialTest:22: error: 'mySerial' was not declared in this scope
Did I put the code in the wrong place? Help, please!
Disregard my last. I closed all windows and then reopened them and then recompiled the same sketch and now it compiles with no problems. Weird stuff...
You probably kept arduino IDE open and unzipped the library so arduino IDE has no knowledge there is a new library. So are you getting any NMEA sentences/messages yet?
Thank you, liudr, for explaining that mystery to me!
Yes and no on reading the data. It is not NMEA, but rather TSIP protocol. I've been able to read streaming broadcast packets of data from the device via NewSoftSerial, but there is occasionally an extraneous byte, for reasons I cannot figure out, and sometimes I fail to read the DLE (0x10) and the ETX (0x03) bytes that signify the end of the packet. Nowhere could I find examples of a receive buffer, so I made my own. I read that NSS needs to remain singly focused, so I've tried simple code like:
if (mySerial.available() > 0) {
// loop till something in buffer, then read the incoming byte from the soft serial RX port:
for (k=0; k<99; k++){
if (mySerial.available() > 0) {
// read the incoming byte
RecBytes[k] = mySerial.read();
}
}
}
if (mySerial.available() > 0) {
// dont print till you get something
Serial.println("Received data is:");
for (l=0; l<99; l++){
Serial.println(RecBytes[l],HEX);
}
(Sorry if the code doesn't show up in a box...I cannot seem to get that icon to work).
Only working at 9600 bps, so I don't think it is a timing challenge. Any thoughts appreciated!! Thanks again.