Setting up a usb gps dongle


58 posts   Page 2 of 3   1, 2, 3
by poing » Wed May 23, 2012 9:52 am
stevep wrote:...but here's an overview of what I want to achieve:

What I'm aiming to achieve is to extract the latitude, longitude and time data from the gps signal, maybe every 15 or 30 minutes.

...I'll then use the data obtained to work out the altitude and azimuth of the sun. This data will then be used (with an interface board) to drive 2 stepper motors that will position a solar collector normal to the incoming solar radiation (using the maths from here)


What intrigues me is the use of GPS, as it seems a turning sun collector would be housed on a specific fixed location due the the needed construction, where a GPS would be useless as the location parameters are fixed as well. When it's built onto a car or a ship you'd need an orientation sensor much more than a gps as the position of the sun in the sky only very slightly changes even if you travel hundreds of kilometers.
Posts: 1090
Joined: Thu Mar 08, 2012 3:32 pm
by stevep » Fri Jun 01, 2012 1:08 pm
The gps device provides the lat, long and time data, all of which are needed to work out the azimuth and elevation. While the lat and long will be constants in any given location, I can't think of another device available for less than £16 that provides this data. From what I have read, other methods of making up for the lack of an RTC on the Pi are at least as expensive and more difficult (for me at least) to understand. The output from the gps device also provides heading data, so it could theoretically be used on a moving vehicle (but practically it would not work, unless the vehicle was moving extremely slowly).
I've only just received my RPi and have yet to sort out all the peripherals needed to get it running, but hopefully I can pick up the pieces of this in the near future and make some progress.
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am
by poing » Fri Jun 01, 2012 2:00 pm
OK, for the time I can see a reason to use a GPS if you don't have a network, but for a tracking device using whole degrees for the location will be accurate enough; you can find the lon/lat easily using Google Maps.

The time on the Pi will be automatically set on startup when you have a network connection.
Posts: 1090
Joined: Thu Mar 08, 2012 3:32 pm
by error404 » Sat Jun 02, 2012 7:47 am
Yeah if the Pi has an Internet connection, even just GeoIP is probably good enough for solar tracking. The better databases can get you within a few dozens of KM.
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by rjcollingridge » Fri Jun 08, 2012 7:41 am
Failed miserably to get the Bluenext GPS dongle working under Linux on any machine. Have tried various devices including Mini-ITX PC (Debian) and Raspberry Pi (Arch & Debian). Have also lent the device to several friends to try on their machines and Linux distros. In all case, the devices seems to work fine and is installed correctly but, there is simply no data coming out of it. The same dongle works perfectly under various Windows installations. Is there a similar device that does work on the Raspberry Pi?
Posts: 9
Joined: Wed May 23, 2012 8:15 am
by error404 » Sat Jun 09, 2012 8:07 pm
This dongle should without a doubt work properly in Linux, so I'm not sure what to tell you. If you're having trouble with this one, you'll probably have trouble with other similar devices as well. If you want to put your Pi online and let someone have a look maybe we could figure out the trouble...
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by stevep » Mon Jun 11, 2012 4:37 pm
rjcollingridge wrote:Failed miserably to get the Bluenext GPS dongle working under Linux


