Automated Data Sending to AskSensors Using Node.js

In a previous tutorial, I showed how to send data to AskSensors IoT platform using the web browser. It was helpful especially for beginners and people don't have material in hand or don't work with electronics!

This made me thinking more about providing you different ways to communicate with AskSensors without using electronics. This instructable explains step-by-step how to conduct automated data sending to AskSensors using Node.js over HTTPS GET Requests.

Note for guys not familiar with Node.js:

We will type command-line instructions, so you need to be comfortable with or at least know how to start a command-line tool like the Windows Command Prompt, or the Git shell.

Npm makes it easy for JavaScript developers to share and reuse code, and makes it easy to update the code that you’re sharing. Later we will need npm to install an HTTPS package for HTTP secure communications with AskSensors.

So let's do it!

Step 1: Install Node.js and NPM

First thing’s first: You need to download Node.js. It’s free and available for Windows, MacOs and Linux (in my case I'm using Windows).

Run the installer, follow the prompts in the installer. Accept the license agreement, click the NEXT button a bunch of times and accept the default installation settings.

NPM is distributed with Node.js, which means that when you download Node.js, you automatically get npm installed on your computer.

Restart your computer. You will not be able to run Node.js until you restart your computer!

Step 2: Test the Node.js

To Make sure you have Node.js and NPM installed, we will run simple commands to see what version of each is installed and to run a simple test program:

Test Node.js: To confirm that you have Node.js installed, type this command in your terminal:

node -v

This should print a version number.

Test NPM: To check if you have NPM installed, you can run this command in your terminal:

npm -v

Create a test file and run it: A simple way to test that Node.js works is to create a JavaScript file: for example name it ask.js, and add the code below:

console.log('Hello AskSensors!');

Run the code: open your command line program, navigate to the folder where you save the file and type:

node ask.js

You should see " Hello AskSensors!", means all fine!

Now, you have the Node.js and NPM ready. By next we will create an AskSensors account..