Skip to content

Latest commit

 

History

History
71 lines (47 loc) · 3.83 KB

README.md

File metadata and controls

71 lines (47 loc) · 3.83 KB

Intro

This is a simple sketch demonstrating the capability of the TTGO T-Beam as a TTN Mapper Node on The Things Network LoraWAN.

Derived from sbiermann/Lora-TTNMapper-ESP32 and with some information/inspiration from cyberman54/ESP32-Paxcounter and Edzelf/LoRa.

Modified and enhanced by dermatthias with sleep and OTAA features for this fork. Additional sleepytimes for the GPS module enabling lower-power-ish operations by stk, based on work by JoepSchyns/Low_power_TTGO_T-Beam and helpful ublox documentation in the UKHAS Wiki. This also measures and transmits battery voltage.

Software dependencies

Arduino IDE ESP32 extension

TinyGPS++

MCCI LMIC Arduino This is a hell to configure. You need to edit ~/Arduino/libraries/MCCI_LoRaWAN_LMIC_library/project_config/lmic_project_config.h and define the “right” band, e.g. CFG_eu868 (and comment out non-matching others)

Bolderflight MPU9250 library if you want to wake the device through the MPU9250 IMU

Instructions

If you have an older hardware version: You need to connect the T-Beam DIO1 pin marked Lora1 to the pin 33 - So that the ESP32 can read that output from the Lora module. Optionally you can also connect the Lora2 output to GPIO 32, but this is not needed here.

You can program the T-Beam using the Arduino ESP32 board 'Heltec_WIFI_LoRa_32'.

On The Things Network side, the settings needed are available here.

Configure the Payload decoder with:

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

    decoded.latitude = ((bytes[0]<<16)>>>0) + ((bytes[1]<<8)>>>0) + bytes[2];
    decoded.latitude = (decoded.latitude / 16777215.0 * 180) - 90;
  
    decoded.longitude = ((bytes[3]<<16)>>>0) + ((bytes[4]<<8)>>>0) + bytes[5];
    decoded.longitude = (decoded.longitude / 16777215.0 * 360) - 180;
  
    var altValue = ((bytes[6]<<8)>>>0) + bytes[7];
    var sign = bytes[6] & (1 << 7);
    if(sign)
    {
        decoded.altitude = 0xFFFF0000 | altValue;
    }
    else
    {
        decoded.altitude = altValue;
    }
  
    decoded.hdop = bytes[8] / 10.0;

    decoded.vbat = ((bytes[9]<<8) + bytes[10]) / 100;

    return decoded;
}

Let me know if more detailed instructions are needed.

Todolist

  • Stop sending data to TTN until the GPS get a fix. <== Done thanks to @Roeland54
  • Manage and document the different T-Beam revisions/versions.
  • Switch to OTAA auth method for TTN and save the 'credentials' for reboot use.
  • Save and reload the frame counter somewhere - GPS RTC data ? SPIFFS ? EEPROM ? - so I can check the "Frame Counter Checks" box as recommended on TTN.
  • Also save the GPS 'status' so that on next boot it gets a fix faster.
  • Reduce the power needed ! That thing is a power hog currently, we need to make it sleep most of the time as possible.
  • Adapt the data send frequency based on current velocity : When not moving, an update per hour should be enough. ← prototype with cheap (1€) IMU board; in this case MPU 9250

Let me know if you think anything else would make sense for a TTN mapper node : Open an issue, I will consider it.