Skip to content

robertlie/ttn_app_server

Repository files navigation

Retrieve sensor data from The Things Network and store it in a database

This repository contains examples how to retrieve sensor data from The Things Network and how to store the sensor data in a database. A PHP script is included to retrieve sensor data from the database and display the data in a browser.

Requirements

The scripts in this repository uses the sensor data from LoRa/LoRaWAN tutorial 26: https://www.mobilefish.com/developer/lorawan/lorawan_quickguide_tutorial.html
or watch this YouTube video:
https://youtu.be/EMoZ9taGZRs

alt text

To make all the scripts work in this repository the following applications need to be installed:

  • MySQL
  • NodeJS
  • NPM
  • PHP (in conjunction with a web server, for example Apache)

Features

The project consists of the following files:

  • config.js: Contains the MySQL user credentials and The Things Network (TTN) appID and accessKey.
  • retrieve.js: Retrieves sensor data from The Things Network and displays it in the terminal.
  • send.js: Creates a downlink and sends binary data from your computer to your LoRa end node.
    If the binary value is 0x00 Yellow Led=Off, Green Led=Off
    If the binary value is 0x01 Yellow Led=On, Green Led=Off
    If the binary value is 0x02 Yellow Led=Off, Green Led=On
    If the binary value is 0x03 Yellow Led=On, Green Led=On
  • create_db.js: Creates the database ttn_demo_db.
  • create_table.js: Creates the table sensor_data.
    alt text
  • store_records.js: Retrieves sensor data from The Things Network and stores the sensor data in the MySQL database.
    alt text
  • drop_db.js: Deletes the database ttn_demo_db.
    BE CAREFUL WITH THIS SCRIPT, ONCE DELETED ALL DATA IS LOST.
  • read_table.js: Retrieves data from table sensor_data and displays it in the terminal.
  • read_table.php: Retrieves data from table sensor_data and displays it in the browser.
    alt text

Installation

npm install

Usage

Watch this YouTube video: https://youtu.be/c5bnhyWMrLY

About

Retrieve sensor data from The Things Network and store it in a database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors