Sending GPS Data to Web Server / Telegram

Intermediate This section will guide you step by step to send the GPS data obtained from the Pico LTE device to a Web Server.

The Pico LTE device provides all the necessary components to receive GPS data and send it to a web server or Telegram. This tutorial will guide you step-by-step on how to send GPS data.

Before starting this Pico LTE tutorial, the Pico LTE SDK installation and configuration steps must be completed. Below are the system requirements for this tutorial. If you haven't followed the SDK installation steps, please refer to the page below before proceeding with the tutorial. The details of these steps will not be covered in this tutorial.

System Requirements

Hardware Requirements Software Requirements
• Sixfab Pico LTE
• Micro USB cable
Passive GNSS/GPS Antenna u.FL Plug – 100mm
• Thonny IDE


Below is shown how to connect passive GNSS antenna



If you have completed all the requirements, you are ready to send the GPS data. Let's get started!

Preparing Coding Environment

  1. Download the Pico LTE SDK repository to your local machine. If you have already downloaded it, skip this step.
  2. Open script "examples → gps → send_location_to_server.py or send_location_to_telegram.py" from the repository via Thonny IDE.
  3. If you haven't, create a config.json file in the root directory of Pico LTE device.

Test the Code Example

If you want to send GPS data to a web server, copy the following code block into the config.json file and enter the Server URL, Username, and Password sections. If Username and Password are not required, you can delete them.

{
    "https":{
        "server": "YOUR_SERVER_URL",
        "username": "YOUR_USERNAME",
        "password": "YOUR_PASSWORD"
}

If you want to send GPS data to Telegram, copy the following code block into the config.json file and enter the Telegram Token and Chat ID sections. How to obtain the Token and Chat ID is explained in the 'Send Message to Telegram Channel' tutorial. You can refer to that tutorial for more detailed information.

{
    "telegram":{
        "token": "YOUR_TELEGRAM_TOKEN",
        "chat_id": "YOUR_TELEGRAM_CHAT_ID"
    }
}

Then save it to your Pico LTE device.

Run the "send_location_to_server.py" or "send_location_to_telegram.py" script that you opened in Thonny IDE.

send_location_to_server.py

send_location_to_server.py

>>> %Run -c $EDITOR_CONTENT INFO: GPS Example INFO: Trying to fix GPS... INFO: {‘status’: 0, ‘response’: [‘+QGPSLOC: 110915.000,3734.6884N,1219.2982W,1.4,22.8,3,0.00,0.0,0.0,070723,05’, ‘OK’], ‘value’: [‘3734.6884N’, ‘1219.2982E’]} INFO: Lat-Lon: [‘3734.6884N’, ‘1219.2982W’] INFO: Sending message to the server... INFO: {‘response’: [‘OK’, ‘+QHTTPPOST: 0,200’], ‘status’: 0} INFO: Message sent successfully.
send_location_to_telegram.py

send_location_to_telegram.py

>>> %Run -c $EDITOR_CONTENT INFO: GPS Example INFO: Trying to fix GPS... INFO: {‘status’: 0, ‘response’: [‘+QGPSLOC: 071201.000,3734.6884N,1219.2982W,1.8,16.9,3,0.00,0.0,0.0,020713,04’, ‘OK’], ‘value’: [‘3734.6884N’, ‘1219.2982W’]} INFO: GPS Fixed. Getting location data... INFO: Lat-Lon: [‘3734.6884N’, ‘1219.2982W’] INFO: Sending message to telegram channel... INFO: {‘status’: 0, ‘response’: [‘{“ok”:true,“result”:{“message_id”:21,“from”:{“id”:*,“is_bot”:true,“first_name”:“Pico LTE”,“username”:“***”},“chat”:{“id”:***,“first_name”:“*”,“username”:“*”,“type”:“private”},“date”:1688628491,“text”:“3734.6884N,1219.2982W”}}’], ‘interval’: 0} INFO: Message sent successfully.

Troubleshooting

+CME ERROR: 516

This error means that your modem couldn't fixed the location. Be sure that you're trying to connect GPS in outdoor, or attach a better antenna to connect easier.

+CME ERROR: 504

This error provides you an information about an ongoing process on the modem with GPS. You can ignore it and continue to your own process. It is possible to exit the ongoing job, and restart your code.