23.05.2022: Tiefpassfilter


Elektronik | Funk | Software

Der Technik-Blog

  • Social Media



    New Posts


    The Tech-Blog

    Dragino LHT65 with TTN V3 setup

    Register LHT65 in TTN V3 (ABP)

    Alex @ AEQ-WEB

    The LHT65 should be connected to a LoRaWAN network via OTTA if possible. All information about the registration of a LHT65 with OTTA can be found in this article (German only). If the sensor should be used in different LoRaWAN networks at the same time or if OTTA is technically not possible, the LHT65 can also be switched to ABP. This article is about the switch from OTTA to ABP, as well as the registration with TTN V3 (The Things Stack). The configuration described in this article also works with a single channel gateway such as the Dragino LG01/LG02 (German only).

    Note: The sensor is preconfigured for OTTA at the factory. To switch the sensor to ABP operation, a USB-TTL-Adapter is required.

    1. Connect the Sensor

    The sensor can be configured via the serial interface. A corresponding cable from the sensor to the jumper-wire connection is included in the shipment. To establish a connection with the computer, a TTL adapter (USB -> RS232) is required. In addition, the firmware can be updated via this cable (ST-Link Programmer required). Alternatively, the Arduino can be used as a serial bridge. The following graphic shows the pinout between sensor and RS232 adapter:

    2. Terminal Software & Keys

    The sensor can be read out and configured via any terminal software. The keys for ABP can either be taken from the enclosed sticker or read out via the terminal. The second option is much more comfortable, because you can copy the keys from the terminal.

    Putty is a popular simple terminal client for Windows/Linux, which supports SSH and serial connections. The following settings must be selected for a successful connection:

  • COM-Port: unterschiedlich (siehe Windows Geräte Manager)
  • Speed: 9600
  • Connection Type: Serial

  • The following screenshot shows an example configuration:


    After opening the connection, type the command "AT" and press Enter to send. Now the following text should appear in the terminal: "Incorrect password".

    Then type in the following password:


    With the return key the password is sent and in case of success "OK" will be returned. The following command displays the configuration and the keys required for LoRaWAN:


    3. Register the LHT65 with TTN

    The LHT65 is registered in the application under "End Devices". Basically there is a template for the LHT65, but you can also configure the sensor manually. The following parameters must be selected:

  • Frequency plan: Europe 863-870 MHz (SF9 for RX2 - recommended)
  • LoRaWAN version: MAC 1.0.3

  • Then the tab "Show advanced activation" must be opened and there select ABP as activation method. In the following fields, the keys required for ABP operation can be copied from the terminal.

    Click on "Register end Device" to register the device. TTN is now ready to receive.


    4. Change LHT65 to ABP

    The following commands can be inserted directly by a right click in the terminal and sent with the Enter key. Each command must be confirmed with OK:

    4.1 Change to ABP:


    4.2 Disable Adaptive Data Rate:


    4.3 Set the data rate (5 = EU band):


    4.4 Set the transmission interval (600 000 millis = 10 min):


    4.5 Set the transmission frequency to 868.1 MHz:


    4.6 Restart controller:


    5. Device activation

    Generally, the LHT65 sends out a data packet immediately after the reset command. The hexadecimal payload should therefore already be visible in the console. The sensor should not be switched off after successful activation. For more information, see point 7.

    6. 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 decomposes the hexadecimal payload array back into its individual components using bit shifting. More information and examples about the LoRaWAN payload can be found in this article. The following screenshot shows a part of the payload formatter:

    The following payload formatter 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,

    As soon as the next data packet arrives, the individual measured values are already decoded and displayed in plain text:


    7. The Frame Counter Problem

    The frame counter is a security feature of LoRaWAN and prevents replay attacks. Both the end device and the LoRaWAN server run a counter that is incremented by 1 with each data packet. If the LHT65 is switched off, the frame counter starts again at 0 and is thus smaller than the counter value from the application. All data packets are rejected in this case and no error message will be displayed. However, it is possible to delete the frame counter manually. For the affected device, the option Resets Frame Counters can be activated under General Settings -> Network Layer -> Advanced MAC settings. Further information can be found in this article.

    8. Setup 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:

    ESP32 LoRa Board LoRaWAN TTN ABP Connect

    LoRaWAN & TTN with ESP32

    • Video
    • DE/EN

    The ESP32 LoRa board from Heltec supports LoRa. This article is about access and data transfer to LoRaWAN & TTN

    read more

    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

    Social Media



    New Posts