Connect Raspberry Pi to QNAP NAS via QIoT Suite Lite

Get started with Rasberry Pi (Node.js)

In this section, you will learn the basics of working with Raspberry Pi (that runs the Debian-based Raspbian). You will then learn how to connect your devices to QNAP NAS using QIoT Suite Lite.

Please ensure your Raspberry Pi and NAS are on the same LAN.

1.Connect Raspberry Pi to QNAP NAS

Please configure your Raspberry Pi device with an operating system, set up your development environment, and deploy an application to Raspberry Pi.

1.1 What you will need

  1. Raspberry Pi
  2. SD card (an 8GB class 4 SD card is recommended) withNOOBSinstalled.
  3. HDMI display.
  4. USB keyboard and mouse.
  5. Power Supply: The Pi requires a USB micro power supply with at least 2A at 5V for the Model 3B, or 700mA at 5V for earlier models.

1.2 Set up Raspbian

  • Insert the SD card containing extracted NOOBS files into the Raspberry Pi

  • Connect the keyboard, mouse, and HDMI display to the Raspberry Pi. Plug in the power adapter. The Raspberry Pi does not have a power switch, and will automatically power on once the adapter is connected.

  • A menu will ask what OS to install and what language and keyboard layout to use. Check the box next to Raspbian and click "Install".

  • The installation process may take up to 20 minutes, and will restart to the Raspbian desktop when complete.

  • Configure Wi-Fi – In the Desktop environment locate the Wireless Network icon in the top-right menu and click the icon to view a list of available Wi-Fi networks.

  • To connect to your Raspberry Pi from another device, you must know the Pi’s IP address. Using the terminal (Ctrl + Alt + t to open Terminal), enter hostname -I.

1.3 Install Nodejs and required libraries

  • Install node.js v6

2. Create your device in QIoT Suite Lite

2.1 Install QIoT Suite Lite

  • QIoT Suite Lite can be installed from the App Center.

  • Launch and log in to QIoT Suite Lite. The default username and password is "admin".

2.2 Create a new IoT application

IoT Applications are a combination of Things, Rules, and Dashboards. We recommend that you first create a "Things" in IoT Application. This IoT Application allows you to keep a record of all of the devices that are connected to your NAS.

Rules make it possible to build IoT applications that gather, process, analyze and act on data generated by connected devices. Rules can apply to data from one or many devices, and it can take one or many actions in parallel.

All these elements provide user a complete IoT Application environment.

If this is your first time using QIoT Suite Lite, click"Quick Setup Wizard"to start the quick setup wizard.

After reading the introduction, click "Next".

  • Create a New IoT application

  • Enter the IoT Application name (for example:"app_1").

  • The Rule name and Dashboard name will be automatically generated based on the IoT Application Name.

  • Click "Next".

  • Click "+ Add" to add this application’s device.

  • After click"+ Add", In “Add Thing”:

  • Enter a name for your device (e.g., raspberrypi) and provide the device information (such as serial number and manufacturer) in Add attribute.

  • If your device is already supported by QIoT (Arduino Yun,Raspberry Pi, Edison, and Linkit 7688 (Duo)), choose a pre-defined Thing Type.

  • Click Add to add the device.



Enter the IP address, User Name, and Password of your device and click the Connect icon. QIoT Suite Lite will check the connection with the device. After the connection is verified, click Next.

  • In "Resources", click "Add Resource".

  • In "Add Thing Resource" :

Enter the name and ID for the sensor in Resource Name and Resource ID. Please note that the Resource ID will be used to create a Topic in the QIoT Broker. This ID should be unique for the device and no duplicates should be allowed for the same device.

  • In "API Keys" :

If you want to embed QIoT dashboard widgets into web pages or access QIoT APIs from third-party applications, go to the API Keys tab and click"Generate New API Key". Click"Done".

  • Your IoT application will now be created. Node.js sample codes and related files (certificate, resource information) will be uploaded to the specified path on your device.

  • A sample dashboard will be created.

  • Go to the Rule tab to define the flow or rules on how to process the data sent from the device, and how to present in a dashboard.

3. Connect your device to QIoT Suite Lite using MQTTS

3.1 Run Sample Code

  • Open Terminal application (such as: PuTTY) on your PC. Connect to your device using SSH and enter the folder where the smaple code is stored (for example: /home/root/bundle).

    

  • To install sample code dependencies, enter the following commands:

  • Run the sample code

  • The device will send a message to topic "temp" (or the topic you defined).

3.2 Another protocol

  • Click "Connect a Device"

  • You can select another protocol.

    

  • Connect to your device using SSH, and enter the following commands:

4.Integrate Power BI

4.1 Get your first Power BI account

  • Sign up for a free PowerBI account athttps://powerbi.microsoft.com/en-us/

  • After a sequence of registration, the page will lead you to below page, you can press "My workspace", and "skip for now" button appear. You could click "skip for now" to start create dataset.

4.2 Setup your streaming dataset API

  • Create"Datasets"

  • Click"Create"in the top-right corner

  • Click"Streaming dataset"

  • Select "API", the source of your data, and click "Next".

  • Define your values from stream (e.g., temp, max, min), and you will get a JSON result in the textbox. We will use this JSON code to push data to the QIoT Suite Lite application. Click "Create" to finish.

  • Once you create your data stream, you get a REST API URL which IoT applications can call using POST requests to push your live data to the streaming data dataset you created.

4.3 Configure NodeRED’s nodes in IoT application

  • Create IoT application in QIoT suite.
  • The following is your first Node-RED flow, and then you can start creating your own IoT flow. You can learn more about Node-RED at https://nodered.org/

  • Before you start pushing live data to Power BI. We need a "function" node to convert IoT data to a streaming data dataset. Here you can replace msg.payload to your JSON dataset.

  • Function code as following:

  • We need an "http request" node to help us to push live data to Power BI. Just drop and drag "http request" node and connect to tail of "function" node.

  • Copy and paste the REST API URL that you got from the Power BI console, and set http method to POST. Click"Deploy"to save changes

  • Your Node-RED flow will look like below.

4.4 Add tile to display real-time data

  • Create"Dashboard"

  • Click "Create" in screen upper right corner

  • And then click "Dashboard"

  • Enter dashboard’s name, and click "Create" to complete create dashboard.

  • Click "Add tile" in screen upper right corner.

  • Select "CUSTOM STREAMING DATA" and click "Next".

  • Select datasets and click "Next".

  • Select visualization type (e.g., gauge), and set value, min, and max value.

  • You will have a streaming dataset to work with, and you can get a real time gauge that looks as following.

results matching ""

    No results matching ""