HasnainMoavia
Posts: 14
Joined: Sun Feb 24, 2019 12:04 am

AdaFruit Ultimate GPS Python Code Error

Sun Feb 24, 2019 12:19 am

Hello!
I am new to Raspberry and Python. I am currently working over Adafruit Ultimate GPS Breakout. I believe I have fulfilled all the settings and libraries for the Ultimate GPS as given in it's handout given by the Adafruit site.
When I run the code, it gives an error.
Traceback most recent call lost
"gps_simpletest.py" line 11, in <module>
RX = board.RX
Attribute Error: module"board" has no attribute "RX".

It will be great of you if anyone can guide me in sorting out this issue.

Regards:
Hasnain Moavia

User avatar
MrYsLab
Posts: 431
Joined: Mon Dec 15, 2014 7:14 pm
Location: Noo Joysey, USA

Re: AdaFruit Ultimate GPS Python Code Error

Sun Feb 24, 2019 3:22 pm

Did you follow the installation instructions? https://learn.adafruit.com/adafruit-ult ... on-parsing

If you are still having issues, I suggest you contact Adafruit customer service.

HasnainMoavia
Posts: 14
Joined: Sun Feb 24, 2019 12:04 am

Re: AdaFruit Ultimate GPS Python Code Error

Sun Feb 24, 2019 8:50 pm

Yeah I have followed all the steps as given in the link, but it still gives the error which is in the python code.
On the website of the forums of Adafruit, in case of any problem in the coding i.e. Python a link of Raspberrypi.org/forums is given and that is why I tried to look for a solution here.

When I run the code it gives the above mentioned error, which I believe is in the code. I think I should make some changes in the Python code, but I am not sure what to change and change to what so that it could work.

User avatar
MrYsLab
Posts: 431
Joined: Mon Dec 15, 2014 7:14 pm
Location: Noo Joysey, USA

Re: AdaFruit Ultimate GPS Python Code Error

Sun Feb 24, 2019 9:44 pm

Glancing at the Adafruit files on Github, I believe board.py is defined here: https://github.com/adafruit/Adafruit_Bl ... c/board.py

The RPi pinout is imported here: https://github.com/adafruit/Adafruit_Bl ... ard.py#L46

Looking at https://github.com/adafruit/Adafruit_Bl ... i_40pin.py there is no RX, but there is RXD. I think the example code was coded against a board other than the RPi. If you look at the other boards that they support, some of them have a pin called RX. Looks like sloppy testing and pin naming by Adafruit.

HasnainMoavia
Posts: 14
Joined: Sun Feb 24, 2019 12:04 am

Re: AdaFruit Ultimate GPS Python Code Error

Sun Feb 24, 2019 9:59 pm

Yeah it's stated in the Python code in the link https://learn.adafruit.com/adafruit-ult ... on-parsing

Code: Select all

# Define RX and TX pins for the board's serial port connected to the GPS.
[b]# These are the defaults you should use for the GPS FeatherWing.[/b]
# For other boards set RX = GPS module TX, and TX = GPS module RX pins.
RX = board.RX
TX = board.TX
They have mentioned in the code above that it is for GPS FeatherWing, but as I am using Raspberry Pi and this Adafruit Ultimate GPS Breakout, so I don't know how to fix it. What I believe is that the problem is in the code and I don't have any clue how to fix it.

User avatar
MrYsLab
Posts: 431
Joined: Mon Dec 15, 2014 7:14 pm
Location: Noo Joysey, USA

Re: AdaFruit Ultimate GPS Python Code Error

Sun Feb 24, 2019 10:06 pm

In gps_simpletest.py you can try changing:

Code: Select all

# Define RX and TX pins for the board's serial port connected to the GPS.
# These are the defaults you should use for the GPS FeatherWing.
# For other boards set RX = GPS module TX, and TX = GPS module RX pins.
RX = board.RX
TX = board.TX
To

Code: Select all

# Define RX and TX pins for the board's serial port connected to the GPS.
# These are the defaults you should use for the GPS FeatherWing.
# For other boards set RX = GPS module TX, and TX = GPS module RX pins.
RX = board.RXD
TX = board.TXD

HasnainMoavia
Posts: 14
Joined: Sun Feb 24, 2019 12:04 am

