Sodaq LoRa One

Install the IDE under Linux

 Setup of antenna, GPS and pins

Layout

 Register the board with The Things Network

Setup the SodaqOne to send data to your application

Start the Arduino IDE and open the serial-monitor in the Tools menu. Configure the device with info you got in the previous paragraph.

Convert received data

Download source code and compiled java executable: Download.
Execute with "java -jar target/sodaqone-0.0.1-SNAPSHOT-jar-with-dependencies.jar D170A3574A33275E331FAC64EE023F0002000005FF"

package com.clueless.sodaqone;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;

import lombok.extern.slf4j.Slf4j;

/**
 * @author milo
 *
 */
@Slf4j
public class Main {
    // Amsterdam Amstel train station
    // Lat : 52.3460135, 52° 20' 45.649"
    // Long: 4.9177772, 4° 55' 3.998"
    private static final String DEFAULT_DATA = "D170A3574A33275E331FAC64EE023F0002000005FF";

    /**
     * @param args - String[]
     */
    public static void main(String[] args) {
        log.debug("main: args='{}'", args.length > 0?args[0]:"");

        String data = DEFAULT_DATA;
        if (args.length > 0) data = args[0];

        Integer timeStamp = Integer.reverseBytes(new Long(Long.parseLong(data.substring(0, 8), 16)).intValue());
        LocalDateTime dateTime = LocalDateTime.ofEpochSecond(timeStamp, 0, ZoneOffset.UTC);
        dateTime = LocalDateTime.ofInstant(dateTime.toInstant(ZoneOffset.UTC), ZoneId.of("Europe/Amsterdam"));
        log.debug("Timestamp: {}", dateTime);

        int voltage = Integer.parseInt(data.substring(8, 10), 16);
        log.debug("Voltage: {}", 3.0 + voltage / 100.0);

        int temperature = Integer.parseInt(data.substring(10, 12), 16);
        log.debug("Temperature: {}", temperature);

        showCoord("lat", data.substring(12, 20));
        showCoord("lon", data.substring(20, 28));
    }

    private static void showCoord(String type, String coordString) {
        Integer coord = Integer.reverseBytes(new Long(Long.parseLong(coordString, 16)).intValue());
        int coordDegrees = coord / 10000000;
        int coordMinutes = new Double((coord / 10000000.0 - coordDegrees) * 60).intValue();
        BigDecimal coordSeconds = new BigDecimal(((coord / 10000000.0 - coordDegrees) * 60 - coordMinutes) * 60).setScale(3, RoundingMode.HALF_UP);
        log.debug("{}: {}, {}° {}' {}"", type, coord / 10000000.0, coordDegrees, coordMinutes, coordSeconds);
    }
}

Mosquitto MQTT broker

As soon as this al works it might be time to connect through 'mosquitto'.

Links