Getting Started with u-blox Thingstream and PointPerfect
Arduino Example 18: PointPerfect Client
From the menu, select the following: File > Examples > SparkFun u-blox GNSS v3 > ZED-F9P > Example18_PointPerfectClient.
Once open, you will need to adjust the code based on your region, WiFi credentials, and decryption keys. Click on the secrets.h tab.
Adjust for Region
By default the example is set up for the US SPARTN 1.8 service. To adjust for Europe, simply adjust the topic provided for the MQTT_TOPIC_SPARTN[]
array.
language:c
const char MQTT_TOPIC_SPARTN[] = "/pp/ip/eu"; // This topic provides the SPARTN corrections for IP only: choice of {eu, us}
At the time of writing, there were only three options for corrections. To view the available topics, head back to Location Services > Location Things and select your Thing. Select the Topics tab. There will be a few topics available. Look for your region listed under "IP correction topic for _____ region
" where "_____
" is abbreviation for your region. You can also check out the available MQTT topics from u-blox PointPerfect documentation.
Add WiFi Credentials Decryption Keys
Enter your WiFi network name and password into the by replacing <YOUR SSID>
and <YOUR PASSWORD>
, respectively.
language:c
const char ssid[] = "<YOUR SSID>";
const char password[] = "<YOUR PASSWORD>";
Add Decryption Keys
Under Location Services > Location Things and select your Thing. Select the Credentials tab. There are four arrays that need to be configured. Replace the following values listed below. Note that the values below are listed with respect to thingstream.
- Client ID (e.g.
MQTT_CLIENT_ID[]
) - Client Key (e.g.
AWS_CERT_PRIVATE[]
) - Client Certificate (e.g.
AWS_CERT_CRT[]
) - Root Certificate (e.g.
AWS_CERT_CA[]
)
The Arduino example code lists the Amazon Root Certificate first and the Client Key arrays last. Make sure that you are copying and pasting the values exactly as provided and not missing any characters within the quotes or parentheses.
language:c
// <Your PointPerfect Thing> -> Credentials -> Client Id
static const char MQTT_CLIENT_ID[] = "<ADD YOUR CLIENT ID HERE>";
// <Your PointPerfect Thing> -> Credentials -> Amazon Root Certificate
static const char AWS_CERT_CA[] PROGMEM = R"EOF(
-----BEGIN CERTIFICATE-----
<ADD YOUR CERTICICATE HERE>
-----END CERTIFICATE-----
)EOF";
// <Your PointPerfect Thing> -> Credentials -> Client Certificate
static const char AWS_CERT_CRT[] PROGMEM = R"KEY(
-----BEGIN CERTIFICATE-----
<ADD YOUR CERTICICATE HERE>
-----END CERTIFICATE-----
)KEY";
// Get this from Thingstream Portal
// <Your PointPerfect Thing> -> Credentials -> Client Key
static const char AWS_CERT_PRIVATE[] PROGMEM = R"KEY(
-----BEGIN RSA PRIVATE KEY-----
<ADD YOUR KEY HERE>
-----END RSA PRIVATE KEY-----
)KEY";
Upload Code
When ready, select the correct board definition from the menu (in this case, Tools > Boards > SparkFun ESP32 IoT RedBoard). The board definition will depend on the ESP32 development board that you purchased. Then select the correct COM port that the board enumerated to (in this case, it was COM13). Hit the upload button.
What You Should See
Open the Arduino Serial Monitor at 115200 baud. The ESP32 will attempt to connect to your WiFi network. You will notice a period every second indicating that it is trying to connect to your WiFi network.
Type a character to send a character to your Arduino and hit the Send button.
If all is well, you should see the following output indicating that the correction data is being received! Data from the subscribed topic will be pushed to the ZED. The output will indicate if the correction data is successfully decrypted for the ZED. Watch the accuracy converge and decrease to a smaller number. Depending on what satellites are in view, it may take a little time before you reach the RTK floating or fixed solution.
Below is the output once the RTK Fixed Solution was achieved. You will notice that the values converged to a point with a horizontal accuracy of about 14mm! Your accuracy may vary depending on the satellites in view and Internet connection.