Is there a way to access the status and the XY-coordinates from a GPS-connection established by the GPS-widget in QGIS 3 via Python?

I want to establish the connection with the widget to have better control of the connection (like changing ports) and status checks, but need the coordinates inside a Python plugin.

  • This is a good one! There is a panel to view GPS in the menu View- Panels- GPS information. There must be a way to get that info.
    – Cary H
    Commented Dec 21, 2018 at 19:17
  • Seems to be a bigger issue.. even in the QGIS mailinglist I got no reaction to this question.
    – Firefly
    Commented Dec 22, 2018 at 9:23
  • 1
    When keeping the map always centered over the current position, it is possible to get the coordinates with canvas = iface.mapCanvas() canvas.center() .
    – Firefly
    Commented Dec 28, 2018 at 21:19
  • 1
    gis.stackexchange.com/questions/187985/… This is a QGIS 2 response but we can look for the same function in QGIS 3.4 docs
    – Cary H
    Commented Feb 20, 2019 at 16:13

1 Answer 1


Thanks to the comment of @CaryH I found a solution.

For QGIS 2:


For QGIS 3:


So using the following code

connectionRegistry = QgsApplication.gpsConnectionRegistry()
connectionList = connectionRegistry.connectionList()
GPSInfo = connectionList[0].currentGPSInformation()

After that it is possible to access all information of the widget-gps-connection using for example


All available commands are listed at https://qgis.org/pyqgis/3.2/core/Gps/QgsGpsInformation.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.