My OP dealt with getting the Bluenext working on a VirtualBox install under OS X. When I came to installing it on the Pi I followed the same steps and came unstuck - I found that someone else had written up their exerience, so copied the following steps (apologies, I have lost the original link so don't know who the author is, but thanks to him anyway!) - the main difference is that the device uses the folder ttyUSB0 instead of GPS0 when connected to the Pi. I have had mine connected and running for extended periods - 5 to 7 hours on each of the last few days:
I use Ubuntu 11.04 and wanted to finally figure out how to use my DeLorme Earthmate GPS LT-20 USB GPS dongle I bought some time ago mainly because it was inexpensive and bundled with obsolete Windows mapping software. I installed gpsd (Linux GPS daemon), gpsd-clients (axillary tools and clients for gpsd), and foxtroggps (a GPS mapping client that uses gpsd) using Synaptic.
I plugged in the USB GPS device after rebooting. I used the terminal and I entered “dmesg | tail” which told me that the USB dongle I just plugged in was a serial device called /dev/ttyUSB0 and was recognized by Linux. (Please note that ttyUSB0 is case sensitive.) I then used the gspd-clients tool by typing "gpsmon /dev/ttyUSB0" in the terminal. This talks directly to the GPS device without gpsd and it returned GPS data telling me that my connected dongle is reading GPS data, speaks “generic NMEA”, and talks at 115200 Baud.
I then used the Linux “process status” command in the terminal "ps -C gpsd - fww" which returned data and told me that gpsd daemon was working. I then used the gspd-clients GPS program or client called xgps in the terminal by typing xgps. This is a useful test client that uses the gpsd server and which returns a map of satellites, coordinates, and information about the GPS fix. This program needs the gpsd server to talk to the GPS unit but no data came up to display. Therefore, both the gpsd daemon and USB dongle were working but programs weren't talking through gpsd to USB dongle.
Lots of Googling and reading led me to find that the gpsd server daemon only needed to be configured. However, I would have figured it out easier if I had read the comments at the top of the gpsd configuration file /etc/default/gpsd. I used "sudo dpkg-reconfigure gpsd" to reconfigure gpsd which modifies the configuration file. It took a lot of time to find this simple trick and even the syntax wasn't easy to get right.
The “dpkg-reconfigure gpsd” is a terminal configuration tool program that walks you through configuring gpsd. It listens for your GPS and identifies the port of the GPS unit as /dev/ttyUSB0. It asks you if you want to accept this port and you say “YES”. Also say YES to both start gpsd automatically (start gpsd at boot) and handle attached USB GPS receivers automatically (autostart
“DEVICES”). Leave the other options or arguments blank as they are not needed. You need unplug the GPS dongle and reboot.
After rebooting, plug in the GPS dongle and it will autostart. Bingo, it works. I brought up xgps tool client again and it returned gps data from the GPS dongle
unit meaning that gpsd was now talking to the GPS dongle. I then brought up
you through configuring gpsd. It listens for your GPS and identifies the port of the GPS unit as /dev/ttyUSB0. It asks you if you want to accept this port and you say “YES”. Also say YES to both start gpsd automatically (start gpsd at boot) and handle attached USB GPS receivers automatically (autostart “DEVICES”). Leave the other options or arguments blank as they are not
needed. You need unplug the GPS dongle and reboot.
After rebooting, plug in the GPS dongle and it will autostart. Bingo, it works. I brought up xgps tool client again and it returned gps data from the GPS dongle unit meaning that gpsd was now talking to the GPS dongle. I then brought up the FoxtrotGPS client and it worked also. My GPS dongle needs to have a fix before the maping clients show a GPS connect so don't get spooked and think it is not working. Watch what is happening with the gpsd tool xgps and be sure you have a fix. The GPS can get a fix in seconds but it can also take many minutes and you need a good view of the sky.
If you plug the GPS dongle in after it has rebooted it autostarts. If you unplug the GPS dongle there is an obligatory 15 minute time out for security reasons before it will re-start. My GPS dongle also starts with it plugged in at boot if you use the -N argument but this defeats some security precautions so I did not ultimately use it.
I studied the functionality of my DeLorme GPS unit by trial and error. My unit has an LED which can be red, yellow, or green. As it is turning on it is briefly red continuously. Then it starts to flash a short red every 2 seconds as it initializes. When it changes to flashing a long red every second it is ready for a GPS client to attempt to connect through gpsd. When it flashes a long flash yellow every second it means that it has a 2 D fix and a long flash of green every second it means it has 3 D fix. Other GPS units will have a variation on this theme.
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am
by dreamgreenhouse » Mon Jun 11, 2012 6:36 pm
error404 wrote:This dongle should without a doubt work properly in Linux, so I'm not sure what to tell you. If you're having trouble with this one, you'll probably have trouble with other similar devices as well. If you want to put your Pi online and let someone have a look maybe we could figure out the trouble...


It is not working on several Linux devices as well as my RPi. It's not a RPi issue but an issue with the Linux (Debian) driver for the dongle from what we can see. The device installs correctly and is recognised fine. The issue we have is that we can see no data. Having subsequently tested further, we can see streams/burst of GPS data appearing in the buffer but the values are all zeros.
Posts: 11
Joined: Sun Mar 11, 2012 1:50 pm
by stevep » Mon Jun 11, 2012 7:25 pm
If the values are all zero's then the gps hasn't got a fix. Many (all?) gps units (proprietary ones like Garmins, as well as dongles) take quite a long time to get an initial fix from a cold start (maybe up to an hour), but once they have that fix, a subsequent restart will take less time, maybe 30 secs to a few minutes.
They also need a clear sky view, particularly to get that first fix, so you might need to place it on the outside window ledge on a usb extension cable.
If you still can't get any output using something like cgps, run sudo dpkg-reconfigure gpsd again and try a different setting. cgps should give you something like this:
Attachments
151705.jpg
151705.jpg (61.82 KiB) Viewed 7462 times
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am
by error404 » Thu Jun 14, 2012 10:00 pm
dreamgreenhouse wrote:It is not working on several Linux devices as well as my RPi. It's not a RPi issue but an issue with the Linux (Debian) driver for the dongle from what we can see. The device installs correctly and is recognised fine. The issue we have is that we can see no data. Having subsequently tested further, we can see streams/burst of GPS data appearing in the buffer but the values are all zeros.


There are other reports of exactly this dongle working fine in Linux, and every one of these dongles I've ever seen uses a bog-standard USB->RS-232 chip that works well in Linux (usually seems to be the Prolific one). I doubt this is a Pi-specific problem, but I do suspect something is wrong in the way you're reading data from the device or how you've got things configured.
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by Vikings40 » Fri Jun 15, 2012 7:06 pm
I've been trying this same device on a Fedora installation. The device is detected and mounts ok as /dev/ttyUSB0. I've tried using stty to configure and cat to read from the port and also written some c code to do the same.
I've found that it is sending bursts of data every second or so but all the data is zero (i.e. null characters).
I've tried lots of combinations of baud rate, character length, parity, flow control etc. but whatever I do it's still just null data.
Not sure what else to try so suggestions welcome.
(I haven't tried installing gpsd as it didn't seem worth it if I can't read any strings of meaningful data from the device directly.)
Posts: 6
Joined: Fri Jun 15, 2012 6:59 pm
by stevep » Sat Jun 16, 2012 12:25 pm
Vikings40 wrote: I've tried using stty to configure and cat to read from the port

Don't know how to do this, but if you post back showing what you did to read the data I'll try the same on mine and tell you what I see.
If it was me I'd install gpsd just to get it set up first. You don't have to continue using it.
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am
by jamesh » Sat Jun 16, 2012 12:45 pm
My Bluenext dongle took a while to find satellites (about 5 minutes I think) and during that time didn't do much. There is a light on the dongle which changes state when its got a fix.

This DID work on a Raspi, as well as my Ubuntu box.

James
Moderator
Posts: 10519
Joined: Sat Jul 30, 2011 7:41 pm
by Vikings40 » Sat Jun 16, 2012 2:43 pm
I tried waiting about 10 minutes but still the same output.

The command lines I used were:

stty -F /dev/ttyUSB0 speed 4800 clocal cs8
hexdump -c </dev/ttyUSB0

which gives
0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

- basically just a burst of null bytes every second or so.

I also tried cat </dev/ttyUSB0 but that doesn't show anything - I think it is ignoring nulls.

It would be interesting to know if anyone who has it working with gpsd can also read strings from the device using the command line operations.
Posts: 6
Joined: Fri Jun 15, 2012 6:59 pm
by stevep » Sat Jun 16, 2012 3:56 pm
I tried hexdump -c </dev/ttyUSB0 but nothing happens. Also tried cat </dev/ttyUSB0 and again nothing happens. I don't know much if anything about command line stuff, so have no idea what exactly you're expecting from either of these. I would have thought that you'd have to look at the gps for probably 10 to 20 seconds before it will start returning useful data (judging by what happens when I run my little Python program which uses gpsd). Can you do some sort of a loop with a command line?
Just install gpsd. At least that way you'll find out if the gps is working ( which I'm sure it will be), and probably have a better idea of the settings you should be using. Then you can do all the complicated stuff afterwards.
By the way, mine is set up at 9600.
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am
by Vikings40 » Sat Jun 16, 2012 5:37 pm
Yes - 9600 is the rate I meant (typo).
stty -F /dev/ttyUSB0 speed 9600 clocal cs8

I would have expected you would get something from the hexdump or cat in the NMEA format. Is your device on ttyUSB0?

Perhaps I'll give gpsd a try but I'm not sure what it could be doing other than listening to the serial port.
Posts: 6
Joined: Fri Jun 15, 2012 6:59 pm
by Vikings40 » Sat Jun 16, 2012 6:02 pm
I have installed gpsd and gpsd-clients. I've tried running it but can't seem to get it to show any results. What is a quick way to check if it's getting anything from the device?
Posts: 6
Joined: Fri Jun 15, 2012 6:59 pm
by stevep » Sat Jun 16, 2012 9:08 pm
Run this bit of Python (it usually has 2 or 3 loops before it picks up proper data):
Code: Select all
#       testgps.py\
import gps, os, time
session = gps.gps(host="localhost", port="2947")
session.poll()
session.stream()
while 1:
   os.system("clear")
   session.poll()
# a = altitude, d = date/time, m=mode,
# o=postion/fix, s=status, y=satellites
   print
   print "GPS reading"
   print "---------------------"
   print "latitude " , session.fix.latitude
   print "longitude " , session.fix.longitude
   print "time GPS " ,  session.fix.time
   print 'time ticks' , time.time()
   
    print 'time GMT ' , time.gmtime()

   print "Satellites (total of", len(session.satellites) , " in view)"
   time.sleep(1)
   for i in session.satellites:
      print "t", i
   time.sleep(10)
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am
by Vikings40 » Sun Jun 17, 2012 6:31 am
Thanks - I've tried that now (first time with a Python script for me).

The results look like this:
GPS reading
---------------------
latitude 0.0
longitude 0.0
time GPS nan
time ticks 1339914546.86
time GMT time.struct_time(tm_year=2012, tm_mon=6, tm_mday=17, tm_hour=6, tm_min=29, tm_sec=6, tm_wday=6, tm_yday=169, tm_isdst=0)
Satellites (total of 0 in view)
Posts: 6
Joined: Fri Jun 15, 2012 6:59 pm
by stevep » Sun Jun 17, 2012 6:45 am
The last line is your clue. Try hanging the gps out of the window, or maybe even out of the window in another room. It can take a long time to get a first fix, so you could also leave that script running for maybe an hour.
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am
by Vikings40 » Sun Jun 17, 2012 7:19 am
I have tried it out of the window. I had thought the LED was an indication though. In the manual it says it should turn from steady to flashing once it has a lock - which it does both indoors and out.

The output of the script doesn't change though. I still think it is because the data is null. I would have expected that the strings sent by the device would be compliant with the NMEA spec even when it hasn't found any satellites.
Posts: 6
Joined: Fri Jun 15, 2012 6:59 pm
by stevep » Mon Jun 18, 2012 10:21 am
Then your gps isn't configured correctly.
From the command line do:
sudo apt-get install gps gpsd-clients foxtrotgps If you haven't already)
Reboot and connect the gps.
From the command line run sudo dpkg-reconfigure gpsd
set it to start gpsd automatically, handle gps receivers automatically, enter the device as /dev/ttyUSB0, accept the defaults for the last two options.
From the command line run cgps - at first the table of data will appear blank, but after a few moments will be populated with the correct data. The only reason for it not to be working now is
1. a faulty gps receiver
2. not getting a fix from at least 4 satellites
3. faulty usb cables
4. maybe a fault (software or hardware) with the Pi - I'm thinking that maybe there is some sort of conflict with other usb devices (the same fault that people are getting with repeating keyboards or non-responsive mice etc). The only cure in this case is to use a decent power supply and known working low power wired keyboards and mice, a cat 5 network connection and not a usb wifi dongle etc etc etc.
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am
by Beenay25 » Tue Jun 19, 2012 7:57 pm
rjcollingridge wrote:Is anyone else having issues getting the BlueNEXT BN-903S working? I've bought one and it works fine under Windows. Having tried it on my Mini-ITX running Debian and a Rpi running Debian and Arch Linux, in all cases the device appears OK but, I'm simply not getting any data out of it. GPDS doesn't see any data from it. I've checked permissions issues and I'm now stuck.


I've been trying to get a BN903s working with Debian for months and it's pretty infuriating.

Works fine in Redhat or Windows. Everything checks out in Debian... but it just doesn't give ANY output.

Forums have proved useless. I've found a mixture of people giving tutorials that don't work (on Debian at least)... and self important idiots who think it's funny to give a link to the Debian documentation or Google.

If anyone does figure out how to get one of these things working in Debian (squeeze or wheezy ideally)... then I'll definitely owe them beers.
Posts: 9
Joined: Tue Feb 21, 2012 9:56 am
by stevep » Tue Jun 19, 2012 8:46 pm
I've just installed Wheezy on a second sd card this afternoon. One of the first things I did was to get the Bluenext working, and I simply followed the procedure I quoted in the above post (11th June 16.37) - ie sudo install gpsd, gpsd-clients and foxtrotgps, followed by sudo dpkg-configure gpsd, setting it up on /dev/ttyUSB0. It worked immediately. I'm not sure what else to suggest - I'm not an expert with Linux by any stretch of the imagination, and all the instructions I have followed have been copied from Google search results, initially at least I was blindly copying and pasting all the command line stuff.

The only thing I can suggest is that maybe some combinations of (usb?) hardware are preventing data being read from the gps receiver.

If you think I can help in any way let me know - maybe posting copies of configuration files or whatever???
Posts: 71
Joined: Sat Dec 24, 2011 10:12 am
by Beenay25 » Wed Jun 20, 2012 7:51 am
Thanks for the reply Steve. Those steps are pretty much what I've already done.
I think I'm going to give up with the Bluenext and buy a GPS that doesn't use the cp210x chipset.
Posts: 9
Joined: Tue Feb 21, 2012 9:56 am