Example Code for Arduino-GPS TCP (Library)

Last revision 2026/01/24

This article offers a detailed guide on using the Arduino-GPS TCP library to transmit GPS data, including hardware and software setup, server connection, and function explanations, utilizing SIM808 module with the Leonardo mainboard.

Hardware Preparation

Software Preparation

Preparations

  1. Install library to Arduino-1.5.*\libraries (not Documents\Arduino\Library)

  2. Find an available server and get the following settings information: (Here, we just show it as an example which doesn't work)

    • char tcpip[]=""TCP","183.230.40.39","876"";
    • char datastreams_id[]="GPS Data";
    • char device_id[]="135506";
    • char api_key[] ="Qjvc7i1UwteNzL1jOGZ8VsVJ04gA";
  3. Upload the sketch and open the serial monitor, wait until the module initialization finished

  4. Then it will get the state if there is any available GPS data. If it is avaible, then the data will be sent to the server

Result

DFR0355_GPS_TCP_serial

Note: The GPS feature should be used outside, here we used it just for an explanation of the library.

Function Explanation

  • Char Tcpip[]= "" TCP\ ", " 183.230.40.39\ ""876"": This is the TCP report format, you can modify the parameters appropriately
  • Mygps.availableGPS (): Check if valid GPS data is received. Sometimes you may not receive GPS data, the system will automatically filter it until it receives valid GPS data
  • Mygps.readGPS (): Get the GPS data
  • Mytcp.connectTCP (): Link to TCP
  • Mytcp.setServerParameters (): Set user information for TCP
  • Mytcp.sendTCPdata (): Send data. In the example sketch, we use it to send GPS data
  • Mytcp.disConnectTCP (): Disconnect the TCP link. Of course if you want to continue sending data, you can also send it again but not disconnect the link as long as the server supports continuous transmission

Was this article helpful?

TOP