RawHID with an Arduino Micro - communicating with a PC program

Status
Not open for further replies.

davidp

New member
Hi all, this is my first post. Not sure if this is the proper forum to ask this question. If not, then I hope you can guide me in the right direction!

I am using Arduino Micro boards that have an ATmega32u4 chip. I would like to use Nicohood's HID library to transmit data over the USB line rather than using the standard Arduino serial library. The reason is that I would like higher speeds than serial can give me. The serial line (with a baud rate of 115200) maxes out at around 7400 bytes/second. I would like to send anywhere from 8,000 to 10,000 bytes/second.

Nichood's code includes a RawHID library. I have written the following code that runs on my Arduino Micro board:

Code:
#include <HID-Project.h>

uint8_t raw_hid_data[255];

void setup() {
  Serial.begin(115200);
  RawHID.begin(raw_hid_data, sizeof(raw_hid_data));
}

void loop() {
  //Create a 100 byte buffer and fill it
  uint8_t mega_buff[100];
  for (uint8_t i = 0; i < sizeof(mega_buff); i++)
  {
    mega_buff[i] = i;
  }

  //Send the buffer
  RawHID.write(mega_buff, sizeof(mega_buff));

  //Send a character over the serial line
  Serial.print("A");

  //Pause for 1 second
  delay(1000);
}

I have some C# code that I am writing on the PC's end to read in the data. The Arduino Micro shows up with a VID of 32823 and a PID of 9025. I am able to connect to it successfully. I am using the HidSharp library in my code, and developing the application using Visual Studio.

Unfortunately, when I try to read the data from the HID device, it just times out. No data is available to read. I can post some of the C# code if desired.

Any ideas on what I could be doing wrong? Thanks for any ideas!
 
Status
Not open for further replies.
Back
Top