2022/6/20 Updated program: 1. Fixed the problem of the transmitter crashing and restarting due to the fast key press speed, and optimized the pairing connection speed. 2. Receiver: Fixed the problem that the transmitter could not connect to the receiver when it was repeatedly turned on and off for more than four times.
2022/7/2 Please note that the SMD crystal oscillator YSX321SL in the BOM table is 26MHZ, not 12MHZ (the component name has been changed). I just found out today that the name has not been changed. If you make a mistake in purchasing because of this, I am really sorry.
In addition, there is a plan to update the Bluetooth version, but I am working on a claw machine recently, so I have to postpone it. The solution I am thinking of now is esp8266 + Bluetooth transparent transmission module + external antenna. I only need to replace the front panel. This is the idea for the time being.
This project is a wireless remote control pen based on the ESP8266EX wireless chip.
The two devices (receiver and transmitter) are connected via WIFI, and the receiver acts as a TCP Server.
The transmitter is the client, and the two transmit data via the TCP protocol. The receiver identifies the data and passes the corresponding key value to the CH9328 serial port to HID chip through the serial port, which is then uploaded to the computer to complete the simulated keyboard operation.
Note: The project is based on my existing materials.
Finished equipment diagram:
Note: This project consists of two devices. The left side of the figure is the receiver (used to simulate keyboard operation) and the right side is the transmitter (to obtain key operation and transmit data).
The device on the left is another open source project of mine, ESP8266-CH9328 wireless HID simulation device.
It is normal for the left device to heat up when in use.
Please click the video link below to learn more about my project:
1. Video demonstration of CH9328 serial port to HID device controlled by esp8266ex
2. Application demonstration of wireless remote control pen based on ESP8266 Remote control
pen details display:

The remote control pen is powered by a 140ma lithium battery. The power supply voltage outputs 5V voltage (built-in) after passing through the TP5400 charging boost chip, and then outputs 3.3V voltage to power ESP8266 through the 662K step-down chip. You can click on the blue words to learn more about the chip.
When you charge to about 4.1V, under normal conditions (referring to when the device is connected to wifi), the device can work continuously for >=2.5 hours (of course, it depends on your actual use time, I only use it for reference). When the device voltage is too low, the LED brightness will decrease. At this time, you need to charge through the Type-C port.
It takes 6-7 minutes to charge from a low voltage of 3V to 4.1V (here I say that when the voltage is greater than 4.1V, the charging speed will decrease, plus the power consumption of the device, it is a bit unrealistic to fully charge to 4.2V after testing).
(It is normal to heat up during charging)
(Please pay attention to whether the toggle switch is connected to the battery. The switch must be turned on when charging)
(Switching the power back and forth multiple times in a short period of time may reduce the life of the lithium battery) (No normal use)
The receiving range of the two devices: After testing, it is about <=5 meters. It can be connected even farther but it is unstable. (2.0V)
If you want to use this project, please note that the PCB thickness should be >1.2mm. If the thickness is too small, it will cause the PCB to deform when pressing the button.
The design of the program is also crucial. In the last test version, I used a loop to detect the IO port level status to send data, so the device power consumption was very high and the battery could only be used for about 50 minutes. In the new version, I used IO interrupts to send data, so that the device can be used for a longer time. For now, I am still very satisfied.
Then I want to tell you about the program of the device. After understanding, you can quickly modify the program to achieve your own DIY. This means that this remote control pen can not only simulate the control of PPT demonstrated in the video, but also simulate many other key operations. I want to explain how to change these things.
(Here I explain that the code I provided in the attachment has already written the up and down pages, play, and exit of PPT. If there is no other requirement, you can burn it directly)
At the sending end, ESP8266 uses IO interrupts to determine whether the user presses a certain key. If it is pressed, the response event of the corresponding key (io) is called
(the figure shows the interrupt callback of four keys).