Re: AdaFruit Ultimate GPS Python Code Error

Mon Feb 25, 2019 10:32 am

Code: Select all

# Define RX and TX pins for the board's serial port connected to the GPS.
# These are the defaults you should use for the GPS FeatherWing.
# For other boards set RX = GPS module TX, and TX = GPS module RX pins.
RX = board.RXD
TX = board.TXD
I have changed the respective as you said.

It gives an error here:

Code: Select all

# Create a serial connection for the GPS connection using default speed and
# a slightly higher timeout (GPS modules typically update once a second).
uart = busio.UART(TX, RX, baudrate=9600, timeout=3000)
Error Stating:

Code: Select all

File "/home/pi/.local/lib/python3.5/site-packages/busio.py".
raise RuntumeError(busio.UART not supported on this platform. Please use any serial instead.')
RuntimeError: busio.UART not supoorted on this platform. Please use pyserial instead.

I tried rename the RX and TX as RXD and TXD as we did with the previous but it gave an error:

Code: Select all

NameError: name 'TXD' is not defined
I reversed the change that I made. So at the moment I have the above error for UART.

BTW thanks a lot for your help.

User avatar
B.Goode
Posts: 10109
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: AdaFruit Ultimate GPS Python Code Error

Mon Feb 25, 2019 10:47 am

I have never used this add-on or its associated software.

But it seems apparent that you have not followed the advice in the Adafruit documentation:
On the Raspberry Pi, comment out the uart = busio(...) line, and uncomment the import serial and uart = serial.Serial(...) lines, changing /dev/ttyUSB0 to the appropriate serial port.
Since this is an accessory made, sold and supported by a third party perhaps they will be best placed to give you knowledgeable information about their own products -
https://forums.adafruit.com

HasnainMoavia
Posts: 14
Joined: Sun Feb 24, 2019 12:04 am

Re: AdaFruit Ultimate GPS Python Code Error

Mon Feb 25, 2019 1:21 pm

I am once again trying to do it all from the beginning. As given in the https://learn.adafruit.com/adafruit-ult ... on-parsing

The first step is: https://github.com/adafruit/Adafruit_CircuitPython_GPS

By going through the steps when I run this code:

Code: Select all

circuitpython-build-bundles --filename_prefix adafruit-circuitpython-gps --library_location .
It download some files and then at the end gives an error:

Code: Select all

FileNotFoundError: [Errno2] No such file or directory: 'build_deps/circuitpython/mpy-cross/mpy-cross'
Can you please identify the error, that where am I making a mistake?

Thanks

User avatar
B.Goode
Posts: 10109
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: AdaFruit Ultimate GPS Python Code Error

Mon Feb 25, 2019 2:02 pm

Can you please identify the error, that where am I making a mistake?


Maybe your error is in assuming that the Circuit Python version of the code can be transferred to a Raspberry Pi?

But as previously suggested, best to check with Adafruit.

User avatar
MrYsLab
Posts: 431
Joined: Mon Dec 15, 2014 7:14 pm
Location: Noo Joysey, USA

Re: AdaFruit Ultimate GPS Python Code Error

Mon Feb 25, 2019 2:05 pm

The Adafruit page, IMHO, is a little overwhelming for someone who is new to RPi and Python. I need to compliment you for not giving up. Looking at the Adafruit page here is what is said:

If you want to use the built-in UART, you'll need to disable the serial console and enable the serial port hardware in raspi-config. See the UART/Serial section of the CircuitPython on Raspberry Pi guide for detailed instructions on how to do this.

The section they are referring to is here: https://learn.adafruit.com/circuitpytho ... art-serial

Keep scrolling down the page, once you get past their sales pitch, you will see instructions on how to use serial. There are 2 approaches, one which is "simpler" requires that you have a USB to serial converter. There is also a "hardway" described here: https://learn.adafruit.com/circuitpytho ... -uart-8-15.

There are are a few caveats for using the "hardway": if you're using a PiUART or console cable or HAT that lets you connect directly to the console, that will no longer work and you'll have to use the HDMI+Keyboard or ssh method of running commands!

If you don't know what a PIUART is, or are using a console cable or HAT, you probably can go with the "hardway".

Hopefully, this will get you on the right path.

User avatar
bensimmo
Posts: 4552
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: AdaFruit Ultimate GPS Python Code Error

Mon Feb 25, 2019 4:45 pm

Honesty though, while Circuit Python can be used on the Pi, if their instructions are not working. Tell them and get them to fix it, they'll want to know.

That is their own personal version of python software, they know and maintain it.

You don't have to use Circuit Python and you should be able to follow most Pi UART (serial0) based GPS tutorials.

User avatar
bensimmo
Posts: 4552
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: AdaFruit Ultimate GPS Python Code Error

Mon Feb 25, 2019 4:50 pm

MrYsLab wrote:
Mon Feb 25, 2019 2:05 pm
The Adafruit page, IMHO, is a little overwhelming for someone who is new to RPi and Python. I need to compliment you for not giving up. Looking at the Adafruit page here is what is said:

If you want to use the built-in UART, you'll need to disable the serial console and enable the serial port hardware in raspi-config. See the UART/Serial section of the CircuitPython on Raspberry Pi guide for detailed instructions on how to do this.

The section they are referring to is here: https://learn.adafruit.com/circuitpytho ... art-serial

Keep scrolling down the page, once you get past their sales pitch, you will see instructions on how to use serial. There are 2 approaches, one which is "simpler" requires that you have a USB to serial converter. There is also a "hardway" described here: https://learn.adafruit.com/circuitpytho ... -uart-8-15.

There are are a few caveats for using the "hardway": if you're using a PiUART or console cable or HAT that lets you connect directly to the console, that will no longer work and you'll have to use the HDMI+Keyboard or ssh method of running commands!

If you don't know what a PIUART is, or are using a console cable or HAT, you probably can go with the "hardway".

Hopefully, this will get you on the right path.
It has to ensure the hardest, the HAT uses serial UART pins (that's the TX/RX pins board it trying to setup).

Once Raspi-config (or Raspberry Pi Setting in the desktop) has been used to disable the console and enable the port.
A reboot
In a terminal windows
cat /dev/serial0
Should get a stream of data from it.

HasnainMoavia
Posts: 14
Joined: Sun Feb 24, 2019 12:04 am

Re: AdaFruit Ultimate GPS Python Code Error

Tue Feb 26, 2019 1:00 am

I am using the Hard way to configure and use the GPS module; not an FTDI cable, which transfers it to a usb cable.
https://learn.adafruit.com/circuitpytho ... -uart-8-15

There is a problem in the
Install the CircuitPython GPS Library
. I downloaded some of the libraries and files from the GitHub, but there are different errors which arises. I am working over it, if I couldn't make it, will further ask again.

At the moment, I have two questions:
1: After going through the Hard setup of the GPS module, I would have to use the following code and make it un-comment right?

Code: Select all

# for a computer, use the pyserial library for uart access
#import serial
#uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=3000)


or shall I use keep using:

Code: Select all

# Create a serial connection for the GPS connection using default speed and
# a slightly higher timeout (GPS modules typically update once a second).
uart = busio.UART(TX, RX, baudrate=9600, timeout=3000)
I have tried both, but is shows up errors, I will give it another try if I couldn't make it. I will post it here then.

2: Keeping in view that I am using the Hard Setup; I am going to use another sensor, which I plug-in through the USB port of the Raspberry Pi. But as for Hard Setup I had made:

Code: Select all

sudo raspi-config
From interfacing Options, I have made:
"Would you like a login shell to be accessible over serial?" to "No"
My question is that, in case if I use another sensor from the USB port, will it work or not?

Thanks

User avatar
bensimmo
Posts: 4552
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: AdaFruit Ultimate GPS Python Code Error

Tue Feb 26, 2019 6:01 am

Ignore 'Python' for now.

In raspi-config you set
"Would you like a login shell to be accessible over serial?" to "No
Which is correct.
There will also have been another question after that to enable the Serial Port, you should answer yes to this.
and reboot.
the text in
/boot/cmdline.txt
and
/boot/config.txt
will show if the settings are correct, post them up if you want a double check.


At this point at a terminal window.
cat /dev/serial0
as I mentioned should be giving you a stream of NMEA lines.
That is your basic test, only if that is working will python work.

I don't know CircuitPython and I'm not going to install it, other than on the Adafruit CPX.
the best people to ask are Adafruit!, they created it, they know the ins and out of it, it's their own work and you are using it with their own hardware. They know what they are talking about. It's a win, win to ask them.

I think you should be using

Code: Select all

# for a computer, use the pyserial library for uart access
import serial
uart = serial.Serial("/dev/ttyserial0", baudrate=9600, timeout=3000)
note the change to the tty part.

If you plug in a USB device, it should just work, no matter what the Serial Port is set to, since you are now using a USB port and not the 2 GPIO pins Serial Port. The are completely different in this respect. Which is nice :-)

you'll find the USB on ttyUSB0 or ttyACM0
(my ublox 8 (M8030) is on ttyACM0)
Check with lsub [ that is LUSB in lower case] that the USB is seen.

then as before, but now use
cat /dev/ttyUSB0
or
cat /dev/ttyACM0
to see which gives the NMEA data stream.

HasnainMoavia
Posts: 14
Joined: Sun Feb 24, 2019 12:04 am

Re: AdaFruit Ultimate GPS Python Code Error

Tue Mar 05, 2019 11:23 am

Thanks a lot for your help and guidance. I am going to work soon over it and look for it's further errors.
Question: a)Shall I keep configuring the GPS sensor using this Hard Setup way or shall I use FTDI cable to access the data on Raspberry Pi?

I have few more question to ask regarding the FTDI cabe connection:
I wants to use the Adafruit GPS Breakout directly on my laptop using the ftdi cable connection.Before buying the FTDI cable, I wants to look for answers before going ahead. I have searched over the internet and also on the Adafruit site. I also asked on the Adafruit forum but haven't received any reply yet. What I found is:
https://learn.adafruit.com/ftdi-friend/ ... di-drivers
https://forums.adafruit.com/viewtopic.p ... 26#p732626
1)Do you know which steps shall I follow to accurately get the data from the sensor on the laptop? And do I have to install extra drivers for this cable?
2) After accessing the data from the sensor, if it is connected to the laptop directly; how can I edit and read the data from the sensor and edit it or how can I take the values from the sensor and use it in Python in real time?


Please keep in view that I am using Windows 10 on my laptop.

Please answer the questions with respect to the questions number given.
Thanks in advance!
Last edited by HasnainMoavia on Tue Mar 05, 2019 11:41 am, edited 2 times in total.

User avatar
B.Goode
Posts: 10109
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: AdaFruit Ultimate GPS Python Code Error

Tue Mar 05, 2019 11:39 am

Edit: asked user to state "what Operating System is running on your laptop. " That information has now been added. And as a consequence I have flagged the post for the attention of a Moderator.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12991
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: AdaFruit Ultimate GPS Python Code Error

Tue Mar 05, 2019 1:23 pm

I'm not sure I understand what the consequence is that the Original Poster is running windows 10 on his laptop, as long as he is using a raspberry pi.

xxEoD2242
Posts: 2
Joined: Sat Jun 15, 2019 4:02 pm

Re: AdaFruit Ultimate GPS Python Code Error

Sat Jun 15, 2019 4:08 pm

So, I'm not sure if the original question of making the Adafruit GPS library code is still valid or if you have figured it out, but here is what I did to get it working:

Step 1:
When you do the pip install for the adafruit_gps.py, the local bin file is most likely not being loaded correctly. I'm not sure if that is a Debian issue, a python issue or an Adafruit issue. Regardless, go to the following path: /usr/local/lib/python<your version number>/dist-packages and find the file that says adafruit_gps.py.

Copy this file to the same directory you are going to run your code. (Yes, this is annoying if you are calling this file from a different place, like I will be for my system) This will solve the file issues.

Step 2:
If you are using pi, follow the steps to turn off the serial monitor. Once that is completed, you then need to go ahead reboot. Then, change the following lines as follows:

RX = board.RXD
TX = board.TXD

This will update the correct pins for the Pi.

Step 3:
Ensure that you change the serial line to the following:

uart = serial.Serial("/dev/serial0", baudrate=9600, timeout=3000)

Make sure to put the serial port that you use if you aren't doing it the standard way.

Run the file again and you should see the data.

Return to “Python”