attnode/Firmware
2020-01-26 17:14:12 +01:00
..
.vscode Adjust gitignore for VS Code 2020-01-12 14:36:33 +01:00
lib different ports for spreading factors 2020-01-22 22:25:07 +01:00
src [Firmware] Adapt Decoder for Optimized Payload Format 2020-01-26 17:14:12 +01:00
.gitignore Adjust gitignore for VS Code 2020-01-12 14:36:33 +01:00
platformio.ini [Firmware] Added Beacon Mode 2019-11-20 19:50:50 +01:00
README.md [Firmware] Adapt Decoder for Optimized Payload Format 2020-01-26 17:14:12 +01:00

TinyLoRa Firmware

Example Sensor Node Firmware with a BMP/E280 or SHT21 Sensor. Used Sensor has to be set via #define in the src/secconfig.h (HAS_BME280 or HAS_SHT21). Please change the values in src/secconfig.h to your Keys from https://console.thethingsnetwork.org. Device has to be set to ABP Mode. Also since there is no permanent storage to store the Frame Counter, please disable the Frame Counter Check in the TTN console.

The code also supports the RFM69W wireless module instead of the RFM95W LoRa module. For this purpose you need a receiver. Example code for a receiver in python (tested on a Raspberry Pi, RFM69 connected via SPI) can be found at https://www.seiichiro0185.org/git/IOT/sensord

Project was created using PlatformIO Atmel-AVR Framework

Decoder for the TTN Application

function Decoder(bytes, port) {
  var decoded = {};

  // We always have Battery Voltage
  decoded.v = (bytes[0] * 20) / 1000.0;

  // Temperature (int32_t)
  if (bytes.length >= 5)
    decoded.t = (bytes[1]) | (bytes[2] << 8 ) | (bytes[3] << 16 ) | (bytes[4] << 24) / 100.0;
  
  // Humidity (int32_t)
  if (bytes.length >= 9)
    decoded.t = (bytes[5]) | (bytes[6] << 8 ) | (bytes[7] << 16 ) | (bytes[8] << 24) / 100.0;

  // Atmospheric Pressure (int32t)
  if (bytes.length >= 13)
    decoded.t = (bytes[9]) | (bytes[10] << 8 ) | (bytes[11] << 16 ) | (bytes[12] << 24) / 100.0;

  return decoded;
}