I am trying to send messages to my Android device's terminal through the HC-06 Bluetooth Module.
Here is the current code.
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX
// Connect the HC-06 TX to Arduino pin 2(as RX).
// Connect the HC-06 RX to Arduino pin 3 (as TX) through a voltage divider.
char c = ' '; //initializes to a space
void setup()
{
Serial.begin(9600);
Serial.println("Arduino is ready");
// HC-05 default serial speed for communication mode is 9600
BTserial.begin(9600);
Serial.println("BTserial started at 9600");
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTserial.available())
{
c = BTserial.read();
Serial.write(c);
}
// Keep reading from Arduino Serial Monitor and send to HC-06
if (Serial.available())
{
c = Serial.read();
// Copy the serial data back to to the serial monitor.
// This makes it easy to follow the commands and replies
Serial.write(c);
BTserial.write(c);
}
}
Here are the connections I have to my Arduino Nano board:
- d3 -> 1k resistor -> 2.2k resistor, and connected to rxd on the HC-06 module from the middle
- d2 -> TXD
- GND -> GND
- 5V -> VCC
Again, I can only send things from my android device to the serial monitor of the Arduino, not the other way around. I would like to be able to send data to my android device's terminal.