When the key is pressed, the interrupt triggers the callback to call the corresponding method and send data to the receiving end through TCP, such as "PageDown" and "ShiftF5" in the figure.
At this time, the receiving end receives the data and enters the judgment method.

Everyone should understand that the receiving end judges the data after receiving it, and then Keyborad.press() a certain key value. This completes the key simulation.
Now let me actually operate how to change the simulated key value and other operations that can be simulated.
1. Change the key value. For example, I want to change the first button, that is, the operation transmitted after pressing btn1, to simulate clicking the button 'A' after pressing it.
First, find the interrupt callback method of btn1 in client.ino, and change
ICACHE_RAM_ATTR void btn1_OnClick(){ client.println(String("PageUp")); }
to
ICACHE_RAM_ATTR void btn1_OnClick(){ client.println(String("A")); }
Then open server.ino, find the writekey() method, and add the content in it as shown in the figure below.

Then burn the corresponding program to the two devices respectively, and press btn1 after powering on and connecting. We will find that
A is successfully pressed as shown in the figure above, but why SHIFT is also pressed. After checking, I know that after

reading the above content, I should have a basic understanding. Then I will talk about what other operations it can perform, giving you a DIY idea.
When the button is pressed, the browser automatically opens to my B station video website.
I won't talk about the program changes on the client side, which have been demonstrated above. I mainly show how the server side simulates this process and gives a video.
Click to jump to the demonstration video, which is quite interesting.
The following are the components not in the BOM table and the precautions for soldering individual components:
2.0V
copper pillars used to fix the power board and the main control board, and the corresponding screws
double-pass M2*7mm copper pillars x4, M2*3mm round head screws x4 (please buy a few more for backup)
fixed around
140ma lithium battery with protection board (it is recommended that you choose a larger capacity lithium battery with appropriate specifications)
x1
power supply
FFC/FPC soft cable 10P; 0.5mm spacing; 6cm
x1
used to connect the power board and the main control board
Precautions:
Please note that only a little tin is needed when soldering the flat cable connector. Don't give too much, otherwise it will be connected. It's useless to blow with a hot air gun or a soldering iron.
The above-mentioned connector and the four buttons on the front should be soldered at a temperature less than 325 degrees, otherwise they will melt.
Please use a lithium battery with a protection board. This is very important. In my design, the charging current is determined by two factors:
one is the resistance value in series with the TP5400 PROG pin, as shown below:

The other is the protection board that comes with the lithium battery.
The part wrapped by the yellow tape as shown in the figure is the protection board.

If you use a lithium battery with a protection board, you only need to set the resistance value of the resistor (R1 in the circuit diagram) to 1K, so that the protection board determines the current size to ensure maximum charging efficiency.
Device burning program, whether it is the receiving end or the transmitting end, they have a row of burning ports, you can burn the device by using a serial port to TTL module.
For convenience, here is another open source project of mine CH340C-TYPEC-Serial Port Burning Tool. Of course, you can choose your favorite burning tool, just connect it to the corresponding hole with a flat cable.
As shown in the figure, the row of 5 holes on the top is the burning hole.
Starting from the square hole on the left, from left to right are: 3.3V, ESP8266_TX, ESP8266_RX, IO0, GND (IO0 must be grounded when powered on to enter the burning mode).

As shown in the figure, the square hole is 3.3V, then the order from right to left is 3.3V, ESP8266_TX, ESP8266_RX, IO0, GND.

Problems found: When burning, the circuit board will heat up slightly. After brushing N times, I found that it did not affect normal use. If you find it very hot when burning, you can check whether the connection is reversed.
Let me briefly talk about how to burn with my CH340C burning tool. Most of these serial ports are converted to TTL like this:
(burning method 1)
1. Insert the corresponding hole

2. Insert the typec into the burning tool, and then insert the other end into the computer USB port, and then power on.

3. Open Arduino, and you can see that there is already a COM display. At this time, click Upload.
If you have any questions during use, you can ask me and I will help you as much as possible.