Introduction: Node.js Client for

This tutorial walk you through creating an internet of things application using Node.js running from a PC as an emulator. Any device that can run node.js can easily push data to

In order to show how node.js works with, we need to implement the example shown in the blog diagram above. In this example, we have a gateway connected to two sensors: sensor0 and sensor1. the first sensor measures battery, distance and current. The second sensor measures pressure and voltage. We need to collect the data from the sensors and send it over the internet and visualize from anywhere in the world.

At the end of the tutorial, you will learn:

1- Add a device to

2- Add sensors

3- Create an application to visualize data in real-time

4- Add a user who can view the visualized data

5- Add alerts to receive emails when a condition is met in the field

Step 1: Install Node.js on Your PC

Go to

Install node.js

Step 2: Create an Account

go to

Follow the steps to register for an account

Step 3: Add Gateway in Device Manager

1. login to your account created in previous step

2. From Admin console, click Device Manager

3. From Device Manager, click Add Gateway

4. From the list of gateways, select Embedded. This is a generic method that allows any device to push data to

5. Enter the following:

MAC Address: this is a unique id that identify your device. e.g. 54445666

Name: this is the name of your device. it could be anything e.g.. my device

Group (optional):

6. fill out the macaddr and the name then click sumbit. you should get an acknowledgment with a green check mark. click ok to close popup menu.

Step 4: Add Sensors to Your Gateway

As shown in the block diagram above, we have two sensors: sensor0 and sensor1. We need to tell the application which sensors are connected to the gateway. To do that:

1. Click the checkbox next to the gateway name

2. Click ToolBox, the click Sensors. This will launch Sensors Manager

3. From Sensors Manager, Click Add Sensor, then click Library

4. From select Sensor dropdown menu, select SensorA

5. Click blue + to the right of the dropdown menu

6. From select Sensor dropdown menu, select SensorB

7. Click blue + to the right of the dropdown menu

8. Give the name: sensor0 and serial number 1 to the first sensor and the name sensor1 and serial number 2 to the second sensor

9. Click Add sensors, you should get an green checkmark. click Ok. Sensors Manager should populate the two sensors you have added

10. Click Back to return to Device Manager

Step 5: Push Data to Using Node.js

Now we are ready to push data to To do that:

1. From Device Manager, click checkbox next to the name of your device.

2. Click Edit Gateway and take note of the secure key

3. Open your favorite code editor and paste the following code from this site:

make sure to update the code with your id and macaddr

4. save the file as s2c_example.js

5. Launch Node.js console, navigate to the directory where you saved the file

6. Type the following node s2c_example.js

7. click return you should get an acknowledgment as shown in the image above. congratulations! you have successfully push data to

Now let's visualize our data

Step 6: Create an Application for Data Visualization

from Admin console, click Application Manager

1. click Add

2. Fill the information as shown in picture above. Make sure to select Nodejs Template. click Ok to close popup menu

3. click Run. a new window should open showing a number of widgets of the various channels

4. From Nodejs console, type the following: node s2c_example.js

5. you should see the values in the widgets change in real-time

You have now successfully visualized your data from a web browser.

Step 7: Add a User Account

now that we can visualize the data, we want to allow other people to view it. So we create user accounts.

From Admin console, click user manager

1. Fill out the name, and choose a username for the user (usually his email address)

2. Set a password for your user

3. From Select Application drop-down menu, select the application name. (this allow you to select who view which application)

4. Click submit. your user should be able to login to using the username and password that you created for them

Step 8: Add Alerts

We want to add an alert and we want to recieve an email if the battery level drops below a certain value

1. From Admin console, click Alert Manager

2. Click 'Add' and fill out the information as shown in the picture above. make sure to put your email address.

3. From your text editor, change the value of the battery and make it smaller than 15.

4. From Nodejs console, run the s2c_example.js

5. After couple of minutes, you should get this email in your inbox:

My Company name

Error: Low battery

Device: 00000000121

Sensor: 0

Channel: battery

value: 10

condition: <

threshold: 15


You have successfully received an email alert

Step 9: Next Steps

In the next tutorials, we will cover the following:

- how to customize applications

- how to create multiple devices into one application

- how to configure the different widgets

for any support questions, please email me at: