RN-42 HID

Warning

This page and code linked within it are being developed on an internal beta site, so some parts may not (yet) be visible! Will be soon...

Getting the RN-42-HID module running...

Homepage:

Manuals:

First Hello World Test

Default serial port settings from UM 3.2:

  • Baud rate 115,200
  • 8 bits
  • No Parity
  • 1 stop bit

Basic commands

  • Enter CMD mode: $$$
  • Exit CMD mode: ---<cr>

Simple test program:

Import program

00001 #include "mbed.h"
00002 
00003 Serial RN42(p9, p10);
00004 Serial pc(USBTX, USBRX);
00005 
00006 DigitalOut RN42_led(LED1);
00007 DigitalOut pc_led(LED2);
00008 
00009 int main() {
00010 
00011     RN42.baud(115200);
00012     pc.baud(115200);
00013 
00014     while(1) {
00015         if(pc.readable()) {
00016             RN42.putc(pc.getc());
00017             pc_led = !pc_led;
00018         }
00019         if(RN42.readable()) {
00020             pc.putc(RN42.getc());
00021             RN42_led = !RN42_led;
00022         }
00023     }
00024 }

With teraterm, sending $$$ did enter command mode!

On iPhone, enabled bluetooth, it searched for devices, found FireFly-0EBB (initially called Keyboard). Clicked on it and it connected! Openned up notes, and can type characters, appearing on iphone.

Also managed to connect on windows. Devices & Printers, Add Device

To make it look like a mouse:

  • SH,0220


3 comments on RN-42 HID:

23 Aug 2012

Hello Simon, I got RN42 HID module yesterday and I was doing some testing. I successfully used commands to change profile from SPP to HID, tried pairing from PC via BT dongle with RN42 as keyboard, mouse, joystick. This worked for me fine.

When RN42 was acting as keyboard and I was using serial passthrough (as in example above) from teraterm through mbed to RN42 and was typing characters on terminal they was appearing in text document on target PC which was connected to RN42 via Bluetooth. This was very easy to do.

But when I switched RN42 to be mouse and after successfull pairing with target PC I was thinking that sending data in RAW mode (as described in http://www.rovingnetworks.com/resources/download/120/HID_User_Manual on page 8) will be easily done and I made this program.

#include "mbed.h"

Serial RN42(p9, p10);
Serial pc(USBTX, USBRX);


uint8_t start = 0xFD;
uint8_t length = 0x05;
uint8_t desc = 0x02;

uint8_t buttons = 0x02;
uint8_t x = 0x20;
uint8_t y = 0x20;
uint8_t z = 0x00;


int main()
{

    RN42.baud(115200);
    pc.baud(115200);

    wait(5);

    while(1) {

        RN42.printf("%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",start, length, desc, buttons, x, y, z);
        //pc.printf("%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n\r",start, length, desc, buttons, x, y, z);

        wait(1);

    }
}


But the mouse never moves cursor on target PC. So I would like to ask You if You was more successfull than me, can You please help me?

23 Oct 2015

I WANT ASK YOU ,as you say you use bluetooth dongle but this dongle is SPP or HID profile.

09 Feb 2018

Has anyone got this working as a Keyboard AND Mouse ??

I am designing a new product, that needs to send mainly mouse move, mouse button, scroll, As well as about 8 keyboard keys.

A Circuit diagram would be nice too :)

Cheers

Ceri

Please log in to post comments.