dont know how to use bluetooth module hc-05

Status
Not open for further replies.
Make sure you set the arduino serial monitor up at 57600
after loading code to you uno

This code let's you play with the HC05
Code:
 */
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("Goodnight moon!");
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}
void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}
 
i dont understand why i shudnt use 38 post becuse everything work . only problem is ascii becuse everrything is wtited in it
 
i dont understand why i shudnt use 38 post becuse everything work . only problem is ascii becuse everrything is wtited in it

Because who can read that

Serial is ascii text you format it to output readable numbers
 
What be80be says in post #47 is correct. Look at the schematic of the Arduino Uno. You will see that the TX on the HC-05 is in parallel with the TX (Pin 9) on the ATMEGA16U (Via a 1K resistor.) This is the reason why with my sggested method that I suggest removing the ATMEGA328 . (And why the apparent strange way of connecting TX to TX is reqired, This is because RX on the ATMEGA16u is conneted to the TX on the ATMEGA328 and therefor marked TX) It is also the reason for be80be's method using two different pins for TX and RX. (As the ATMEGA328 only has one UART this requires the use of a software UART.) When you post you need to give FULL details of how everything is connected together. You have not said if the bluetooth module is in setup mode (AT command mode) or if it is paired and communicating with another Bluetooth interface. (For example a Bluetooth interface on a PC or Android tablet.)

Les.
 
Les Jones That I said is correct You cant use the atmega RX and TX pins if it is you will never no where the data is coming you have to remove the Atmega
But on lots of uno that's not even a option now days

Remove that atmega
 
This code let's you use the atmega both ways it to show you how it work from there you can go on and do what you want.
Code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
}
void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}
 
Just unplug it from the socket assuming it is an Arduino Uno Rev 3. If it is not a plug in chip then you would have to write a program to set the data direction register for the TX pin to be an input. Before doing this you would have to study how to boot loader worked as it might depend on this pin being left as an output.

Les.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…