Page tree
Skip to end of metadata
Go to start of metadata

This data measurement is implemented using  Adafruit Ultimate GPS featherwing and Adafruit Feather M0 WiFi (ATWINC1500) micro-controllers.

1.0 Adafruit Ultimate GPS featherwing Overview

An overview of the GPS featherwing can be found here.

2.0 Diagram of GPS sensor and Adafruit Feather M0 WiFi connection

An example of a GPS micro-controller connection to Feather M0 is shown below.

Connection tips:

  • connect both feather M0 and GPS sensor to power and ground
  • connect TX of GPS to RX of Feather M0 
  • connect RX of GPS to TX of Feather M0

3.0 Implementation

The Library

Include the config.h and UCW_GPS  libraries

Include library
#include "config.h"
#include "UCW_GPS.h" 

Edit the config.h library

  • The struct, cfg, allows the user to provide access token for authentication, server address and port number, indicate if connection mode is secured and specify server connection medium (REST_API or MQTT)  

    config.h: struct_cfg
    static UCWConfig cfg = {
      .host = "",
      .port = 80,
      .isSecuredConnection = false,
      .useMqtt = false,
      .mqttUser = UCW_MQTT_USER,
      .mqttPassword = UCW_MQTT_PASS,
      .token = "your_token"
  • In this example, connection to the UCW server is via a WiFi network. WiFi credentials (SSID and password) are provided here 

    WiFi credentials
    /******************************* WiFi **************************************/
      The UCW_WiFi client will work with the following boards:
        - Feather M0 WiFi ->
        - Feather HUZZAH ESP8266 ->
        - HUZZAH ESP8266 Breakout ->
        - Feather WICED ->
    #define WIFI_SSID       "your_SSID"
    #define WIFI_PASS       "your_password"
    #include "UCW_WiFi.h"
    UCW_WiFi ucw(&cfg, WIFI_SSID, WIFI_PASS);

Provide data stream name and device ID

device ID and data stream are defined in the main file 

define data stream & device ID
#define DEVICE_ID   "your_device_ID"
#define DATA_STREAM "GPS info using RMC and GGA"

Create object  for UCW_GPS.h library 

gps library object
UCW_GPS ucw_gps; //create GPS object

connect() method is used to connect the micro-controller to the WiFi network. This is called in the void setup () section of the arduino file


printNetworkInfo() is called to print the details of the WiFi network that the micro-controller is connected to 


Setup GPS 

setupGPS() method Initialise the GPS module, sets the update rate to 1Hz, surpresses the output to only RMC and GGA NMEA statements and activates updates of the GPS antenna 


sys() method ensures the connection to the UCW cloud/server is still valid/established. This method is called in the void loop()  section


Read Data

The readGPS() method extracts relevant information from the NMEA statements received from the GPS sensor and returns the type gpsParams.

In this example, the latitude, longitude date, and time are extracted from the struct and saved as a JSON string gpsData 

Read data
gpsParams data = ucw_gps.readGPS(); // read GPS info
String Time = String(data.Hour) + ":" + String(data.Min) + ":" + String(data.Sec) + "." + String(data.millisec);
String Date = "20" + String(data.Year) + "-" + String(data.Month) + "-" + String(data.Day);
String timeStamp = Date + " " + Time;

String gpsData = "{\"Latitude\": %lat,\"Longitude\": %long,\"Timestamp\": \"%tStamp\"}";
gpsData.replace("%lat", String(data.Latitude));
gpsData.replace("%long", String(data.Longitude));
gpsData.replace("%tStamp", timeStamp);

Sending the data

The data is sent to the server using the sendData() method

Example using sendData method
ucw.sendData(DEVICE_ID, DATA_STREAM, gpsData);

The full example can be found here.

  • No labels