Sending sensor readings to airvantage :
For this i connected airvantage to the beaglebone black and after its connected go to http://192.168.7.2:3000/
This is the cloud9 workspace.
Now in the cloud9 workspace go to terminal and in the default cloud9 location run the following :
npm install mqtt
This installs the necessary mqtt module for nodejs in cloud9 directory.
Next I created a sample file using the following code to send data to airvantage :
var mqtt = require('mqtt'); var port = 1883; var server = "na.airvantage.net"; var serialnumber = "3713BBBK7777"; //serialnumber of your beaglebone var password = "1234"; //password used in credentials var mqtt_options = {username: serialnumber, password: password}; var client = mqtt.createClient(port, server, mqtt_options); console.log("Client started"); //Send values console.log("Sending value"); //Publish a message on the right topic var room_1= {}; var timestamp = new Date().getTime(); room_1[timestamp] = { "room1.temperature": 42.2, "room1.threshold": 30, "room1.humidity": 42.2, "room1.dust": 42.2, "room1.co": 42.2, "room1.co2": 42.2,}; client.publish(serialnumber + '/messages/json', JSON.stringify(room_1)); console.log(room_1);
Save this file and run the file in cloud9 workspace.
Thats it . Next go to your airvantage account and go inventory > systems > your device > timeline tosee if the readings are being uploaded. On the timeline you can see all the readings that are uploaded.