Introduction
Prerequisites
Install the Arduino IDE and libraries
Connect and program the Things Node
Obtain the Device EUI for the Things Node
Register your device with TTN
Program the Things Node
Using the Android app
Using the iPhone app
More intense mapping
Introduction
At The Things Conference we ran a workshop on how to contribute coverage measurements to TTN Mapper. To our own shock it is a slight learning curve to get The Things Node up and running. This tutorial will hopefully summarize the steps to follow to get The Things Node (or Uno) ready for mapping with TTN Mapper.
Prerequisites
A Things Node (or Things Uno)
An Android or iPhone smartphone with a working GPS and internet connection
Philips (+) screw driver
MicroUSB cable
3x AAA batteries
Install the Arduino IDE and libraries
You can follow all the steps on https://www.thethingsnetwork.org/docs/devices/node/quick-start.html, but we will repeat all necessary steps again for clarity.
Download and install the Arduino IDE from https://www.arduino.cc/en/Main/Software. Choose the correct installer for your operating system, download and install it.
Try and open the Arduino IDE and make sure that you see a window similar to the one below. In the bar at the top you will see the version number. Make sure it is at least version 1.8.5 or newer.
Go to File->Preferences. Next to Additional Boards Manager URLs type in the following and then click on OK.
https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json
Connect and program the Things Node
You will need a Philips screw driver to open up the Things Node.
Remove the two screws from the back of the Things Node, and remove the back cover. You will see the battery holder that fits 3 AAA batteries, and a micro USB port in the corner. Plug a micro USB cable into the port, and then connect the other end of the cable to your computer.
When the Node is plugged in it should receive power and the light should switch on in either red or green.
In the Arduino IDE go to Tools->Board: and choose SparkFun Pro Micro.
Also under Tools choose Processor ATmega32U4 (3.3V, 8 MHz).
If you are using a Things Uno, choose Arduino Leonardo. The rest of the steps should be the same as for the Things Node.
Then choose Tools->Port and select the port to which the Things Node is connected. The easiest to figure this out is to unplug the Node and see which port disappears. Plug it back in and choose the port that appeared. On Linux the port is mostly called /dev/ttyACM0, but on windows it can be any COM device.
To check if everything is working as expected we are going to program the Blink example into the Node.
Go to File->Examples->01. Basic->Blink. A new window should open pre-filled with some code. Go to Sketch->Upload.
If everything was successful, the light on the Things Node should switch on and off every second. If it is not flashing or working as expected, follow the troubleshooting guide at https://www.thethingsnetwork.org/docs/devices/node/troubleshooting.html
Obtain the Device EUI for the Things Node
In the Arduino IDE go to File->Examples->TheThingsNode->DeviceInfo.
A new window opens with some code pre-filled. On the 7th line you will see REPLACE_ME, and some options above it. Replace this text with the appropriate frequency plan name from the list in the line above it.
Go to Sketch->Upload.
When you see Done uploading at the bottom, go to Tools->Serial Monitor.
You should see output similar to the following:
Device Information
EUI: 0004A30B001CXX75
Battery: 3346
AppEUI: 70B3D57ED000XX32
DevEUI: 0004A30B001CXX75
Data Rate: 5
RX Delay 1: 1000
RX Delay 2: 2000
Use the EUI to register the device for OTAA
-------------------------------------------
Note down the text next to EUI: as you will need this in the next step. The EUI is an address that is unique per device. It is used to identify your device on the network. The address for your device will therefore be different than the one listed above.
Register your device with TTN
If you do not have a TTN account yet, go to https://account.thethingsnetwork.org/register to create one.
Go to https://console.thethingsnetwork.org/ and click on Applications. Then click on Add application.
An application is a group of devices. It is best to keep your TTN Mapper devices in their own application away from any other devices you have. Application ID is the most important field to fill in. This should be globally unique.
After you added an application you should see it in the list on https://console.thethingsnetwork.org/applications.
Choose the application you just created.
Under Devices click on Register device.
Device ID: choose any alphanumeric name for your device that should be unique in your application
Device EUI: type in here the EUI you retrieved from the Node in the previous step.
Click on Register.
You should see your new devices listed under Devices now. Click on it to open its settings.
You should see the Device EUI which you got from the device listed here.
Under that the Application EUI and App Key. Note down these two values.
Program the Things Node
You can use any software on the Things Node to use it for mapping. So you do not have to follow this step. The code used here is however the easiest to get it to work.
In the Arduino IDE go to File->Examples->TheThingsNode->Basic. In the window that opens you will see the code for the most basic program to communicate with The Things Network. The program will send a message via TTN every minute, every time the button is pressed or whenever the device is moved.
At the top of the code you will see the following two lines:
const char *appEui = "0000000000000000";
const char *appKey = "00000000000000000000000000000000";
Replace the 0's next to the appEui with the Application EUI you noted down from the device settings screen on the console. Also replace the 0's next to the appKey with the App key from the console.
Lastly replace the TTN_FP_EU868 or REPLACE_ME with the correct frequency plan name, as listed in the line above, for the area you live in.
Make sure the Node is still plugged into your computer. Go to Sketch->Upload.
When you see Done uploading, go to Tools->Serial Monitor. In the serial monitor you will likely see the following output:
Sending: mac join otaa
Join not accepted: denied
Check your coverage, keys and backend status. Sending: mac join otaa Response is not OK: no_free_ch Send join command failed
Using the Android app
This step assumes you have an Android smartphone. If you have an iPhone, skip to the next step.
Download the TTN Mapper app from the Play Store: https://play.google.com/store/apps/details?id=com.jpmeijers.ttnmapper
Optional: Download the TTN Mobile app from the Play Store: https://play.google.com/store/apps/details?id=com.async.ttn
Open the TTN Mapper app. If you see a popup, click on Link Device, or follow the next steps.
Click on the blue circle with three white dots at the bottom left to open the menu. Select Settings.
Click on View and modify linked device.
Click on Log in and select device.
Log in with your TTN login details.
You should see a list of applications that are registered on your TTN account.
Choose the application you created earlier.
Select the device you want to use to map with.
At the top of the Link Device screen you should see all your device configuration filled in.
Click on close and go back to the main screen where you see the map.
At the bottom right you will see a slider switch to enable mapping. Click on this switch.
Most likely the app will now ask you for permissions to use the GPS in your device. Click on configure.
There are three permission types we need. Under each one clikc on Ask For Permission and then Allow.
When you are done click on Continue.
Try to switch on mapping mode again.
The app is now armed. As soon as a packet is received from your device, a circle will be drawn on the map on your phone. If the location of the gateway is known, the circle will be connected to the gateway with a line.
All results will by default be uploaded to ttnmapper.org, and also saved in a logfile on your phone. You can change this from the settings menu.
You can also log into the TTN Mobile app, select your application and device there, and then click on Use with TTN Mapper.
Using the iPhone app
From the App Store install the TTN Mapper app.
Also install the TTN Mobile app.
Open the TTN Mobile app and log in using your TTN login details.
Select the application you have created earlier that contains the device you want to map with.
Select the device you want to map with.
Click on Use with TTN Mapper.
The TTN Mapper app should now open and automatically be linked to the selected device. All you have to do now is to enable mapping and wait for your device to send a message.
More intense mapping
By default the Things Node only sends a message every minute. This means when you drive or cycle through a city you will travel quite far before the Node will send the next message. To produce a good coverage map one needs more packets in more different locations. One solution is to send messages more often.
In the Basic example you can change
node->configInterval(true, 60000);
to
node->configInterval(true, 10000);
to send a message every 10 seconds.
If you are using the default fastest data rate this should just be possible while keeping to the 1% duty cycle of the regulations. You however do break the TTN fair use policy, but as long as you only map for an hour or so per day it is still fine.
Another option is to use the following example: