Sodaq LoRa One
Install the IDE under Linux
- Download the Arduino IDE (ArduinoIDE)
- Make sure the kernel support ACM USB devices (CONFIG_USB_ACM=y)
- Add board support to the IDE: File > Preferences > 'Additional Boards Manager URLs’. Enter 'http://downloads.sodaq.net/package_sodaq_samd_index.json'
- Click on Tools > Board > Boards Manager… and install the "SODAQ SAMD Boards"
- Select the "SODAQ ONE"
- Now compile the code (SodaqOne-UniversalTracker-v3) and upload it to the board... Or just use the version that is already installed...
Setup of antenna, GPS and pins
Register the board with The Things Network
- See Quick Start Guide for ttnctl
- ttnctl user create [Your Email]
- ttnctl user login [Your Email]
- ttnctl applications create [Application Name]
- ttnctl applications use [EUI]
- ttnctl devices register personalized [DevEUI]
- ttnctl subscribe
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'.
- ttnctl applications
- mosquitto_sub -h staging.thethingsnetwork.org -t '+/devices/+/up' -u <EUI> -P 'Access Key'
Links
- https://staging.thethingsnetwork.org/
- https://www.thethingsnetwork.org/wiki/Backend/Connect/Application
- https://thethingsnetwork.slack.com/messages/general/
- https://www.thethingsnetwork.org/wiki/Backend/ttnctl/QuickStart
- http://ttnmapper.org/
- http://ha-23.eradus.eu/croft.html
- https://www.thethingsnetwork.org/map