HID Relay, wired keyboard to Bluetooth project learning: remember a failed attempt

HID Relay, wired keyboard to Bluetooth project learning: remember a failed attempt

After starting to learn embedded, one of the most uncomfortable points is that there are not enough computer ports. My computer has two USB ports and one TypeC port. The mouse and keyboard must be plugged into the USB port, and the stm32 and 51 must also be plugged into the USB port.

Then when burning, either unplug the keyboard and burn first. If the code is wrong, plug in the keyboard to type again, then unplug it to burn, plug in the keyboard again to type, and then unplug it.

Later, I bought a second-control keyboard, but the feel is far worse than my alice.

How do you know my keyboard is ACR Pro Alice Plus?

I don't want to buy a new mouse and keyboard (not even a computer). Coincidentally, I found an embedded predecessor who had the same idea, and he developed a wired keyboard-to-Bluetooth device.

image-20230506042504272

The main development board used is arduino pro mini. If done, it would be my first experience making a project successfully. So I think this interesting project is well worth a try.

So I started from buying chips, hardware, and electric soldering iron, went to the hardware store countless times, soldered several rows of pins, and even suffered the double price of burns and punctures on my left thumb, and finally——

I failed.

Semi-finished product display

Why do we have to talk about it when we fail, instead of improving it better, or trying to achieve success?

Because May is really busy. In addition to the homework requirements in the course, there are many extracurricular activities, large and small, the code to be written, the video to be made, the test to be tested... I know that I really don't have time to spend on fixing him, at least for now .

But this is my first project, and even if it fails, this little thing is worth a lot to me. And I also learned a lot from it.

So I decided to write down this "failure" experience summary to put a semicolon for him temporarily. Maybe one day in the future, if I am more capable, I can dig out this gadget from the cardboard box, fix him, and complete this article.

Original video link

material selection

  1. Main development board: arduino pro mini, 3.3V. Compared with the arduino boards I have played before, the pro mini is small in size and low in power consumption. Using it to design a wired keyboard Bluetooth converter is not only compact, but also saves power.

    The Arduino Pro Mini board

  2. The USB Host Shield 2.0 expansion board provides a usb interface, allowing arduino, etc. to have usb host functions, such as connecting a mouse, keyboard, and U disk. There is also a spi interface, which can be used for communication.

image-20230506043809303

  1. FT232RL, a commonly used USB interface conversion IC produced by FTDI Company. It can convert the USB interface into a standard serial interface.

image-20230506044149507

  1. Bluetooth module.

image-20230506044233998

  1. Breadboard, breadboard power supply module.

schematic diagram

Brief principle:

image-20230506044916586

First of all, the mini board cannot communicate with the computer. We need to use FT232RL as an intermediary to convert the USB interface of the computer into an IC serial interface that arduino can receive. In this way, communication burning can be carried out.

Then the input data from the keyboard cannot be directly sent to the arduino. We can convert the data through the USB Host Shield, and also convert the data into a serial interface type that can be received by the USB.

welding

Image source: USB Host Shield Mini with USB support added to the module - schaepher - 博客园 (cnblogs.com)

img

First, cut off the Vcc-2k2 part of the USB Host Shield, and then connect it to the arduino.

image-20230506045308088

Why do you do this? Our keyboard needs to be powered by 5V, but the Vcc of the USB Host Shield is connected to 3.3V, so we need to disconnect it and connect it to the 5V pin on the arduino.

Therefore, solder the hole above Vcc, connect a wire to lead out, and connect to arduino in a while.

image-20230506045521692

  1. For arduino pro mini, just solder all the pin headers directly, and plug it right in front of the USB Host Shield. The wire is connected to the RAW pin in the lower right corner.

image-20230506045654918

  1. Connect FT232RL and Arduino Pro mini with six female-to-female Dupont wires. Or solder a row of pins like the picture.

image-20230506045806972

  1. Insert the lower pin header of Arduino Pro mini into the breadboard, and connect the breadboard with 3.3V power supply.

image-20230506050012950

RAW and GND are drawn out and connected to 3.3V and GND. If both the FT232 and the arduino are on, and the arduino still has a flashing light, it means that the programming is ready. (Connect the USB Host Shield to a wired keyboard)

burning

Code download:

https://github.com/felis/USB_Host_Shield_2.0

  1. Unzip the code package to the libraries folder under the arduino folder.

    image-20230506050236487

  2. Turn on the arduino, and open the project in the example:

image-20230506050413479

image-20230506050431597

  1. Link the computer and FT232, and download the program. During the downloading process, the yellow light on the FT232 will flash wildly, and the download is successful after the flashing.

image-20230506050656593

Open the serial port:

image-20230506050742302

Oh~ I failed here. If it is running normally, start should be displayed, and the key information will be output in real time after the key is pressed.

image-20230506050905781

to reflect

My question here may be many. Because the button information is not output after pressing the button, it is not just the problem of garbled characters on the serial monitor, but also the problem of the link circuit, which makes the data transmission error.

But through this attempt and record, at least I learned how to use the electric soldering iron, and I have a certain understanding of these hardware. If you have a chance in the future, you can learn from a separate module, and then study the code logic on the project, and gradually investigate the cause of the problem~

Good night, HID Relay.

Guess you like

Origin blog.csdn.net/jtwqwq/article/details/130518600