LHT65 TTN V3 Webapp
This article is an update to the project From TTN to your own website, which was developed under TTN V2. With the new TTN Stack V3 the existing project is no longer compatible, because the JSON formatting has changed. In addition, with TTN V3 the layout of the console has changed a lot compared to Stack V2. For this reason, a new, completely updated article has been written.
Why a webapp?
Basically, a LoRaWAN network only takes care of the data transfer, but not the storage of this data. The user has to take care of storing the data himself and tell the LoRaWAN network an interface to which the data can be sent. For this purpose, there are many ready-made services, some of them free of charge, which store these data and display them graphically. Alternatively, you can send the data from TTN to your own web space using a webhook (formerly HTTP integration). The project presented on this page is a small PHP application that stores and displays the measurement data from the Dragino LHT65 in a small MySQL database. This is a working example project, which should be adapted to your own needs or further developed.
Everybody who owns a homepage already has a webspace. But there are also free webspace providers like bplaced.net. There are no special requirements for the webserver. Only the PHP script should have write permissions in the main directory, so that a logfile can be created. Additionally a database (ideally MySQL) is needed to store the data.
Configuration & Webapp Upload
In the ZIP-Archive there are four files in total. First open the file [config.php] with a text editor and adjust the parameters for the database server. You get the access data as well as the server address from the respective provider. The configuration could look like this:
After the login data has been modified, the file can be saved. The following files to be uploaded to the web space via an FTP-Client (for example FileZilla):config.php
Afterwards the database template (sql_template.sql) must be imported at the database server. Usually this is done via phpMyAdmin. The access data is again obtained from the respective provider.
Open the Webapp
If the PHP files have been uploaded to the web space and the database server has been configured correctly, the following error message should appear when calling the URL:
Webhooks (integrations) are HTTP/HTTPS interfaces between the LoRaWAN network or application and the Internet. To get the data from TTN to your own website, you have to set up a webhook with the URL to your webspace. In the Application under Integrations -> Webhooks -> Add Webhook a "Custom webhook" must be created. The following parameters must be specified:Webhook ID (can be chosen freely)
Webhook format: JSON
Base URL (Url to your Webserver/Webspace)
Uplink message: /ttn.php
The following screenshot shows an example configuration:
Use your webapp
After successful setup, TTN automatically forwards new measurement data from the LHT65 to the webapp. If everything has been set up correctly, the measurement data can be viewed on the website just a few seconds after transmission:
Info: This page was automatically translated and may contain errors