In this tutorial, we will connect an HC-05 Bluetooth module with Surilli GSM by serial communication between our PC and Arduino, so we can send information (like sensor readings) from an Arduino to PC or Android device, and build home automation system via Bluetooth, and control a robot wirelessly.
STEP 1: Required Materials1. Surilli Basic M0
2. HC-05 Bluetooth module
3. Jumper wires
4. Breadboard
STEP 2: ConnectionsSurilli Basic M0 --> Bluetooth HC-05
USB --> +5V
GND --> GND
TX --> PIN 10
RX --> PIN 9
STEP 3: Set Up Arduino IDE for SurilliMake sure you have selected the right port, board and processor for the Surilli as shown in the picture below and it is programmable (compile and upload “Blink” from File>Examples>Digital>Blink onto your Surilli to check if everything is working fine).
STEP 4: The CircuitryThe circuitry is very simple. Follow the figure below to set up your hardware.
We now want to send or receive daa between Arduino and computer.
First, we need to make a communication link from the Arduino to the computer.
We will need software called Tera Term to show the data received or what we want to send through it .
You can download Tera Term or any terminal emulator software.
To make a link between your Arduino and Bluetooth, do the following :
1) Go to the Bluetooth icon , right click and select Add a Device 2) Search for new device , Our Bluetooth module will appear as HC-05 , and add it 3) The pairing code will be 1234 .4) After make a pairing , we can now program the Arduino and upload a sketch to send or receive data from Computer.
STEP 6: Upload and Burn Code Ono SurilliNow you have completed setting up your hardware and Arduino IDE. Copy and paste the Arduino sketch given below into your Arduino IDE and hit upload.
We will use software serial library to make pin 10 and 11 as Tx and Rx instead of using the default Rx and Tx.
This program below allow us to control LED connected to D13. To blink ON/OFF, by pressing key 1 from PC Keyboard the LED is ON , and if we press key 0 from PC Keyboard the LED is OFF.
To send the control commands from the computer to Arduino, go to Tera Term, run it, and choose Serial, then select the Bluetooth serial.
#include <SoftwareSerial.h>// import the serial library
SoftwareSerial Genotronex(9, 10); // RX, TX
int ledpin=13; // led on D13 will show blink on / off
int BluetoothData; // the data given from Computer
void setup() {
// put your setup code here, to run once:
Genotronex.begin(9600);
Genotronex.println("Bluetooth On please press 1 or 0 blink LED ..");
pinMode(ledpin,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (Genotronex.available()){
BluetoothData=Genotronex.read();
if(BluetoothData=='1'){ // if number 1 pressed ....
digitalWrite(ledpin,1);
Genotronex.println("LED On D13 ON ! ");
}
if (BluetoothData=='0'){// if number 0 pressed ....
digitalWrite(ledpin,0);
Genotronex.println("LED On D13 Off ! ");
}
}
delay(100);// prepare for next data ...
}
After uploading this sketch, go to Tera Term, press 0 or 1 , and see the results.
STEP 5: Connect Arduino to Android DeviceAfter we finished from connecting Arduino with PC via the HC-05 module, we can connect Arduino to an Android device.
First, you will need a terminal emulator on any Android device to send or receive data to Arduino.
You can download this app from Google Play.
After that, you can use the same Arduino sketch and control an LED blinking on/off from Android device.
Just type and send "1" to make LED blink ON, or "0" to make LED blink OFF.
STEP 6: Receiving Data from ArduinoIf you make something fun and interesting do share it with our community.
That’s all for now. If you have any queries, visit surilli.io or contact our support. Stay connected with Surilli family for more amazing stuff. :-)
Comments