物联网教程:BeagleBone Green连结微软Azure平台

  

 

  

 

  

 

  

 

  

 

  

 

  

 

  

 

  

 

  

 

  In this recipe I would like to introduce how to connect to Microsoft Azure from BeagleBone Black/Green. I use Node.js for implementation. For testing, we use ConnectTheDots.io library, http://connectthedots.io , to connect Microsoft Azure.

  Step 1: Preparation

  Firstly, setup your BeagleBone Black/Green with Debian Linux. Then, connect the board to Internet network.

  

 

  Step 2: Installing Required Libraries

  You need install several required libraries to communicate with Microsoft Azure. Write package.json file and write this script:

  Save it. Now you can install it using npm on your BeagleBone Black/Green Terminal. Open Terminal and navigate to where package.json path is. Then, type this command.

  Make sure BeagleBone Black/Green is connected to Internet network.

  

 

  Now you're ready to build a program.

  Step 3: Writing A Program

  The first step to write a program is to configure the data which is sent to Microsoft Azure. We should configure our data format based on ConnectTheDots.io . Write this script.

  Save this script into a file, called setting.json. You may change GUID value using your own tool. Change displayneme, organization and location with your own words.

  Now we can write a program to send sensor data such as Temperature, Humidity, Light intensity. The program will send data to Microsoft Azure every second.

  Write this script:

  Save the program into a file, called bbb_azure.js

  The program will generate random values for light intensity, temperature and humidity. Then, the program sends data to Microsoft Azure. You can change sensor data by sensing from sensor devices directly.

  The program needs connectthedots.js. Basically, you can download it onhttps://github.com/Azure/connectthedots . The following is a script from connectthedots.js file .

  Step 4: Testing

  Now you can test the program. Using BeagleBone Black/Green Terminal, you can type this command to run the program.

  If running succeed, you should see the program send data to Microsoft Azure. The following is my program output

  

 

  Now you can open a browser from your desktop and navigate tohttp://connectthedotsdx.azurewebsites.net . You should see your sensor data on this dashboard.

  The following is sample output forms from my program.