LoRa/LoRaWAN tutorial 27: Retrieve and Store Sensor Data From The Things Network

Ғылым және технология

If you like this video and want to support me, go this page for my donation Paypal or crypto addresses:
/ mobilefish
This is part 27 of the LoRa/LoRaWAN tutorial.
In this video series different topics will be explained which will help you to understand LoRa/LoRaWAN.
It is recommended to watch each video sequentially as I may refer to certain LoRa/LoRaWAN topics explained earlier.
In this tutorial I will demonstrate:
- how to retrieve sensor data from The Things Network,
- how to store it in a database,
- how to retrieve this data from the database and display it in a browser,
- and how to create a downlink, using a NodeJS script, sending data from my computer to my LoRa end node.
All code used in this tutorial can be found in the following Github repository:
github.com/robertlie/ttn_app_...
The Things Network community developers created several Software Development Kits (SDK) to receive activations and messages from IoT devices via The Things Network to your server.
It also allows you to send messages back to the IoT devices from your server.
The SDK’s are available in Go, Java, Python and Node.JS
Go: github.com/TheThingsNetwork/g...
Java: github.com/TheThingsNetwork/j...
Python: github.com/TheThingsNetwork/p...
Node.JS: github.com/TheThingsNetwork/n...
In this tutorial I will use the Node.JS SDK.
This tutorial assumes you have installed the following software packages and know how these packages works.
Node.JS (JavaScript server environment) and npm (node package manager)
nodejs.org/en/download/packag...
MySQL (Relational Database Management System)In this tutorial MySQL Community Server is used.
www.mysql.com/downloads/
phpMyAdmin (Web based administration tool for MySQL)
www.phpmyadmin.net/
Goto The Things Network console.
Goto the applications page and select the application which receives the sensor data.
In this demo the application ID is "youtube_demo_app2".
To retrieve sensor data from The Things Network to your server, you need:
The application ID
Example: youtube_demo_app2
Access key
Example: ttn-account-v2.uicwOOArAqESHCfa8LGdftBSM6IZWjCdv4Art14iKtc
Download the Git repository:
github.com/robertlie/ttn_app_...
Goto folder ttn_app_server
Install the node modules, type: npm install
Modify file config.js
Modify file read_table.php
Run the script retrieve.js, type: node retrieve.js
This script only retrieves sensor data from TTN and displays it in the terminal.
It is possible to create a downlink by sending data to the end node using script send.js.
Modify file send.js:
client.send("youtube_demo_device", Buffer.alloc(1, 0x00, ‘binary'));
Depending on the hex value send, the yellow and green leds can be On or Off.
Run the script, type: node send.js
The retrieved sensor data from TTN can be stored in a MySQL database.
A database and corresponding table needs to be created.
First create the database ttn_demo_db, type: node create_db.js
Next create the table sensor_data, type: node create_table.js
Use the web application phpMyAdmin, to check if the database and table are created.
localhost/~username/phpmyadmin/index.php
The column "payload_raw" has data type tinyblob to store binary data.
The payload_fields data is not stored because the payload_raw data can be used to recreate the payload_fields data.
The Arduino sketch transmits the humidity and temperature data as four bytes.
If the button switch is pressed a single byte is transmitted.
To retrieve sensor data from TTN and store it in a MySQL database, type: node store_records.js
Use the web application phpMyAdmin, to check if sensor data are stored.
The sensor data is stored in the table sensor_data.
To display all records from table sensor_data in a terminal, type: node read_table.js
The sensor data is stored in the table sensor_data.
To display all records from table sensor_data in a browser:
First deploy file read_table.php in a web server (for example Apache supporting PHP and MySQL).
Open a browser and open the PHP file.
To completely delete the database ttn_demo_db, type: node drop_db.js
BE CAREFUL, ONCE DELETED ALL DATA IS LOST.
Check out all my other LoRa/LoRaWAN tutorial videos:
• LoRa/LoRaWAN tutorials
Subscribe to my KZread channel:
/ @mobilefish
The presentation used in this video tutorial can be found at:
www.mobilefish.com/developer/...
#mobilefish #lora #lorawan

Пікірлер: 23

  • @trendyprimawijaya314
    @trendyprimawijaya3145 жыл бұрын

    Thank you so much. It is helpful. It help me so much.

  • @l2_2022
    @l2_20222 жыл бұрын

    Very good work!

  • @simonndungu1196
    @simonndungu11965 жыл бұрын

    all at another level

  • @joyouslatter103
    @joyouslatter1039 ай бұрын

    Great stuff

  • @henrisors9049
    @henrisors90492 жыл бұрын

    Robert, thanks a lot for your tutorials. They are really high quality. I am impressed ! Quick question regarding this video: I am interested only by the "send downlink" portion of your tutorial. Do you believe the same code would work with TTNV3 ?. Thanks.

  • @tumelotux5539
    @tumelotux55395 жыл бұрын

    Is it possible to directly retrieve data from things network using web sockets and visual studio? I need to utilise my sensor data in visual studio.

  • @mos2161
    @mos21615 жыл бұрын

    Hallo , Sometimes when i send data ( downlink) the data doesn't achieve the nodes from first time , so i need to send data many times then nodes get the data . can u tell me please what the factors which have effect on downlink . I use same ur hardwares and same library and i'm from same Holland :). thanks in advace

  • @vinodselvaraj007
    @vinodselvaraj0075 жыл бұрын

    What kind of sensor can be used with lora and lorawan

  • @cute_pet_videos
    @cute_pet_videos4 жыл бұрын

    Hi. Thanks for this valuable tutotial content. Is there a way to know the amount data sent out and compliance to fair usage policy by measuring the usage instead of calculating it ?

  • @Mobilefish

    @Mobilefish

    4 жыл бұрын

    I have not tried this myself, but have you tried using wireshark?

  • @danymerhej9488
    @danymerhej94883 жыл бұрын

    Dear Robert, thank you for this tutorial. I managed to get it working without any problem on TTN V2. What are the modifications in order to use it with TTN V3?

  • @Mobilefish

    @Mobilefish

    3 жыл бұрын

    As we speak, I am working on new tutorials which answers your question. However making KZread videos takes a lot of time and I am also working on other side projects. In the mean time I have written a tutorial www.mobilefish.com/developer/lorawan/lorawan_quickguide_build_lora_node_rfm95_arduino_pro_mini_v3.html which will answer some of your questions. But soon I will upload new LoRa/LoRaWAN videos.

  • @alawrence8228
    @alawrence82282 жыл бұрын

    Where can anyone find the access_key? It has dissapeared from the dashboard

  • @Dr.Sarkar
    @Dr.Sarkar2 жыл бұрын

    is it still working on V3???

  • @aghamaretha6006
    @aghamaretha60064 жыл бұрын

    Can you help me? I got Error: Cannot find module 'ttn' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) when I'm trying to run node retrieve.js Thankyou

  • @dwptsr

    @dwptsr

    4 жыл бұрын

    i got the same problem, could anyone solve this?:(

  • @tutorlee4081

    @tutorlee4081

    4 жыл бұрын

    @@dwptsr run npm install --save ttn

  • @Ohayou703
    @Ohayou7034 жыл бұрын

    How to save data from lora node(arduino) to lora gateways(raspberry pi) on database 😭🙏

  • @marwaneb_4615
    @marwaneb_4615 Жыл бұрын

    stp pense au sous-titre chacal

Келесі