AskSensors IoT Platform Documentation


Connect Hardware to AskSensors


As there are many IoT hardware available nowadays, AskSensors is not tied to some specific hardware or platform.
If your device is connected to the internet, you can connect it easily to AskSensors and start building your Internet of Thing project in few minutes.
This section will cover how to program your hardware to connect and use it with the AskSensors platform.

Here is a list of how to use instructions provided for some popular platforms. To start using the platform select the development board you want to use:

1-ESP8266

2-ESP32

3-Arduino Ethernet

4-Arduino WiFi

5-Raspberry Pi

6-Regular PC using Node.js


Note:

It is recommended to install a new version of Arduino IDE from the official Arduino download page for programming Arduino compatible hardware, which is any board you can program with the Arduino IDE (Arduino + Ethernet, Arduino + Wifi, ESP8266, ESP32 , etc).
Please install a version starting form v1.8.7. Ignore this if you already have a modern version.


1-ESP8266

The ESP8266 chip from Espressif was the new generation of low-cost WiFi chips after the TI CC3000/CC3200.
This small chip not only integrates the whole WiFi features, but also a powerful programmable MCU.
Depending on the board layout (ESP-01, ESP-03, ESP-07, ESP12, etc) it is attached to a programmable flash, ranging from 512K to 4M. This increases the available user code space, and make possible other cool features like a small file system, or OTA updates.
This devices can be directly programmed from the Arduino IDE. The only requirement is to install the board via the Arduino Boards Manager.

