Transferring data from MPU6050 to computer via HC-05 issues

Hello all,

I'm having issues with transmitted data from the HC-05 module.

I have a code that outputs gyro values in degrees from the MPU6050 that works perfectly fine with connected via USB to my computer However, when I switch to an external power source and allow the HC-05 to transmit the data it only displays "90" for all gyro values.

Connections for Reference:
MPU6050 ------ Arduino Uno
Vcc 3.3 V
GND GND
SCL A5
SDA A4

HC-05 ------ Arduino Uno
RXD TX (D1)
TXD RX (D2)
Vcc 5 V
GND GND

Example Serial Monitor with USB @ COM3
X Axis Y Axis Z Axis
94 90 92
90 98 100
84 110 115
80 120 116

Example Serial Monitor with HC05 @ COM5
X Axis Y Axis Z Axis
90 90 90
90 90 90
90 90 90
90 90 90

Code:
/*

Connections:

MPU6050_____UNO
VCC_________3.3v
GND_________GND
SCL_________PinA5
SDA_________PinA4

*/
#include "Wire.h"
#include "I2Cdev.h"
#include "MPU6050.h"
#include "Servo.h"

MPU6050 mpu;

int16_t ax, ay, az;
int16_t gx, gy, gz;

long val, val2, val3;
long prevVal;

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

Serial.print("X-Data");
Serial.print("\t");
Serial.print("Y-Data");
Serial.print("\t");
Serial.print("Z-Data");
Serial.println("\t");
}
void loop()
{
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
val = map(gx, -17000, 17000, 0, 180);
val2 = map(gy, -17000, 17000, 0, 180);
val3 = map(gz, -17000, 17000, 0, 180);
Serial.print(val);
Serial.print("\t");
Serial.print(val2);
Serial.print("\t");
Serial.print(val3);
Serial.println("\t");

delay(5);
}

Does anyone have any idea of the cause of this and a potential fix?

Thanks in advance

The line

long prevVal;

appears redundant, or may suggest your code is incomplete.

Do you really need a loop of 5ms? I bet you couldn’t read it if anything changed, and it may be the cause of your problem.

I am very new to arduino and the C/C++ language.
This code is more or less a scrapbook of example codes found online.

long PrevVal did prove to be redundant so it has been removed from the code.

An increase in delay from 5ms to 500ms yielded the same “90 90 90” results via bluetooth.

I’m trying to measure very sudden and rapid changes in rotation so the sampling frequency doesn’t have much room for alteration. I might be able to justify knocking it down to 100 Hz (10ms) at the very least.

OK. If the 500ms delay doesn't fix it, I guess the problem isn't there.