I'm trying to get my HC-06 and HC-05 connected. I have managed to get into the HC-05's AT command thing and set it as the master, and gave it the address of the HC-06 to connect. It seems that they have been able to successfully connect, seeing as the light on the HC-06 goes solid and the one on the HC-05 blinks twice every 2 seconds or so, but I'm not getting the character that the HC-06 sends in my Serial Monitor. When I try to test the HC-06 with my phone, it simply returns: Connection failed: gatt status 133 and doesn't connect. What could be causing this issue, and how do I fix it?
Here are the codes for the HC-06:
#include <Wire.h>
#include <SoftwareSerial.h>
#include <MPU6050.h>
SoftwareSerial BTSerial(10, 11);
MPU6050 mpu1(0x68); // Address 0x68
MPU6050 mpu2(0x69); // Address 0x69
void setup() {
Wire.begin();
BTSerial.begin(9600);
Serial.begin(9600);
mpu1.initialize();
mpu2.initialize();
if (!mpu1.testConnection()) {
Serial.println("MPU6050 #1 connection failed");
} else {
Serial.println("MPU6050 #1 connected");
}
if (!mpu2.testConnection()) {
Serial.println("MPU6050 #2 connection failed");
} else {
Serial.println("MPU6050 #2 connected");
}
}
void loop() {
int16_t ax1, ay1, az1;
int16_t gx1, gy1, gz1;
int16_t ax2, ay2, az2;
int16_t gx2, gy2, gz2;
mpu1.getMotion6(&ax1, &ay1, &az1, &gx1, &gy1, &gz1);
mpu2.getMotion6(&ax2, &ay2, &az2, &gx2, &gy2, &gz2);
// Calculate angles (implement your own algorithm here)
float angle1 = atan2(ay1, az1) * 180 / PI;
float angle2 = atan2(ay2, az2) * 180 / PI;
float relativeAngle = angle2 - angle1;
Serial.print("Angle1: ");
Serial.print(angle1);
Serial.print(" Angle2: ");
Serial.print(angle2);
Serial.print(" Relative Angle: ");
Serial.print(relativeAngle);
if(relativeAngle<-70 && relativeAngle>-110) {
Serial.println("one joint");
BTSerial.write("O");
}
else if(relativeAngle<-130 && relativeAngle>-180) {
Serial.println("two joint");
BTSerial.write("T");
}
else {
Serial.println("no joint");
BTSerial.write("N");
}
delay(100);
}
and the HC-05:
#include <SoftwareSerial.h>
SoftwareSerial Bluetooth(10,4);
char c=' ';
void setup() {
Serial.begin(9600);
Serial.println("ready");
Bluetooth.begin(38400);
}
void loop() {
if(Bluetooth.available()) {
c=Bluetooth.read();
Serial.write(c);
}
if(Serial.available()) {
c=Serial.read();
Bluetooth.write(c);
}
}