This module allows you to both send and receive 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.
The terminal module allows you to both send data to the hardware device and receive data from the hardware device.
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:
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.
You can use the terminal in the following three ways.
- To compare a string of data: There is a boolean block “is data from terminal()”, using this you can compare a string received from the terminal.
- To send data to the terminal: There is a stack block “send () to terminal”, using this you can send a string of data to the terminal.
- To receive a number from the terminal: There is a reporter block “get Number from terminal”, It will always return a number. Using this, You can receive any number from the terminal.
To include the Terminal module in the Arduino program, you have to include the following header:
After defining the above mention headers, you have to include the dabble library:
You can download the library from here:
Enabling Bluetooth Communication
To enable Bluetooth communication, you have to initialize serial communication using the following code:
Here Baud_Rate is the baud rate set for the Bluetooth module. With evive, you normally get 115200 baud rate modules.
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:
Following are the function available for the Terminal module:
- 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.
- Terminal.read(): This function returns the first byte available in the terminal queue. This function returns one character at a time.
- Terminal.readString(); This function returns the whole string of data available on the Terminal.
- 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.
- Terminal.readNumber(): This function reads the last number available in the Terminal and returns its value in int data type.
- Terminal.print(data): This function sends the argument to the mobile app.
- Terminal.println(data): This function sends the argument to the mobile app with a newline added at the end of the message.