Page 1 of 1

Requesting help in interfacing raspberry pi with android via bluetooth hc-05 module

Posted: Tue Apr 23, 2019 3:17 pm
by Majinranga
Hello all,
My project is designing a smart system with gesture control using raspberry pi. However for gesture control i have used accelerometer and arduino leonardo i want to interface it to raspberry pi using hc-05 bluetooth module and make my gesture control work on raspberry pi. Any help is appreciated.

Thank you

Re: Requesting help in interfacing raspberry pi with android via bluetooth hc-05 module

Posted: Tue Apr 23, 2019 6:30 pm
by Douglas6
You'll need to configure the Serial Port Profile on the Pi, and create a virtual serial device using rfcomm. There are instructions in this forum which a search should reveal.

Re: Requesting help in interfacing raspberry pi with android via bluetooth hc-05 module

Posted: Wed Apr 24, 2019 6:00 am
by Majinranga
Douglas6 wrote:
Tue Apr 23, 2019 6:30 pm
You'll need to configure the Serial Port Profile on the Pi, and create a virtual serial device using rfcomm. There are instructions in this forum which a search should reveal.

Code: Select all

#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>
#include <Mouse.h>

MPU6050 mpu;
int16_t ax, ay, az, gx, gy, gz;
int vx, vy, vx_prec, vy_prec;
int count=0;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  mpu.initialize();
  if (!mpu.testConnection()) {
    while (1);
    }
}

void loop() {
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

  vx = (gx+300)/200;  // 
  vy = -(gz-100)/200; // 
  
  Mouse.move(vx, vy);
}
this is the code i have burned to arduino for making the air mouse when connected through wire it works fine how do i perform the same function wireless using hc-05 module should i make any changes in the code ?? I tried the method suggested above but i am not able to work using it.

update: i have connected it via serial connection on rfcomm0 and in bluetooth section it shows device can be used.

Thank you in advance.

Re: Requesting help in interfacing raspberry pi with android via bluetooth hc-05 module

Posted: Wed Apr 24, 2019 12:27 pm
by Douglas6
I'm sorry, I did not initially understand your goal. It appears you want to use the Arduino as a HID (mouse). The HC-05 module can't do that. I'm told that the firmware of the HC-05 can be reprogramed to provide HID functionality, but that is left as an exercise for the reader (here's an instructrable: https://www.instructables.com/id/3-Blue ... -Firmware/. It appears you'll need a PC with a parallel port, good luck there.) It might be cheaper and easier to purchase a Bluetooth module with HID capabilities.

Alternatively you can send coordinates over a serial connection, and generate mouse movements on the Pi, but again, I can't help you there.

Re: Requesting help in interfacing raspberry pi with android via bluetooth hc-05 module

Posted: Thu Apr 25, 2019 10:22 am
by Majinranga
Douglas6 wrote:
Wed Apr 24, 2019 12:27 pm
I'm sorry, I did not initially understand your goal. It appears you want to use the Arduino as a HID (mouse). The HC-05 module can't do that. I'm told that the firmware of the HC-05 can be reprogramed to provide HID functionality, but that is left as an exercise for the reader (here's an instructrable: https://www.instructables.com/id/3-Blue ... -Firmware/. It appears you'll need a PC with a parallel port, good luck there.) It might be cheaper and easier to purchase a Bluetooth module with HID capabilities.

Alternatively you can send coordinates over a serial connection, and generate mouse movements on the Pi, but again, I can't help you there.
Thank you again for your reply i understood the problem with using hc 05 but the second method you suggested seems to be the solution and now i am transferring the data over serial connection i.e Vx and Vy to raspberry pi but would like to have a insight on how the data can used to generate mouse movements.

Can i perform the function using esp8266 ??

Re: Requesting help in interfacing raspberry pi with android via bluetooth hc-05 module

Posted: Thu Apr 25, 2019 12:01 pm
by Andyroo
Adding another device in is not needed once you have the data on the Pi - you can use xdotool:
What is xdotool?
This tool lets you simulate keyboard input and mouse activity, move and resize windows, etc. It does this using X11’s XTEST extension and other Xlib functions.
Taken from https://www.semicomplete.com/projects/xdotool/