Absolute beginner needs help to integrate HC-05 Bluetooth into UNO - ADXL345

Hello, I have an ADXL345 Accelerometer connected to my Arduino UNO connected to my PC through USB at the moment

Arduino 3v3 to ADXL345 VCC & CS
Arduino GND to ADXL345 GND
Arduino PC5 to ADXL345 SCL
Arduino PC4 to ADXL345 SDA

#include <Wire.h>

#define accel_module (0x53)
byte values[6];
char output[512];

void setup(){
  Wire.begin();
  Serial.begin(9600);

  Wire.beginTransmission(accel_module);
  Wire.write(0x2D);
  Wire.write(0);
  Wire.endTransmission();
  Wire.beginTransmission(accel_module);
  Wire.write(0x2D);
  Wire.write(16);
  Wire.endTransmission();
  Wire.beginTransmission(accel_module);
  Wire.write(0x2D);
  Wire.write(8);
  Wire.endTransmission(); 
}

void loop(){
  int xyzregister = 0x32;
  int x, y, z;

  Wire.beginTransmission(accel_module);
  Wire.write(xyzregister);
  Wire.endTransmission();

  Wire.beginTransmission(accel_module);
  Wire.requestFrom(accel_module, 6);

  int i = 0;
  while(Wire.available()){
    values[i] = Wire.read();
    i++;
  }
  Wire.endTransmission();

  x = (((int) values[1]) << 8) | values[0];
  y = (((int) values[3]) << 8) | values[2];
  z = (((int) values[5]) << 8) | values[4];

  sprintf(output, "%d %d %d",x, y, z);
  Serial.print(output);
  Serial.write(10);

  delay(100);
  }

The accelerometer is feeding the x, y and z values fine. So now I'm looking to integrate HC-05 Bluetooth module into the project. The problem is that I have zero clue how. Even the code for the accelerometer was not done by me, I found it here

I've searched through the internet and I managed to connect the HC-05 to my Arduino separately from the accelerometer, and I've had success to connect my PC to the HC-05. But I'm struggling to put these two together in the project. I have some familiarity with C programming if it's relevant.

(Image attachments of the ADXL345 and the HC-05 Bluetooth module provided)

adxl345.jpg

Bluetooth_Module_HC05-3.jpg

Very little more than zero clue is actually required and, assuming that your accelerometer programme works, no more programming.

In the immortal words of a guru round here, Bluetooth is just serial without wires.

You will require a terminal programme for your PC, like RealTerm, that can receive input from PCs Bluetooth.You may then simply connect HC-05 to serial pins 0,1 and send the data to RealTerm via Bluetooth instead of to the serial monitor via cable.

You might find the following background notes useful.

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

You may require no more than the first page....

Nick_Pyner:
Very little more than zero clue is actually required and, assuming that your accelerometer programme works, no more programming.

In the immortal words of a guru round here, Bluetooth is just serial without wires.

You will require a terminal programme for your PC, like RealTerm, that can receive input from PCs Bluetooth.You may then simply connect HC-05 to serial pins 0,1 and send the data to RealTerm via Bluetooth instead of to the serial monitor via cable.

You might find the following background notes useful.

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

You may require no more than the first page....

Thank you very much for this detailed guide you've shared. But I'd like to know one thing. According to the guide, I'm required to connect the HC-05 RXD to both Arduino's GND and TXD, but they had resistors on the connection. As I have no access to resistors at this very moment, I'd like to know how important are those resistors, why even have resistors there?

This is clearly good practice but definitely not critical. I have never heard of anybody frying a module because they didn't do it, and my first Bluetooth project was running continuously for over a year without the resistors before I found that this was not such a good idea.

The resistors form a voltage divider, thereby converting the transmitted signal from the 5v Arduino to 3.3v, as required by HC-05. See the back of the board. Arduino is fine with 3.3v signal from HC-05.

I'd like to know how important are those resistors, why even have resistors there?

They are very important. The Bluetooth module is designed for 3.3V and according to the manufacturer, will be destroyed by application of 5V to the input. The resistors form a "voltage divider" to produce 3.3V from 5V.

Alternatives include using a single series resistor (say 4.7K) from Arduino TX to module RX, a logic level converter, or best of all, use a 3.3V Arduino and make the connection directly.

Some people are lucky, and their modules survive application of 5V to an input for some period of time. Yours may not.