0

I have two PCs: the first is connected to the Arduino via WiFi, this will instruct the Arduino what keys to send, and the second PC is connected to the Arduino via USB that will act as a USB Keyboard for the PC to receive keystrokes. Is it possible to use Arduino Leonardo as a USB Keyboard connected to a PC with WiFi module connected to another PC? Do I need other components or modules for this to work?

I have searched the possibility of keystrokes and WiFi connection as separate projects but can't seem to find a project that has this scenario.

I also consider using Teensy with WiFi module if it is feasible. If this is not possible, are there any workarounds? Or other devices I can use? Thanks in advance.

EDIT: I am also checking Raspberry Pi Zero as an alternative. Is the project more probable with this or is it better to stick with Arduino?

1

Its always very unlikely that someone will have done exactly the same project as you, which is why you need to break it down.

  1. You want to talk to an Arduino over Wifi.
  2. You want he PC to send commands to the Arduino.
  3. You want to make the Arduino act as a keyboard.

I know each of those three parts in on this site, so that should help answer a lot of questions on how to do it, but obviously some of the solutions may conflict so you'll have to discard them.

  1. You can use an ESP8226 - the Arduino talks to it via serial (software serial).
  2. You will need an application (c# will be easiest for Windows) that will send data to the Arduino. You need to design and implement a protocol, using REST may be a good idea.
  3. I've never done it and don't know how, but I think I read there is a HID Library (Human Interface Device aka Keyboard or rat) and that makes thinks easier.

As to what hardware you could use there may well be performance constraints, that affect what hardware you can use. I suspect the lower spec Arduiano's may introduce a lag that may not be acceptable. Since you want to do it over Wi-Fi, you might want to have a look at the ESP8226, which can be programmed like an Arduino and has native Wi-Fi. I'm not sure if you can use it as a HID though.

1

Further to what @CodeGorilla says:

  1. You don't need SoftwareSerial on the Leonardo - the UART pins 0 and 1 are independent of any other hardware and can be used directly without any interference.
  2. The Arduino IDE has Keyboard examples for the Leonardo built in and full software support for the USB interface acting as HID is built in to the API. No need for any extra libraries on that front.
  3. The ESP8266 has no USB interface. It may be able to bit-bang it, but I don't think anyone has written software to do that (it's a horrible thing to do anyway).

So you would use pins 0/1 to talk to an ESP8266 which would be your WiFi interface. The Leonardo can directly talk "keyboard" with the wired PC.

A better choice of host board may be the Pro Micro 3.3V since it runs at the same voltage as the ESP8266 so you don't have any issues of logic level translation. True, it runs at half the speed of the Leonardo, but you're hardly doing any intensive processing here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.