IoT Module – Internet

Description
Perform HTTP GET requests right from the hardware! Observe the request execution and response in real-time.

Introduction

This module allows you to connect to the world of the Internet through your Smartphone. It uses mobile data for connecting to the internet. This means that if you don’t have any wifi module like esp8266 but still, you can talk to the world. All you need is your Smartphone with a data connection, Dabble in your Smartphone and hardware with Bluetooth module and you are all ready to go!!. The module is currently under development and is able to process HTTP GET requests, however complete support for the HTTP request-response will be added soon. Currently, you can perform activities like publishing data on IoT platforms like Thingspeak or any such platform that works on the HTTP protocol.

In this module, you can observe the request execution and response in real-time. Request and response can also be copied by tapping on respective boxes.

The above image shows the process of updating your Thingspeak channels.

Arduino IDE Functions

Header

To include the Internet module in the Arduino program, you have to include the following header:

#define CUSTOM_SETTINGS
#define INCLUDE_MUSIC_MODULE

After defining the above mention headers, you have to include the dabble library:

#include <Dabble.h>

You can download the zip of the Arduino Library for

  1. evive, Uno, Mega, and Nano – Dabble-Arduino 
  2. ESP32 – Dabble-ESP32

depending on the board you are using.

Enabling Bluetooth Communication

To enable Bluetooth communication, you have to initialize serial communication using the following code:

  1. For evive and Arduino Mega, Uno, and Nano
    Dabble.begin(Baud_Rate);

    Here Baud_Rate is the baud rate set for the Bluetooth module. With evive, you normally get 115200 baud rate modules.

  2. For ESP32
    Dabble.begin("Bluetooth_Name");

    In place of Bluetooth_Name  enter the name that you want to keep for Bluetooth of ESP32. The default name given in the library is “MyEsp32”.

Refreshing the data

To refresh the data that the device has got from the mobile app, you have to use the following line of code:

Dabble.processInput();

Functions

The following functions are available for the input module:

  1. sendGETRequest(URL) – pass the HTTP GET request URL as an argument in this function, it will be sent to Dabble and the processed response will be available in the response section in Dabble.
  2. updateThingspeakField(WRITE_KEY, Field number, Numeric Data) –  This is a specific function that is meant to be used for updating the data of various fields present in your Thingspeak channel. You have to enter your write key obtained from API settings in your Thingspeak account, the field number that you want to update followed by the numeric value with which you want to update your field. There is a maximum of 8 data fields available in the Thingspeak channel.
  3. updateThingspeakField(WRITE_KEY, Field number, text Data) – This function is the same as above but it is for entering any text type data into the field.
  4. updateThingspeakChannel(WRITE_KEY, number of Fields, Numeric data1, Numeric data2, ….) – This function can be used when you want to publish data to multiple fields in one single update. For this enter your usual write key followed by the number of fields you want to update and then the numeric data for each field.
    Note:  Make sure that you enter data in sequence this means, for example, if you want to update field 1, field 2, and field 3 then you should write the corresponding data. That is the data of the first field should be first, the second field should be second and the third field should be third. You can skip any field as well. This means you can’t perform updates for field 1, field 2. and field 4 simultaneously, you have to enter the data of field 3 as well. You cannot break the sequence.
  5. updateThingspeakChannel(WRITE_KEY, number of Fields, text data1, text data2, ….)  – The function works the same as the above one but it is for updating fields simultaneously with text type of data. Here also the field data should be entered sequentially.

PictoBlox Blocks

The support for the Internet module will be added soon on PictoBlox.

Examples

Arduino IDE Example for IoT Module – Internet

evive

/*
   In this example you will be sending data of evive potentiometer to your thingspeak channel.
   Data is send to field 1 of your thingspeak channel.   
  
   You can reduce the size of library compiled by enabling only those modules that you
   want to use. For this first define CUSTOM_SETTINGS followed by defining
   INCLUDE_modulename.

   Explore more on: https://thestempedia.com/docs/dabble/internet-module/
*/
#define CUSTOM_SETTINGS
#define INCLUDE_INTERNET_MODULE
#include <evive.h>
#include <Dabble.h>
String WRITE_KEY = "IXPXC82OLNNH1EBW";   //enter your thingspeak channel write key   


void setup() {
  Dabble.begin(115200); //Enter baudrate of your bluetooth.Connect bluetooth on Bluetooth port present on evive.
  pinMode(TACTILESW1,INPUT);
}

void loop() {
  Dabble.processInput(); //this function is used to refresh data obtained from smartphone.Hence calling this function is mandatory in order to get data properly from your mobile.
  if(digitalRead(TACTILESW1) == HIGH)
  {
    Internet.updateThingspeakField(WRITE_KEY, 1, analogRead(POT1));  //Thingspeak Write Key, Field number, Data
    Dabble.delay(500);   //Debounce delay
  }
}

Mega, Uno, and Nano

/*
   In this example you will be sending data of analog pin to your thingspeak channel.
   Data is send to field 1 of your thingspeak channel.   
   
   NOTE:
   1)For Arduino Mega Connect Bluetooth on Serial3 pins.
   2)For Arduino Uno/Nano library uses SoftwareSerial,hence pin 2 and pin 3 are used
   as RX and TX pins respectively on SoftwareSerial.Hence with arduino Uno
   follow below connections for bluetooth.
   UNO  - BLUETOOTH
   2    - TX
   3    - RX
   3)For Uno/Nano keep bluetooth Baudrate below 38400.


   You can reduce the size of library compiled by enabling only those modules that you want
   to use. For this first define CUSTOM_SETTINGS followed by defining INCLUDE_modulename.

   Explore more on: https://thestempedia.com/docs/dabble/internet-module/
*/
#define CUSTOM_SETTINGS
#define INCLUDE_INTERNET_MODULE
#include <Dabble.h>
String WRITE_KEY = "IXPXC82OLNNH1EBW";   //enter your thingspeak write key 
uint8_t pushButton = 4;
void setup() {
  Dabble.begin(9600); //Change this baudrate as per your bluetooth baudrate. Connect bluetooth on digital pin 2(RX) and 3(TX) for Uno/Nano and on Serial3 pins for Mega.
  pinMode(pushButton,INPUT_PULLUP);  
}

void loop() {
  Dabble.processInput(); //this function is used to refresh data obtained from smartphone.Hence calling this function is mandatory in order to get data properly from your mobile.
  if(digitalRead(pushButton) == LOW)
  {
    Internet.updateThingspeakField(WRITE_KEY, 1, analogRead(A0));
    Dabble.delay(500);   //Debounce delay
  }
}
Table of Contents