Terminal Module

Terminal Messages

This module allows you to both send and receives data from a device with this module.

You can send both textual and voice commands to the device e.g. turning it ON or OFF. The messages are displayed with a timestamp

You can also publish data sent by the device on the app.

The data can be displayed in 4 formats: ASCII, binary, decimal, and hex.

 

You can now access this module on iOS devices by downloading Dabble from App Store.

Introduction

The terminal module allows you to both send data to the hardware device and receive data from the hardware device.

Dabble Terminal Messages

This module is similar to the serial monitor where you see the data sent and received from the device in real-time. 

Options for displaying data

You can display the sent and received data on the terminal in the following formats:

  1. ASCII
  2. Binary
  3. Decimal
  4. Hexadecimal

You can toggle between the options by clicking on the tree verticle dots on the top right side of the screen and clicking on the option.

Dabble Terminal Options

Functions for Arduino IDE

Header

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

#define CUSTOM_SETTINGS

#define INCLUDE_TERMINAL_MODULE

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

#include <Dabble.h>

You can download the zip of 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 name that you want to keep for Bluetooth of ESP32. 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

Following are the function available for the Terminal module:

  1. Terminal.available(): This function tells if there is new data present in the terminal queue or not. It returns 0 if there is not data, and 1 if there is data present.
  2. Terminal.read(): This function returns the first byte available in the terminal queue. This function returns one character at a time.
  3. Terminal.readString(); This function returns the whole string of data available on the Terminal.
  4. Terminal.compareString(String text): This function takes a string in the argument and compares whether the string available in the Terminal is same or not. If the string matches, it returns 1, otherwise returns 0.
  5. Terminal.readNumber(): This function reads the last number available in the Terminal and returns its value in int data type.
  6. Terminal.print(data): This function sends the argument to the mobile app.
  7. Terminal.println(data): This function sends the argument to the mobile app with a newline added at the end of the message.

PictoBlox (Scratch) Blocks

You can use the terminal in the following three ways.

  1. To compare a string of data: There is a boolean blockis data from terminal()”, using this you can compare a string received from the terminal.
    is data from terminal
  2. To send data to the terminal:  There is a stack blocksend () to terminal”, using this you can send a string of data to the terminal.send to terminal
  3. To receive a number from the terminal: There is a reporter blockget Number from terminal”, It will always return a number. Using this, You can receive any number from the terminal.
    get number from terminal
evive Notes Icon
Note: When you are using this module with Arduino Uno, Mega, and Nano,  you have to set the Bluetooth baud rate to the baud rate of the Bluetooth module to have proper communication between the board and the module. To set the baud rate you have to use set bluetooth baud rate to () block.

set bluetooth baud rate to

Examples

Click here to view Arduino IDE Example for Terminal Module

The example given below shows how to carry out a general communication between the Terminal module and your board.
1. Upload the code and open Serial Monitor.
2. Send any data from the Serial Monitor. You will be able to see it on your terminal screen. Similarly, send any data from terminal it will be displayed on Serial Monitor.

Code for all boards is given below. Copy the code as per your board. You can also find the code by navigating to “Files>>Examples>>Dabble>>” and select “Terminal” example as per your board.

evive

Mega, Uno, and Nano

ESP32

Click here to view PictoBlox (Scratch) Example for Terminal Module

Turn Lights ON/OFF  

In this example, you will learn how to switch ON or OFF  pin 13 led of your board by sending the “lights on” and “lights off” commands using Dabble’s Terminal module. Below is the script in Stage mode in Pictoblox.  

evive Notes Icon
Note: When working with evive or any of your Arduino board on PictoBlox for the very first time, or if you’ve previously uploaded another code to your board, you must upload the firmware in order to work in stage mode. You can find the procedure for the same here.

This script will run on evive but for Mega, Uno, and Nano add the “set bluetooth baud rate to” block below “when flag clicked” block. The rest of the script remains the same. For now, PictoBlox does not support ESP32; however, it will be added soon.

Projects

All articles loaded
No more articles to load

Leave a Reply

Close Menu
×

Cart