AskSensors : ESP8266

    • Prerequisites
    • Hardware requirements
    • To follow along with this tutorial you will simply need:
      • Computer running Arduino software.
      • ESP8266 Node MCU.
      • USB micro cable to connect the node MCU to the computer.

    • Install ESP8266 in Arduino IDE
    • To install the ESP8266 board in your Arduino IDE, follow the instructions below:
      • Install the latest version of Arduino IDE software (1.8.7 or higher).
      • First of all, open the preferences window from the Arduino IDE : File> Preferences.
      • Go to the "Additional Board Manager URLs" field, Enter the following URL:
        http://arduino.esp8266.com/stable/package_esp8266com_index.
        If you already have the ESP32 boards URL, separate the URLs with a comma as show below:
        https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json
        Now, open boards manager (Tools > Board > Boards Manager), search for ESP8266 and click the install button for the "ESP8266 by Espressif Systems". It takes some few seconds.

    • Software
    • Example sketch and ESP8266 WIFI libraries are available in Github. The provided code is ready to use as is. It connects the ESP8266 to wireless network as HTTP client, and then push data to AskSensors.
      Download the code from github, decompress the zip folder and open the .ino file in Arduino IDE. You need to fill the following:
      • Your WIFI SSID and password.
      • The Api Key In generated before by AskSensors.
      • If needed, the time period between two successive data updates (set to 25 second in this example).
      • const char* wifi_ssid = ".........."; // SSID
        const char* wifi_password = ".........."; // WIFI
        const char* apiKeyIn = ".........."; // API KEY IN
        delay(25000); // delay 25sec

    • Run the code
      • Connect your ESP8266 to the computer and upload the code from Arduino IDE.
      • Return back to your sensor page on askSensors, click on 'visualize' and 'Show Graph' to view your sensor data in graph.
      • Open a serial terminal. You can cross-check the AskSensors graph readings with the values being printed on your Arduino Terminal.

    • Source Code :

    • /*
      * askSensors HTTP Request
      * Description: Connect ESP8266 to AskSensors over HTTP
      * Author: https://asksensors.com, 2018
      * github: https://github.com/asksensors/AskSensors-ESP8266-API
      */ #include <Arduino.h>
      #include <ESP8266WiFi.h>
      #include <ESP8266WiFiMulti.h>
      #include <ESP8266HTTPClient.h>
      // user config: TODO
      const char* wifi_ssid = "..................."; // SSID
      const char* wifi_password = "..................."; // WIFI
      const char* apiKeyIn = "..................."; // API KEY IN
      // ASKSENSORS config.
      String host = "http://asksensors.com"; // ASKSENSORS host name
      ESP8266WiFiMulti WiFiMulti;
      void setup() {
      Serial.begin(115200);
      Serial.println("*****************************************************");
      Serial.println("********** Program Start : Connect ESP8266 to AskSensors over HTTP");
      Serial.println("Wait for WiFi... ");
      Serial.print("********** connecting to WIFI : ");
      Serial.println(wifi_ssid);
      WiFi.begin(wifi_ssid, wifi_password);
      while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
      }
      Serial.println("");
      Serial.println("-> WiFi connected");
      Serial.println("-> IP address: ");
      Serial.println(WiFi.localIP());
      }
      void loop() {
      // wait for WiFi connection
      if (WiFi.status() == WL_CONNECTED){
      HTTPClient http;
      Serial.print("[HTTP] begin...\n");
      // Create a URL for the request
      String url = "";
      url += host;
      url += "/api.asksensors/write/";
      url += apiKeyIn;
      url += "?module1=";
      url += random(10,100);
      Serial.print("********** requesting URL: ");
      Serial.println(url);
      http.begin(url); //HTTP
      Serial.println("> Request sent to ASKSENSORS");
      Serial.print("[HTTP] GET...\n");
      // start connection and send HTTP header
      int httpCode = http.GET();
      // httpCode will be negative on error
      if(httpCode > 0) {
      // HTTP header has been send and Server response header has been handled
      Serial.printf("[HTTP] GET... code: %d\n", httpCode);
      // file found at server
      if(httpCode == HTTP_CODE_OK) {
      String payload = http.getString();
      Serial.println(payload);
      }
      } else {
      Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
      }
      http.end();
      Serial.println("********** End ");
      Serial.println("*****************************************************");
      }
      delay(25000);
      }

    2-ESP32

    After the big success of the ESP8266, the ESP32 is a new chip from Espressif that combines WiFi and Bluetooth wireless capabilities with two CPU cores and a decent hardware peripheral set.
    This section shows how to connect your ESP32 to the AskSensors cloud

    AskSensors : ESP32

      • Prerequisites
      • Hardware requirements
      • To follow along with this tutorial you will simply need:
        • Computer running Arduino software.
        • ESP32 development board.
        • USB micro cable to connect ESP32 development board to the computer.

      • Install ESP32 in Arduino IDE
      • To install the ESP8266 board in your Arduino IDE, follow the instructions below:
        • Install the latest version of Arduino IDE software (1.8.7 or higher).
        • First of all, open the preferences window from the Arduino IDE : File> Preferences.
        • Go to the "Additional Board Manager URLs" field, Enter the following URL:
          https://dl.espressif.com/dl/package_esp32_index.json
          If you already have the ESP8266 boards URL, separate the URLs with a comma as show below:
          https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json
          Now, open boards manager (Tools > Board > Boards Manager), search for ESP8266 and click the install button for the "ESP8266 by Espressif Systems". It takes some few seconds.

      • Software
      • Download this demo from the AskSensors Github page.
        The code includes the libraries for both connecting to a WiFi network and to perform the HTTP requests. You need to fill the following:
        • Your WIFI SSID and password.
        • The Api Key In generated before by AskSensors.
        • const char* wifi_ssid = ".........."; // SSID
          const char* wifi_password = ".........."; // WIFI
          const char* apiKeyIn = ".........."; // API KEY IN

      • Run the code
        • Connect your ESP32 to the computer and upload the code from Arduino IDE.
        • Return back to your sensor page on askSensors, click on 'visualize' and 'Show Graph' to view your sensor data in graph.
        • Open a serial terminal on Arduino IDE. You can cross-check the AskSensors graph readings with the values being printed on your Arduino IDE Terminal.

      • Source Code:

      • /*
        Connect ESP32 to AskSensors
        * Description: This sketch connects to a website (https://asksensors.com) using an ESP32 Wifi module.
        * Author: https://asksensors.com, 2018
        * github: https://github.com/asksensors
        */
        #include <WiFi.h>
        #include <WiFiMulti.h>
        #include <HTTPClient.h>
        WiFiMulti WiFiMulti;
        HTTPClient ask;
        // TODO: user config
        const char* ssid = "............."; //Wifi SSID
        const char* password = "............."; //Wifi Password
        String apiKeyIn = "............."; // API Key
        const char* host = "asksensors.com"; // host
        const int httpPort = 80; // port
        void setup(){
        // open serial
        Serial.begin(9600);
        Serial.println("*****************************************************");
        Serial.println("********** Program Start : Connect ESP32 to AskSensors.");
        Serial.println("Wait for WiFi... ");
        // connecting to the WiFi network
        WiFiMulti.addAP(ssid, password);
        while (WiFiMulti.run() != WL_CONNECTED) {
        Serial.print(".");
        delay(500);
        }
        // connected
        Serial.println("WiFi connected");
        Serial.println("IP address: ");
        Serial.println(WiFi.localIP());
        }
        void loop(){
        // Use WiFiClient class to create TCP connections
        WiFiClient client;
        if (!client.connect(host, httpPort)) {
        Serial.println("connection failed");
        return;
        }else {
        // Create a URL for the request
        String url = "https://asksensors.com/api.asksensors/write/";
        url += apiKeyIn;
        url += "?module1=";
        url += random(10, 100);
        Serial.print("********** requesting URL: ");
        Serial.println(url);
        // ask.begin("https://asksensors.com/api.asksensors/write/ONKMHCC38YT74K5NGT8JC1GF8B1O9QKT?module1=100"); //Specify the URL
        ask.begin(url); //Specify the URL
        //Check for the returning code
        int httpCode = ask.GET();
        if (httpCode > 0) {
        String payload = ask.getString();
        Serial.println(httpCode);
        Serial.println(payload);
        } else {
        Serial.println("Error on HTTP request");
        }
        ask.end(); //End
        Serial.println("********** End ");
        Serial.println("*****************************************************");
        }
        client.stop(); // stop client
        delay(20000); // delay
        }

      3-Arduino Ethernet

      The Arduino Ethernet Shield connects your Arduino to the internet in mere minutes. Just plug this module onto your Arduino board, connect it to your network with an RJ45 cable, and you are almost done to start controlling your world through the internet.

      AskSensors : Arduino + Ethernet

      • Arduino Ethernet Shield
      • - Features:

        • Requires an Arduino board.
        • Operating voltage 5V, supplied from the Arduino Board.
        • Ethernet Controller: Wiznet Ethernet controller W5100 with internal 16K buffer.
        • The Wiznet W5100 provides a network (IP) stack capable of both TCP and UDP.
        • Connection speed: up to 10/100Mb.
        • Connection with Arduino on SPI port: It uses the ICSP header pins and pin 10 as chip select for the SPI connection to the Ethernet controller chip.
        • The latest revision of the Ethernet Shield includes a micro-SD card slot on board, which can be used to store files for serving over the network.
        • The Ethernet Module has a standard RJ45 connection, with an integrated line transformer.
        • The connection to a network is made with a RJ45 Ethernet cable.

        - Software Library:

        • The Ethernet shield relies on the Arduino Ethernet library.
        • The library comes bundled with the Arduino IDE.
        • We will need to change some network settings in the program to correspond to our network.

        - Informational LEDs:

        • PWR: indicates that the board and shield are powered.
        • LINK: indicates the presence of a network link and flashes when the shield transmits or receives data.
        • FULLD: indicates that the network connection is full duplex.
        • 100M: indicates the presence of a 100 Mb/s network connection (as opposed to 10 Mb/s).
        • RX: flashes when the shield receives data.
        • TX: flashes when the shield sends data.
        • COLL: flashes when network collisions are detected.

        • Prerequisites
        • Hardware requirements
        • To follow along with this tutorial you will simply need:
          • Computer running Arduino software.
          • An Arduino board such as the Arduino Uno.
          • An Arduino Ethernet Shield.
          • USB micro cable to connect ESP32 development board to the computer.
          • An Ethernet cable, for connecting to your network router.

        • Software

        • There are hundreds of tutorials about connecting the Arduino to the web through the Ethernet Shields, so I'm not going to explain this part.
          Download this demo from the AskSensors Github page.
          The code uses DHCP and DNS for the server and is supposed to work right away with few changes:
          • If you are using more than one Ethernet shield on a network, make sure that each Ethernet shield on the network must have a unique mac address.
          • Change the IP address in the sketch to match the IP address range of your network.
          • Set the Api Key In of your sensor.
          • Set your dummy data.
          • // MAC
            byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
            // Set the static IP address to use if the DHCP fails to assign
            IPAddress ip(192, 168, 1, 177);
            // ASKSENSORS config.
            const char* apiKeyIn = "......................"; // Change it with your API KEY IN
            // dummy data
            int dumData = 100; // set your data

        • Run the code
          • Plug the Ethernet shield into the Arduino Uno board.
          • Connect the Ethernet shield to your router/network through the Ethernet cable.
          • Connect the Arduino to the computer through the USB cable. Power will be supplied to the two boards via the USB cable.
          • Open your code in Arduino IDE, Select the correct Arduino board and COM port. Then, upload the code to your Arduino board. make sure that the code was uploaded successfully.
          • You can use the reset button on the shield to reset both the the Ethernet Controller and the Arduino board.
          • After reset/power up, open a serial terminal, you should see the Arduino printing the program status: the arduino connects to the network (takes few seconds), then sends the dummy data to the AskSensors over HTTP get requests.
          • After receiving the request of wrting data to the specific Sensor from the client, the server first sends a HTTP response telling the number of modules updated successfully ('1' in our case).

        • Source Code

        • /*
          Connect Arduino Ethernet to AskSensors
          * Description: This sketch connects to a website (https://asksensors.com) using an Arduino Wiznet Ethernet shield.
          * Author: https://asksensors.com, 2018
          * github: https://github.com/asksensors
          */
          #include <SPI.h>
          #include <Ethernet.h>
          // ETHERNET config.
          // Enter a MAC address for your controller below.
          // Newer Ethernet shields have a MAC address printed on a sticker on the shield
          byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
          // Set the static IP address to use if the DHCP fails to assign
          IPAddress ip(192, 168, 1, 177);
          // ASKSENSORS config.
          char server[] = "asksensors.com"; // ASKSENSORS host name
          const int port = 80; // Port: HTTP=80
          const char* apiKeyIn = "5V8APAV9Q0OWEBDOSCYRSKGGEIWC3M8Q"; // API KEY IN (change it with your API KEY IN)
          // dummy data
          int dumData = 100; // set your data
          // Initialize the Ethernet client library
          // with the IP address and port of the server
          // that you want to connect to (port 80 is default for HTTP):
          EthernetClient client;
          void setup() {
          // Open serial communications and wait for port to open:
          Serial.begin(9600);
          while (!Serial) {
          ; // wait for serial port to connect. Needed for native USB port only
          }
          // start the Ethernet connection:
          if (Ethernet.begin(mac) == 0) {
          Serial.println("Failed to configure Ethernet using DHCP");
          // try to congifure using IP address instead of DHCP:
          Ethernet.begin(mac, ip);
          }
          // give the Ethernet shield a second to initialize:
          delay(1000);
          Serial.println("connecting...");
          // if you get a connection, report back via serial:
          if (client.connect(server, port)) {
          Serial.print("connected asksensors.com");
          //Create a URL for the request
          String url = "http://asksensors.com/api.asksensors/write/";
          url += apiKeyIn;
          url += "?module1=";
          url += dumData;
          Serial.print("********** requesting URL: ");
          Serial.println(url);
          //Make a HTTP request:
          client.print(String("GET ") + url + " HTTP/1.1\r\n" +
          "Host: " + server + "\r\n" +
          "Connection: close\r\n\r\n");
          client.println();
          Serial.println("> Request sent to ASKSENSORS");
          } else {
          // if you didn't get a connection to the server:
          Serial.println("connection failed");
          }
          }
          void loop() {
          // if there are incoming bytes available
          // from the server, read them and print them:
          if (client.available()) {
          char c = client.read();
          Serial.print(c);
          }
          // if the server's disconnected, stop the client:
          if (!client.connected()) {
          Serial.println();
          Serial.println("disconnecting.");
          client.stop();
          // do nothing forevermore:
          while (true);
          }
          }

        4-Arduino WiFi

        In this section we will configure a setup composed from an Arduino and an ESP8266 WiFi module as an IoT Thing.

        AskSensors : Arduino + WiFi

          • Prerequisites
          • Hardware requirements
          • To follow along with this tutorial you will simply need:
            • Computer running Arduino software
            • An Arduino board such as the Arduino Uno.
            • ESP8266 WiFi module. I'm using the ESP-01S
            • USB micro cable to connect ESP32 development board to the computer.
            • Wires and breadboard.

            The connection between Arduino and ESP8266 is as follows:
            • ESP TX to Arduino pin 10
            • ESP RX to Arduino pin 11
            • ESP VCC to Arduino 3V3
            • ESP CH_PD to Arduino 3V3
            • ESP GND to Arduino GND

          • Software

          • Now let’s write the code to send a simple data from the Arduino to the AskSensors cloud through WiFi. The Arduino code communicates with the ESP8266 WiFi module using AT commands. Data will be sent to AskSensors over HTTP connection. A ready to use code is provided in the AskSensors Github page.
            Download the code and set the following variables to your setup (WiFi SSID, password and the 'Api Key In'):
            String ssid = "............."; //Wifi SSID
            String password = "............."; //Wifi Password
            String apiKeyIn = "............."; // API Key

          • Run the code
            • Connect your Arduino to the computer and upload the code from Arduino IDE.
            • Return back to your sensor page on askSensors, click on 'visualize' and 'Show Graph' to view your sensor data in graph.
            • Open a serial terminal on Arduino IDE. You can cross-check the AskSensors graph readings with the values being printed on your Arduino Terminal.

          • Source Code

          • /*
            Connect Arduino WiFi to AskSensors
            * Description: This sketch connects the Arduino to AskSensors IoT Platform (https://asksensors.com) using an ESP8266 WiFi.
            * Author: https://asksensors.com, 2018
            * github: https://github.com/asksensors
            */
            #include <SoftwareSerial.h>
            // serial config
            #define RX 10
            #define TX 11
            SoftwareSerial AT(RX,TX);
            // TODO: change user config
            String ssid = "............."; //Wifi SSID
            String password = "............."; //Wifi Password
            String apiKeyIn = "............."; // API Key
            String host = "asksensors.com"; // host
            String port = "80"; // port
            int AT_cmd_time;
            boolean AT_cmd_result = false;
            void setup() {
            Serial.begin(9600);
            // open serial
            Serial.println("*****************************************************");
            Serial.println("********** Program Start : Connect Arduino WiFi to AskSensors");
            AT.begin(115200);
            Serial.println("Initiate AT commands with ESP8266 ");
            sendATcmd("AT",5,"OK");
            sendATcmd("AT+CWMODE=1",5,"OK");
            Serial.print("Connecting to WiFi:");
            Serial.println(ssid);
            sendATcmd("AT+CWJAP=\""+ ssid +"\",\""+ password +"\"",20,"OK");
            }
            void loop() {
            // Create the URL for the request
            String url = "GET /api.asksensors/write/";
            url += apiKeyIn;
            url += "?module1=";
            url += random(10, 100);
            Serial.println("*****************************************************");
            Serial.println("********** Open TCP connection ");
            sendATcmd("AT+CIPMUX=1", 10, "OK");
            sendATcmd("AT+CIPSTART=0, \"TCP\",\"" + host +"\"," + port, 20, "OK");
            sendATcmd("AT+CIPSEND=0," + String(url.length() + 4), 10, ">");
            Serial.print("********** requesting URL: ");
            Serial.println(url);
            AT.println(url);
            delay(2000);
            sendATcmd("AT+CIPCLOSE=0", 10, "OK");
            Serial.println("********** Close TCP Connection ");
            Serial.println("*****************************************************");
            delay(20000); // delay
            }
            // sendATcmd
            void sendATcmd(String AT_cmd, int AT_cmd_maxTime, char readReplay[]) {
            Serial.print("AT command:");
            Serial.println(AT_cmd);
            while(AT_cmd_time < (AT_cmd_maxTime)) {
            AT.println(AT_cmd);
            if(AT.find(readReplay)) {
            AT_cmd_result = true;
            break;
            }
            AT_cmd_time++;
            }
            Serial.print("...Result:");
            if(AT_cmd_result == true) {
            Serial.println("DONE");
            AT_cmd_time = 0;
            }
            if(AT_cmd_result == false) {
            Serial.println("FAILED");
            AT_cmd_time = 0;
            }
            AT_cmd_result = false;
            }

          5-Raspberry Pi

          This section explains how to connect your Raspberry Pi to the AskSensors IoT platform using node.js.

          AskSensors : Raspberry Pi

            • Prerequisites
            • Hardware requirements
            • Here is the required materials:
              • Raspberry Pi Model B+ or Model B (you can also use a Raspberry Pi 2 Model B)
              • USB micro cable to power up your Pi.
              • MicroSD card, I recommend a class 10 card that is 16 GB or higher.
              • MicroSD to SD memory card adapter, you will need to use the SD card reader on your laptop/desktop to write to the microSD card.

            • Set Up Your Raspberry Pi

            • Running a basic setup of Raspbian on Raspberry Pi become easy and clearly explained in this Getting Started Guide.
              Here are the main steps:
              • Download NOOBS
              • Extract it on your SD
              • Plug it in and turn on the Raspberry Pi.
              • When prompted, choose to install Raspbian and let it run.
              That's it, Now we have an amazing Raspberry Pi system that can be used for a variety of tasks!

            • Install Node Js

            • Here we go in the Node.js installation, Installing an ARM-version of Node become very easy!

            • Test Node.js

            • To make sure that node.js runs correctly, Type the commands below. It should return the current version of node and npm installed. node -v
              npm -v
              Make sure it doesn't give any error. If everything is ok, we can move to the next step!

            • Software
            • Download the .js file from github. It requires the installation of the https npm package.
              You will need to set your Api Key In. var ApiKeyIn = '................'; // Api Key In

            • Run the code
            • Now you are ready to run the final script :
              node https_GET.js

            • Source Code

            • /*
              * Connect Raspberry Pi to AskSensors
              * Description: This code sends dummy data to askSensors IoT platform over HTTPS GET Request.
              * Author: https://asksensors.com, 2018
              * github: https://github.com/asksensors
              * Instructables: https://www.instructables.com/id/Connect-Raspberry-Pi-to-Asksensors-IoT-Platform-Us/
              */
              // includes
              var https = require('https');
              const request = require('request');
              // Configuration
              var host = 'https://asksensors.com'; // server host
              var ApiKeyIn = '........................'; // TODO: Put your Api Key In
              var module1 = 0; // module
              var timerInterval = 20000; // timer interval
              // Function declaration: send data
              function send_data(){
              var url = host + '/api.asksensors/write/';
              url+= ApiKeyIn;
              url+= '?module1='
              url+= 100*Math.random();//module1++;
              console.log('Data sent to:' + url);
              request(url, { json: true }, (err, res, body) => {
              if (err) { return console.log(err); }
              });
              }
              send_data();// send first data
              // Send data every timerInterval
              setInterval(send_data, timerInterval); // setInterval

            6-Regular PC using Node.js

            This section explains how to connect send data to the AskSensors IoT platform from regular PC using node.js.

            AskSensors : Node.js

              • Prerequisites
              • Install Node.js and NPM
                • 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!

              • 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

              • Software
              • Download the .js file from github. It requires the installation of the https npm package.
                You will need to set your Api Key In. var ApiKeyIn = '................'; // Api Key In

              • Run the code
              • Type this command to run the .js file::
                node https_GET.js

              • Source Code

              • /*
                * Automated data sending using https
                * Description: This example code sends dummy data to askSensors IoT platfom (https://asksensors.com) over HTTPS GET Requests.
                * Author: https://asksensors.com, 2018
                * github: https://github.com/asksensors
                */
                // includes
                var https = require('https');
                const request = require('request');
                // Configuration
                var host = 'https://asksensors.com'; // server host
                var ApiKeyIn = '...................'; // TODO: fill your sensor Api Key In given by https://asksensors.com
                var module1 = 0; // module
                var timerInterval = 20000; // timer interval
                // Function declaration: send data
                function send_data(){
                var url = host + '/api.asksensors/write/';
                url+= ApiKeyIn;
                url+= '?module1='
                url+= 100*Math.random();//module1++;
                console.log('Data sent to:' + url);
                request(url, { json: true }, (err, res, body) => {
                if (err) { return console.log(err); }
                });
                }
                send_data();// send first data
                // Send data every timerInterval
                setInterval(send_data, timerInterval); // setInterval


              Previous : Create Sensor