Go Down

Topic: RN-42 Bluetooth HID Mouse (Read 11208 times) previous topic - next topic


Feb 02, 2012, 08:41 am Last Edit: Feb 02, 2012, 08:44 am by MobileWill Reason: 1
I just recieved a BlueSmrif in HID mode and trying to get it to act like a mouse


I don't quite understand what to send to send a mouse event.

I can get keyboard to work and send text and codes like backspace and volume up just fine. Just confused about the mouse part.

I have it in HID mouse mode now.

Thanks for any help.


Here is what it has for mouse

0xFD 5 bytes 0x2 Buttons X-stop Y-stop Wheel

I get the FD, the 5 bytes is for Length not sure so should it be  0x05? And then the rest I take it would be a hex value for each? I am not sure what the value would be for Buttons X, Y and Wheel

There is an example of a keyboard press and that is

0xFD 0x03 0x03 0x00 0x10 for keydown
0xFD 0x03 0x03 0x00 0x00 for keyup


In case anyone finds this and wants to know the solution.

I was using binary instead of the hex value. The manual needs to be more clear. So for mouse mode I used 0020 and it worked ;) Other stuff to figure out still, like what the range is for the cursor movement and how to map that to a absolute position.


like what the range is for the cursor movement and how to map that to a absolute position.

The range is, in theory, unbounded. Of course, the actual position is stored in a variable of some type that imposes limits. The absolute position must be determined by adding all the + movements and subtracting all the - movements.
The art of getting good answers lies in asking good questions.


Hello, I was wondering if you could tell me how you send the hid reports to the bluesmirf. I have been trying to send the report through the uart connection from a terminal window. Instead of the module interpreting the report it justs sends each character as a key press.
I have sent 0xFD 0x9 0x1 0x0 0x04 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 to the module which the manual says will send an event that the "a" key has been pressed.


The terminal won't work, you need a terminal program that can send hex values. I use hterm

There are others like this one


Let me know if you get it work or anything else you need. It was a pain but works great once you get it working.


Thanks, that worked nicely. I've got my arduino sending events to it now as well.

My only problem with it now is that it does not send back any feedback after sending it any commands. It goes into command mode with $$$ but it doesn't send back the CMD response. I changed the name of the module with the SN command but it does not send back AOK even though the name was successfully changed.

Anyway, at least I know how to send events to it now.


It should. I had to play with the CR and LF in the terminal app. Sometimes it wants it and others it whats no feed. really odd. Its picky.

I am still trying to figure out a way to translate x,y to be able to send absolute values or at least keep it in sync.


Should be nothing sent after $$$ but all other commands expect a new line. At least thats what it looks like since the commands are executed I just don't get any feedback.
I've sent mouse x and y values from my arduino with byte( val );
I tested it out with this:

  buffer[0] = 0xFD;
  buffer[1] = 0x05;
  buffer[2] = 0x02;
  buffer[3] = 0x00; //Buttons
  buffer[4] = byte( random( 1366 ) ); //X-stop
  buffer[5] = byte( random( 768 ) ); //Y-stop
  buffer[6] = 0x00; //Wheel
  Serial.write( buffer, 7 );

Have you gotten your module to auto connect after a power cycle?


Really that works? I thought x and y were only distance to move. At least that is how it seems to work for me.
What mode are you using for hid?

No and I thought it was supposed. I ended up having the Arduino send a connect command on startup.works well enough.


Your right, x and y seem to be relative distances. I think I was just moving it so far that it wrapped around maybe?
I don't see any way to set an absolute position. I have it in mouse mode for now.


I am working on a way to translate absolute to relative. The mouse when connected to my phone starts in the middle so just have to track from there. I am testing using processing and just jumping to where I click the mouse. So far its not working so well. I think you can only move so far per command. So I tired to move in smaller jumps to the click location but still not working right.

I think mine is in combo mode. On my phone it won't wrap but I didn't try on a computer.

Haven't had a chance to get back to this project, really need to get this working so I can work on the touchscreen part.


You can only make small jumps since we only have a byte to store the position. Also my code "byte( random( 1366 ) )" doesn't make any sense since the maximum value would be 256, and since its signed the range is -127 to 127. And that would be why you can only move small distances at a time.


Have you gotten your module to auto connect after a power cycle?

HI guys!
For autoconnect you need to put the device in pair mode. You can get that mode by sending the command "SM,6" on the uart. In this mode the module will pair up with the last device. Works well for me.


I am facing this problem with this module -
Code: [Select]

void setup()

void loop()

Now when i try to see this on the serial window, I get
and so on..
A lot of characters are lost
When i do this with a SPP module by bluesmirf, I get all the characters.
Any idea why this might be happening?

Go Up