0

I am trying to send data which is appearing on Arduino IDE serial monitor to an Android app Blueterm via Bluetooth module HC-05. After connecting HC-05 sends data only for 2sec, even though app shows "connected HC-05".

I need to send data for at least 3 minutes continuously.

#include <MPU6050_tockn.h>
#include <Wire.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1); 
MPU6050 mpu6050(Wire);
void setup() {
  mySerial.begin(9600);
  Serial.begin(9600);
  Wire.begin();
  mpu6050.begin();
  mpu6050.calcGyroOffsets(true);
}
void loop() {
  mpu6050.update();
  mySerial.print("angleX : ");
  mySerial.print(mpu6050.getAngleX());
  mySerial.print("\tangleY : ");
  mySerial.print(mpu6050.getAngleY());
  mySerial.print("\tangleZ : ");
  mySerial.println(mpu6050.getAngleZ());
}
BSMP
  • 4,596
  • 8
  • 33
  • 44
tpg1
  • 1
  • any reason why you use SoftwareSerial on the UART pins 0 and 1? that doesn't make too much sense to me – Piglet Apr 15 '19 at 13:00
  • @Piglet those are pins for data transmission 0-Rx pin & 1-Tx pin on arduino uno which are connected to Tx & Rx pins of Bt module HC-05 respectively for data transmission. (Rx of arduino to TX of hc-05 and Tx of Arduino to Rx of Hc-05) – tpg1 Apr 16 '19 at 09:06
  • I know that. But they are the hardware UART pins, using them with SoftwareSerial makes no sense. Just use Serial – Piglet Apr 16 '19 at 11:22
  • It might be problem with wire library. It goes onto infinite loop while waiting for data. – anilkunchalaece Apr 20 '19 at 06:50
  • @anilkunchalaece what's the solution then..? – tpg1 Apr 29 '19 at 09:34
  • instead of using mpu6050 library try to directly read MPU6050 registers. Check readMpu function in https://github.com/anilkunchalaece/arduQuad/blob/master/ArduinoCode/ksrmQuadLevelModePlusConfig/ksrmQuadLevelModePlusConfig.ino – anilkunchalaece Apr 29 '19 at 10:27

1 Answers1

0

I don't think its a problem in your module (If you not sure then you can check Status Pin). I suggest you to check the android app, Check these :

  • If there is any time out in android app
  • If app get large data collection at once. (If so Android Stop receiving by killing the receiving process. For that, you can add delay between Gyro data )
No One
  • 109
  • 10