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
- DFR0355 SIM808 with Leonardo mainboard x1
- GSM & GPS Antennas (Included) x1
- External power supply (7-23V, DC) x1
- SIM card (GSM/GPRS) x1
- FIT0265 Micro USB Cablex1
Software Preparation
- Download and install the Arduino IDE: Click to Download Arduino IDE
- Download and install the SIM808 library: SIM808 library
Preparations
-
Install library to
Arduino-1.5.*\libraries(not Documents\Arduino\Library) -
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";
-
Upload the sketch and open the serial monitor, wait until the module initialization finished
-
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

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?
