Today, will sharing own private cloud with Raspberry Pi and Container in IoT application.
Before starting, we will prepare some hardware and software
Hardware:Raspberry Pi 2, Container, SD card,HDMI-cable ( pi connect with monitor) and sensors of you want to do.
Software:Raspberry Pi -SDK
We will use QNAP-NAS as our container, because QNAP provides a good platform and easier to development.
Then we will introduce the establishment of pi and QIOT link, and finally how to make it together to make an example for IoT.
First, We recommend download NOOBS, which is designed to be very easy to use. After downloading the .zip
file, unzip it to get the image file (.img
) for writing to your SD card.
Once you’ve flashed the disk image using the methods above, place the SD card into your Pi, plug in the HDMI monitor, any keyboards and mice, and then the power cable. Your Pi should begin to boot and you should be able to see Raspbian on your screen.Complete the Raspbian setup, and your Pi is now ready to be used!
For easy to use, we will setting SSH to remote control pi.
We will use node-js, python, mqtt..etc SDK to connect to QNAP-NAS, so we will download SDK in pi.
The SDK :
- node-js
- grovepi
- grovepi blessed
- grovepi blessed-contrib
- grovepi mqtt
then, node-js version is 10.28,and successfully installed as Figure 1.
To this side, RPI's environment is considered a paragraph, and we will introduce QNAP-NAS the environment to bulid.
QNAP-NAS's official website provides a basic installation of the NAS, here we will explain how to install QIOT-Containers, will see this beautiful picture, shown in Figure 2.
Then install the MQTT, Node-Red in the Container, set the network relationship when installing the MQTT, change it to Host and set the port to 1883, in the Node-Red settings will Port into 1880, as shown in Figure 3.
We are now on both sides of the environment are built to complete, then put the whole series together.
Here we will demonstrate a simple example of Node-js, its function is to re-RPI surface to write a link to the NAS program, the code shown in Figure 4.
When the program is complete, then to pull the components of Node-Red, open our Container and click on Node-Red in Figure 5.
Then we pull the two components for the mqtt, debug, which must this component is just set our Port, IP location linked to the place, and Debug is easy to see if we have received the information transmitted by the RPI, when the implementation of just the After writing the example, you can see the text in the Node-Red screen Debug as shown in Figure 6, in addition, we can also link through the Container situation, to ensure that our devices are connected to the NAS, as shown in Figure 7.
To this side, describes how to link the RPI and NAS, as stated at the beginning, QNAP NAS provides SDK, platform, and interface are very friendly, very easy to operate, so you can build a private cloud and RPI in the above Do IOT applications, through the combination of fruit and NAS, IoT applications want to do more in-depth I believe that more can be handy!
留言列表