Introduction
Introduction
Adding an application
Register the device
Add payload decoder
Configure the Adeunis via USB
Introduction
This is a brief explanation on how to configure a new TTN application and configure your Adeunis Field Tester for The Things Network usage.
Introduction
Your new Adeunis ARF8123AA LoRaWAN Field Tester comes together with a sticker which contains the pre-programmed Device EUI, Application EUI and Application Key with which you can register your device within the The Things Network application Console. In this how-to we will add a new application to your TTN console and setup your Adeunis Field Tester for the TTN network including the configuration of a payload decoder to visualise the data in the console.
Adding an application
Login to your TTN console, select Applications and Add application. Fill in a unique application ID and a description for the application and select Add application.
Because the Application EUI was automatically generated in the first step we now add the Adeunis pre-programmed app EUI and remove the generated key.
In the application overview screen select Application EUIs, Manage EUIs and add EUI.
Fill in the provided APP EUI from your Adeunis and confirm.
Now you can remove the generated APP EUI to end up with the pre-programmed EUI only.
Register the device
Select the tab Devices on top of the screen and select Register Device. Give the device a unique Device ID and fill in the DEV EUI and APP Key that are pre-programmed in your device. Check if the APP EUI the one you added in the step before and confirm adding the device by clicking the Register button.
Now your Adeunis Field Tester is registered you may power your device, wait for the GPS receiver to get a fix and check if data is received within the application.
Add payload decoder
You may add a payload decoder to the application to decode the data sent by the Adeunis. Select the Payload Formats button on top of the application screen. Select Payload format “Custom” from the pull-down menu and select Decoder. Add the following payload decoder script. Click the Save Payload functions to confirm.
Click the Data button om top of the screen and check if your decoder is working correctly by clicking a row of data received. Now you can see all decoded data and metadata. If not you can copy a payload message and test it in the Payload Formats menu.
The TTN configuration is completed and your Field Tester should work. Use the Integrations to make your data visible on dashboard or in another external system, e.g.TTNmapper.org .
function Decoder( bytes, port )
{
// Functions
function parseCoordinate( raw_value, coordinate )
{
// This function parses a coordinate payload part into
// dmm and ddd
var raw_itude = raw_value;
var temp = "";
// Degree section
var itude_string = ( (raw_itude >> 28) & 0xF ).toString( );
raw_itude <<= 4;
itude_string += ( (raw_itude >> 28) & 0xF ).toString( );
raw_itude <<= 4;
coordinate.degrees += itude_string;
itude_string += "°";
// Minute section
temp = ( (raw_itude >> 28) & 0xF ).toString( );
raw_itude <<= 4;
temp += ( (raw_itude >> 28) & 0xF ).toString( );
raw_itude <<= 4;
itude_string += temp;
itude_string += ".";
coordinate.minutes += temp;
// Decimal section
temp = ( (raw_itude >> 28) & 0xF ).toString( );
raw_itude <<= 4;
temp += ( (raw_itude >> 28) & 0xF ).toString( );
raw_itude <<= 4;
itude_string += temp;
coordinate.minutes += ".";
coordinate.minutes += temp;
return itude_string;
}
function parseLatitude( raw_latitude, coordinate )
{
var latitude = parseCoordinate( raw_latitude, coordinate );
latitude += ((raw_latitude & 0xF0) >> 4).toString( );
coordinate.minutes += ((raw_latitude & 0xF0) >> 4).toString( );
return latitude;
}
function parseLongitude( raw_longitude, coordinate )
{
var longitude = ( ((raw_longitude >> 28) & 0xF ) ).toString( );
coordinate.degrees = longitude;
longitude += parseCoordinate( raw_longitude << 4, coordinate );
return longitude;
}
function addField( field_no, payload )
{
switch( field_no )
{
// Presence of temperature information
case 0:
payload.temperature = bytes[bytes_pos_] & 0x7F;
// Temperature is negative
if( (bytes[bytes_pos_] & 0x80) > 0 )
{
payload.temperature -= 128;
}
bytes_pos_++;
break;
// Transmission triggered by the accelerometer
case 1:
payload.trigger = "accelerometer";
break;
// Transmission triggered by pressing pushbutton 1
case 2:
payload.trigger = "pushbutton";
break;
// Presence of GPS information
case 3:
// GPS Latitude
// An object is needed to handle and parse coordinates into ddd notation
var coordinate = {};
coordinate.degrees = "";
coordinate.minutes = "";
var raw_value = 0;
raw_value |= bytes[bytes_pos_++] << 24;
raw_value |= bytes[bytes_pos_++] << 16;
raw_value |= bytes[bytes_pos_++] << 8;
raw_value |= bytes[bytes_pos_++];
payload.lati_hemisphere = (raw_value & 1) == 1 ? "South" : "North";
payload.latitude_dmm = payload.lati_hemisphere.charAt( 0 ) + " ";
payload.latitude_dmm += parseLatitude( raw_value, coordinate );
payload.latitude = ( parseFloat( coordinate.degrees ) + parseFloat( coordinate.minutes ) / 60 ) * ( (raw_value & 1) == 1 ? -1.0 : 1.0);
// GPS Longitude
coordinate.degrees = "";
coordinate.minutes = "";
raw_value = 0;
raw_value |= bytes[bytes_pos_++] << 24;
raw_value |= bytes[bytes_pos_++] << 16;
raw_value |= bytes[bytes_pos_++] << 8;
raw_value |= bytes[bytes_pos_++];
payload.long_hemisphere = (raw_value & 1) == 1 ? "West" : "East";
payload.longitude_dmm = payload.long_hemisphere.charAt( 0 ) + " ";
payload.longitude_dmm += parseLongitude( raw_value, coordinate );
payload.longitude = ( parseFloat( coordinate.degrees ) + parseFloat( coordinate.minutes ) / 60 ) * ( (raw_value & 1) == 1 ? -1.0 : 1.0);
// GPS Quality
raw_value = bytes[bytes_pos_++];
switch( (raw_value & 0xF0) >> 4 )
{
case 1:
payload.gps_quality = "Good";
break;
case 2:
payload.gps_quality = "Average";
break;
case 3:
payload.gps_quality = "Poor";
break;
default:
payload.gps_quality = (raw_value >> 4) & 0xF;
break;
}
payload.hdop = (raw_value >> 4) & 0xF;
// Number of satellites
payload.sats = raw_value & 0xF;
break;
// Presence of Uplink frame counter
case 4:
payload.ul_counter = bytes[bytes_pos_++];
break;
// Presence of Downlink frame counter
case 5:
payload.dl_counter = bytes[bytes_pos_++];
break;
// Presence of battery level information
case 6:
payload.battery_level = bytes[bytes_pos_++] << 8;
payload.battery_level |= bytes[bytes_pos_++];
break;
// Presence of RSSI and SNR information
case 7:
// RSSI
payload.rssi_dl = bytes[bytes_pos_++];
payload.rssi_dl *= -1;
// SNR
payload.snr_dl = bytes[bytes_pos_] & 0x7F;
if( (bytes[bytes_pos_] & 0x80) > 0 )
{
payload.snr_dl -= 128;
}
bytes_pos_++;
break;
default:
// Do nothing
break;
}
}
// Declaration & initialization
var status_ = bytes[0];
var bytes_len_ = bytes.length;
var bytes_pos_ = 1;
var i = 0;
var payload = {};
// Get raw payload
var temp_hex_str = ""
payload.payload = "";
for( var j = 0; j < bytes_len_; j++ )
{
temp_hex_str = bytes[j].toString( 16 ).toUpperCase( );
if( temp_hex_str.length == 1 )
{
temp_hex_str = "0" + temp_hex_str;
}
payload.payload += temp_hex_str;
}
// Get payload values
do
{
// Check status, whether a field is set
if( (status_ & 0x80) > 0 )
{
addField( i, payload );
}
i++;
}
while( ((status_ <<= 1) & 0xFF) > 0 );
return payload;
}
Configure the Adeunis via USB
To configure the Adeunis Field test device to your personal needs you need to enter the command mode. For this you need a serial tool allowing to send hexdecimal values. CoolTerm is a good and free solution for this.
Connect the Field test device on the serial port via USB, select it in the coolTerm list with a 115200 baud speed, 8 databits and 1 stop bit communication. Activate the local echo and eventually the Line mode. Then go to menu Connection >> Send String then select hexadecimal and send the following string: FFFFFFFFFF2B2B2B
The field test will display COMMAND MODE on its screen and the terminal will print CM as a string.
The full configuration information is available in the Adeunis Field Tester user manual available at the Adeunis website.
To configure the tester to your first needs here are some of the commands you can check or change. At first unlock the operating range and then do some configuration.
COMMAND | DESCRIPTION | RESPONSE | DEFAULT VALUE |
ATT63 PROVIDER | Unblock the operating range | “O” if the operation has been accepted. | |
ATS380? | Check the frame transmission period | S380=300 | 600 |
ATS380=900 | Set the frame transmission period to 900 seconds | “O” if the operation has been accepted. | |
ATS382=1 | Ack and class mode. | “O” if the operation has been accepted. | 1 |
ATS201=7 | Set the Spreading Factor to 7 Possible values are 7 - 12 | “O” if the operation has been accepted. | 12 |
ATS220=1 | Activate ADR 0 - deactivate ADR 1 - Activate ADR | “O” if the operation has been accepted. | 1 |
AT&W | Save the current configuration to non-volatile memory | “O” if the operation has been accepted. | |
ATO | Exit command mode | “O” if the operation has been accepted. | |
AT&RST | Restart the Device | “O” if the operation has been accepted. |
As you can see you can check a value via the ATSxxx? command and set a value via ATSxxx=yyy command.
After writing the configuration and restarting the device via ATO or AT&RST the Adeunis tester is ready for the first test ride.