Hello everyone, in this tutorial we are going to look at few examples to send and receive data over Bluetooth.
Prerequisites
- Windows 10 or above/Linux (64 bit)
- Arduino IDE
- VEGA ARIES Board support package
Hardware Required
- ARIES v3.0 Board
- HC-05 Bluetooth Module
- Piezo Buzzer
- LED
- USB type C to USB type A cable.
- Jumper Wires
Note: All of the following boards can be used for this project
ARIES v3.0 Board
The ARIES v3.0 is a fully indigenous and a “Made in India” product to get started with basic microprocessor programming and embedded systems. This board is built upon a RISC-V ISA compliant VEGA Processor with easy-to-use hardware and software. For more details about ARIES v3.0 boards please refer to the ARIES development boards and Ecosystem.
Bluetooth Module HC-05
The HC-05 is a class 2 Bluetooth module designed for transparent wireless serial communication. It is pre-configured as a slave Bluetooth device. Once it is paired to a master Bluetooth device such as PC, smart phones and tablet, its operation becomes transparent to the user. All data received through the serial input is immediately transmitted over the air. When the module receives wireless data, it is sent out through the serial interface exactly at it is received.
Connection Diagram
Let’s connect the HC-05 Bluetooth Module to the ARIES v3 board.
Connections
HC-05 Bluetooth Module | ARIES V3.0 Board |
VCC | 3.3/5V |
GND | GND |
TXD | RX-1 |
RXD | TX-1 |
Procedure
Once we are done with the connections, let’s power up the board. Make sure the Laptop/Desktop/PC which we’re using should be preinstalled with Arduino IDE and VEGA ARIES Boards of latest version.
- Now, Open the Arduino IDE
- Make sure you have selected ARIES v3 Board from Tools -> Board -> VEGA Processor: ARIES Boards -> ARIES v3
- Enable the Flash Mode, Tools -> Flash Mode -> Enabled
- Select Programmer as VEGA FLASHER from Tools -> Programmer -> VEGA FLASHER
- Also select appropriate port, Tools -> Port -> COM* (ARIES Board)
- Here we are going to look at all the examples under File -> Examples -> Under Examples for ARIES v3 -> UART -> Bluetooth_HC05
- On your Android phone, turn on the Bluetooth. Search and tap on HC-05 in Available devices. Enter pin as “1234” and click on OK. Now you can see HC-05 under Paired devices.
- Before coming to the example, download the Android app required for this project which is Bluetronics.
Once you are done with the installation, let’s start to look at the first example.
• Dimmer
In this example, we will control the intensity of LED using the Android app.
How it works
- Connect a LED to PWM channel 0.
- Open the dimmer example from File -> Examples -> Under Examples for ARIES v3 -> UART -> Bluetooth_HC05 -> dimmer
- Once you did that Upload the code in ARIES v3 Board.
- Now, Open the Bluetronics app on your phone, click on “Select Your Device” option. Here you can see all the paired devices. Select HC-05 and click on Connect button.
- In Basic menu, you can see many blocks. Scroll down and select the Dimmer block.
- Drag the ball to the certain percentage from 0 to 100%, where 0% means 0% duty-cycle, 50% means 50% duty-cycle and so on.
Output
According to the dimmer value, the LED intensity will vary.
• Switch
In this demo, we will control built-in RGB LED on ARIES v3 board using an Android app.
How it works
- Open the switch example from File -> Examples -> Under Examples for ARIES v3 -> UART -> Bluetooth_HC05 -> switch
- Once you did that Upload the code in ARIES v3 Board.
- Now, Open the Bluetronics app on your phone, click on “Select Your Device” option. Here you can see all the paired devices. Select HC-05 and click on Connect button.
- In Basic menu, select the Switch block.
- Here we have assigned Switch 1 to Green LED on the board and Switch 2 and Switch 3 to Blue and Red LED respectively.
Output
When you turn on the Switch 1, Green LED on ARIES board will turn on and vice-versa. Similarly, when you turn on the Switch 2 and Switch 3, Blue and Red LED on the board will turn on. Other switches (Switch 4 to Switch 10) are not assigned to anything. You can add your own code to make use of other switches.
• Slider
In slider example, we are using slider block on Android app to increase and decrease the volume of buzzer.
How it works
- Connect a Buzzer to PWM channel 0.
- Open the slider example from File -> Examples -> Under Examples for ARIES v3 -> UART -> Bluetooth_HC05 -> slider
- Once you did that Upload the code in ARIES v3 Board.
- Now, Open the Bluetronics app on your phone, click on “Select Your Device” option. Here you can see all the paired devices. Select HC-05 and click on Connect button.
- In Basic menu, select the Slider block.
- Here you can select minimum and maximum value for the slider. For this example, we are using the default value i.e. from 0 to 1000.
- Move the slider to increase and decrease the volume of buzzer.
Output
When you move the slider towards right, you will notice the buzzer volume is increasing and vice versa.
• Voice Control
In this example, we will turn on and off the built-in LED over a voice command from the Android app.
How it works
- Open the voice control demo from File -> Examples -> Under Examples for ARIES v3 -> UART -> Bluetooth_HC05 -> voiceControl
- Once you did that Upload the code in ARIES v3 Board.
- Now, Open the Bluetronics app on your phone, click on “Select Your Device” option. Here you can see all the paired devices. Select HC-05 and click on Connect button.
- In Advance menu, select the Voice Control block.
- Click on microphone button and say “LED on” or “LED off” to turn on and off the LED respectively.
Output
When you say “LED on“, Green LED on the board will turn on and when you say “LED off” Green LED will turn off.
• Send Text
In this example, we will send the text from ARIES board to the Android app via Bluetooth.
How it works
- Open the send text demo from File -> Examples -> Under Examples for ARIES v3 -> UART -> Bluetooth_HC05 -> sendText
- Once you did that Upload the code in ARIES v3 Board.
- Now, Open the Bluetronics app on your phone, click on “Select Your Device” option. Here you can see all the paired devices. Select HC-05 and click on Connect button.
- In Basic menu, select the Receive Text block.
- Open the serial monitor at 115200 baud rate. Type the text message on serial monitor and click on Send button OR simply hit Enter on your keyboard.
Output
When you hit the Enter button on your keyboard, the same text message you typed on serial monitor will display on Receive text block in the Android app.
Note: You can also use Terminal block in Advance menu.
• Receive Text
In this example, we will send the text from the Android app and display it on serial monitor.
How it works
- Open the receive text demo from File -> Examples -> Under Examples for ARIES v3 -> UART -> Bluetooth_HC05 -> receiveText
- Once you did that Upload the code in ARIES v3 Board and open the serial monitor at 115200 baud rate
- Now, Open the Bluetronics app on your phone, click on “Select Your Device” option. Here you can see all the paired devices. Select HC-05 and click on Connect button.
- In Basic menu, select the Send Text block.
- Type the text message on Send Text block where “Type Here” is mentioned and click on Send.
Output
When you click on Send button, the same text message you typed in Send text block will display on Serial monitor.
Note: You can also use Terminal block in Advance menu.
Serial Output
On the serial monitor, a “Ready to receive data…..” message will be displayed for every example. This indicates that you need to send some data from the Android App. When you send data, it will be received on the ARIES v3 board and displayed on the serial monitor.
For example: when you turn on the Switch 1, “1A” will receive on ARIES board and display on serial monitor.