Elektronik | Funk | Software

Der Technik-Blog

  • Social Media



    New Posts


    • Keine zukünftigen Events vorhanden

    The Tech-Blog

    Dragino LHT65 with TTN V3 setup

    Register LHT65 in TTN V3 (OTTA)

    Alex @ AEQ-WEB

    The LHT65 is a LoRaWAN temperature measurement station that consists of two internal sensors (temperature & humidity) and one external temperature sensor. The external sensor is the well-known DS18B20. The energy management of this node is very good, as it can be operated with a battery for many years and is therefore almost maintenance-free. This article is about the configuration of the LHT65 with the LoRaWAN-Network TTN V3 (The Things Stack) with OTTA. For OTTA, an 8-channel LoRaWAN gateway such as the MikroTIK LR8 (German Article) is recommended. If you operate with a single channel gateway such as a Dragino LG01 or LG02, you can only operate with OTTA in a special configuration. Therefore, it is better to use ABP for this configuration. An instruction for the configuration of the ABP operation can be found in the following article: Connecting LHT65 with TTN V3 (ABP).

    The LHT65

    The sensor has a built-in battery that should hold 8 to 10 years according to the manufacturer. Inside is a circuit board with an STM32 microcontroller, which is extremely energy efficient, and the well-known SX1276 LoRa chip from Semtech. On the rear is a 4-pin connector that can be used to update the firmware. In addition, a serial connection to the LHT65 can be established via this interface, which is used to configure the sensor. On the front is a multi-color status LED, a QR code and the type identification. On the underside there is a button and a jack connector for the external sensor (DS18B20).

    Register the sensor at TTN

    In the package there is a sticker with many keys, which are needed for the registration in the LoRaWAN network. Of course and if necessary, all keys can be changed in the device. In general this is not necessary with OTTA, because each node is delivered with unique keys. Each node can only be registered once with the manufacturer keys at TTN. The following keys are required for OTTA registration:

  • App EUI
  • Dev EUI
  • App KEY
  • Werbung:

    1. Create an application

    Before the registration of the actual sensor, an application must be created. The application includes all sensors, interfaces and the central decoder (payload formatter in V3). If additional sensors of the same type are commissioned later, they can be integrated into the existing application. The application ID and optionally a name and description can be freely selected.

    2. Create a device

    The sensor can be added either via the repository or manually. For this example, the manual option was selected, since this option can also be used to add sensors that do not exist in the repository. The following settings are selected in Europe for LHT65:

  • Frequency plan: Europe (SF9 for RX2)
  • LoRaWAN version: MAC V1.0.3

  • The keys included in the delivery are then entered:

    After clicking on "Register end device", the device will be created and displayed. The device can be activated in the next step.


    3. Switching on & activating

    There is a button on the bottom of the LHT65 that is pressed for about three seconds to activate it. The green LED lights up continuously during this time. The JOIN request is sent and the sensor waits for the assignment of the keys from the network server. If the JOIN request was successful, the blue LED lights up briefly. Afterwards the first measured values are already sent to TTN. The following screenshot shows the hexadecimal payload:

    4. Payload formatter (Decoder)

    The Uplink Payload Formatter (formerly Decoder) converts the payload encoded by the device back into the individual measured values. It is a JavaScript that uses bit-shifting to break down the hexadecimal payload array back into its individual components. More information and examples about the LoRaWAN payload can be found in this article (German only). The following screenshot shows a part of the payload formatter:

    The following payload formatter (decoder) is inserted as Javascript:

    //Payload decoder for LHT65 with external DS18B20
    function Decoder(bytes, port) {
      var batt_v = ((bytes[0]<<8 | bytes[1]) & 0x3FFF)/1000;
      var temp_int = ((bytes[2]<<24>>16 | bytes[3])/100).toFixed(2);
      var temp_ext = ((bytes[7]<<24>>16 | bytes[8])/100).toFixed(2);
      var hum_int = ((bytes[4]<<8 | bytes[5])/10).toFixed(1);
      var ext_sen = 
             "0":"No external sensor",
             "1":"Temperature Sensor",
        return {
          Ext_sensor: ext_sen,
          BatV: batt_v,
          TempC_SHT: temp_int,
          Hum_SHT: hum_int,
          TempC_DS: temp_ext,

    5. Display decoded payload

    Under the "Live data" tab, the decoded sensor data should now be displayed in addition to the payload:


    If you click on the line, a window opens where all data is displayed in JSON format. Here you can find, among other things, the signal strengths and IDs of the gateways that have received this data. Exactly in the same format the data is passed on to the HTTP integration (webhook).

    6. Setting up an interface

    The LoRaWAN network primarily only takes care of the transmission of the data packets. The user is responsible for the evaluation and storage of the data. TTN offers here many interfaces to different services, where the data can be forwarded after reception. Popular are MQTT connections or HTTP requests. The next article is about setting up a small PHP application that receives the data via HTTP mail from TTN, stores it in a database and displays it on a web page.

    Info: This page was automatically translated and may contain errors

    About the Author

    Alex, the founder of AEQ-WEB. He works for more of 10 years with different computers, microcontroller and semiconductors. In addition to hardware projects, he also develops websites, apps and software for computers.

    Top articles in this category:


    LoRaWAN TTGO GPS Tracker

    • Video
    • DE/EN

    The second part of the LoRa GPS Tracker project is about the setup of LoRa and the registration at TTS (The Things Stack), the successor of TTN

    read more
    LoRaWAN ABP Frame Counter Problem

    The LoRaWAN Frame Counter Problem (ABP)

    • Video
    • DE/EN

    The Frame Counter (ABP) is an important security feature in the LoRaWAN network. This article is about the permanent storage of the current counter.

    read more

    Social Media



    New Posts


    • Keine zukünftigen Events vorhanden