Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: RawHID with an Arduino Micro - communicating with a PC program

  1. #1
    Junior Member
    Join Date
    Jan 2018
    Posts
    1

    RawHID with an Arduino Micro - communicating with a PC program

    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!

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,595
    Maybe ask on Arduino's forum? You are using an Arduino brand board, afterall.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •