Broadband-Hamnet™ Forum :: Developer's Forum
Welcome Guest   [Register]  [Login]
 Subject :TTL GPS.. 2015-08-21- 15:50:25 
n2wls
Member
Joined: 2015-05-29- 11:42:35
Posts: 1
Location

Prices on Chinese UART GPS modules on eBay seem to keep dropping and with a stack of Linksys mesh nodes sitting here, I decided to order a handful of the GPS NEO-7M-C modules. These are TTL and can be hooked right to the WRT54G serial ports:

GPS NEO 7M C

The serial ports on the WRT54G series of nodes are well documented on the web elsewhere:

WRT54G Serial Port header pinout

Just remember that ttyS0 defaults to console, and unless you inhibit that in /etc/inittab, you should avoid using that serial port and stick with ttyS1.  The actual device on the Linksys nodes is /dev/tts/1.  The NEO-7M-C GPS defaults to 9600 Baud, as does the WRT54G node S1 serial port, so it's a simple matter of wiring 3.3V to VCC, GND to GND, TX to RX, and RX to TX.


Jim, K5KTF, did a nice writeup on his implementation of GPS in his node:

http://www.broadband-hamnet.org/applications-for-the-mesh/145-gps-on-a-mesh-node.html


I took a similar yet slightly different approach.  Instead of building anything into the status page, I put a separate perl script in the /www/cgi-bin directory.  This way I can remotely "ping" the current GPS coordinates of one of my nodes.  The perl script /www/cgi-bin/gps is below:

#!/usr/bin/perl

use perlfunc;

my $node = nvram_get("node");

http_header();
html_header("$node gps ping", 1);
print "<body><pre>\n";

$gpgll = `head -n 19 /dev/tts/1 | grep GPGLL`;

$latdeg = substr($gpgll,7,2);
if( substr($latdeg,0,1) eq "0" ) { $latdeg = substr($latdeg,1,1); }
$latmin = substr($gpgll,9,8);
$latdir = substr($gpgll,18,1);
$latdecdeg = $latmin/60 + $latdeg;
if( $latdir eq "S" ) { $latdecdeg = $latdecdeg * -1; }
$latitude = sprintf("%.5f", $latdecdeg);

$longdeg = substr($gpgll,20,3);
if( substr($longdeg,0,1) eq "0" ) { $longdeg = substr($longdeg,1,2); }
if( substr($longdeg,0,1) eq "0" ) { $longdeg = substr($longdeg,1,1); }
$longmin = substr($gpgll,23,8);
$longdir = substr($gpgll,32,1);
$longdecdeg = $longmin/60 + $longdeg;
if( $longdir eq "W" ) { $longdecdeg = $longdecdeg * -1; }
$longitude = sprintf("%.5f", $longdecdeg);

$gpstime = substr($gpgll,34,6);

print "$node,$latitude,$longitude,$gpstime";

print "</pre>\n";
print "</body>\n";
print "</html>\n";


So now the script is called from the web browser at http://localnode:8080/cgi-bin/gps and produces a result such as:

N2WLS-WRT-3,42.70441,-78.57855,024314

That is in the format of Nodename, Decimal Latitude, Decimal Longitude, UTC Timestamp.  This should make it relatively easy to have a website that polls the location of several different nodes and combines the data into a table or a map for instance.

Hopefully this helps someone else who wants to easily implement GPS location services on their Linksys WRT54G Broadband-Hamnet nodes.

Gary, N2WLS

IP Logged
Page # 


Powered by ccBoard


SPONSORED AD: