0

I'm stuck with my waveshare hat and it would be cool if you could help me. I would like to obtain the gps location.

I'm a python beginner and tried to use some already written code from this websites:

https://www.waveshare.com/w/upload/4/4a/GSM_GPRS_GNSS_HAT_User_Manual_EN.pdf Throws an error for the sleep function and when I outcommand it, it gives an error

https://www.rhydolabz.com/wiki/?p=18639 Throws an error for the if loop.

https://www.youtube.com/watch?v=A1zmhxcUOxw Works maybe but doesn't receive any signal from gps hat.

Unfortunately, I assume that this code is written in Python2 and it will throw an error while executing it. All my attempts to change that code in a python3 code failed.

Do you have any recommendations for me?

Thank you very much.

Philipp
  • 1
  • 2
  • Ah, let me see. So you have two problems: (1) How to get GPS data using Python 3, (2) How to convert python 2 code to python 3. For the first problem, you can read my anser to the following question: "Rpi UART to GPS Module Connection Problem": https://raspberrypi.stackexchange.com/questions/98840/rpi-uart-to-gps-module-connection-problem. But if your WaveShare GPS module is different from mine, you need a lot to time to learn how to do GPSD. (2) If the WaveShare code is in python 2, It is not that difficult to do the conversion. You can find semiautomatic tools to help you. / 歉欲阱划岐, ... – tlfong01 Dec 10 '19 at 09:09
  • Obvious and simple conversions include [print "abc"] becomes [print("abc")]. In case the translation is not python generic, but Rpi and GPS specific, such as cannot find modules to import, then you can show us that particular code snippet and see if anybody can help you. – tlfong01 Dec 10 '19 at 09:12
  • 1
    Thanks so far, first I'll try to convert my code to python3, if I still have problems afterwards, I'll come back to you – Philipp Dec 10 '19 at 09:15
  • I skimmed through the WaveShare GPS module user manual and find a section for Rpi (Page 29). For newbies, you need to use Rpi MiniCom (I prefer Rpi CuteCom) to give AT commands by hand. If you find manual mode OK. Then you can write a simple pyhon program to do the AT instruction/status communication (let me know if you cannot find examples). You can find SIM800 modules in this forum, which is similar to this part of manual. – tlfong01 Dec 10 '19 at 09:19
  • Just now I skimmed the tutorial which you mention "Throws an error for the if loop ..." is indeed the python program doing serial communication with AT commands. This is the most basic program ALL newbies need to learn. Search for "Rpi python serial "loop back" test programs" in this forum to learn more." Let me know if you get stuck in loopback testing. Good luck and cheers. – tlfong01 Dec 10 '19 at 09:27
  • I forgot to mention that (1) Tutorials using python 2, especially running in terminal text mode is almost always very OUT OF DATE. (2) You can run them in the Rpi buster GUI Thonny Python IDE. Thonny is very newbie friendly I have been using IDLE python in my Rpi3B+ for a couple of years and found it OK. But now I switched over to Thonny and find it even more newbie friendly. For example: (a) if your old programs use, TAB instead of FOUR SPACES, Thonny will do the conversion for you. If you use [print 'abc'], Thonny hints to use [print('abc'). It has other nice debugging tools as well. – tlfong01 Dec 11 '19 at 01:09
  • You are a great help. I begin to understand the code which is written there :D – Philipp Dec 12 '19 at 07:41
  • I'm going to work on it today and give you feedback afterwards. Thanks! – Philipp Dec 12 '19 at 07:42
  • Hi @Philipp, How nice to hear that you are getting started. I read the tutorial using Python 2.7 and found it well written, only problem is python 2.7. I think it is not that difficult to translate it to Python 3.7. I still highly recommend buster Thonny python 3. I would suggest you to get to know Thonny by trying some basic examples which might be useful to your project later, such as (1) ask user to input some integers, (2) find average, and print out floating pointing values etc etc. Take it easy and go slowly. I would suggest spend a couple of days playing around. Happy learning! :) – tlfong01 Dec 12 '19 at 12:21
  • Please don't give only links to understand your question: [What's wrong with “I followed this tutorial” kind of questions?](https://raspberrypi.meta.stackexchange.com/questions/2197/whats-wrong-with-i-followed-this-tutorial-kind-of-questions/2198#2198). Please explain what you have tried and what's the problem. – Ingo Dec 13 '19 at 20:52

0 Answers0