The project implements wireless macro keyboard. For wireless connectivity ESP-NOW communication protocol is used and not bluetooth or Wi-Fi. So you don't need Wi-Fi router or Bluetooth dongle.
Two small size ESP-32 microcontrollers dev boards have been used. ESP-32 has builtin wireless capabilities. One acts as USB dongle to be connected to PC. And the other as wireless macropad.
- Two mini ESP-32 microcontrollers. Buy two of any of the following or buy one of each of the following:
- IR Remote Control Sensor Module. In this project, for keypad I am using IR remote. You can use touch key pad (TTP229) or 4x4 key module instead
- 10k ohm potentiometer with knob.
- For key press feedback
- 5v active buzzer
- BC547 NPN transistor
- Two 100 ohm resistors
- 1N4007 diode
- For ESP-NOW connectivity indicator
- 3mm Blue LED
- 1k resistor
- To power keyboard part tpe-c USB power cable, 5v power bank, or 18650 batteries with LM7805 LDO.
It is assumed you already have following tools:
- Soldering tools, soldering iron etc.
- Type-c male USB data cable
- NodeJS installed
- Arduino IDE with ESP32 setup
Solder the buzzer to GPIO pin 6 as follows:
Solder IR receiver and potentiometer as to other ESP32 follows:
You can power the device using USB type-c power cable or 5V 18650 batteries module.
The dongle ESP32 is connected to PC over USB serial port. It receives commands over esp-now wifi protocol from other ESP32 macro boards. Received commands are sent to pc-serial-macro-server over the serial port. The receiver dongle also receives commands from PC to be executed on its GPIO pins. You can achieve other automation using GPIO pins on the dongle ESP32 :nerd:. For example, you could drive a relay to run electrical appliances. For now the code uses commands to make sounds on buzzer module.
First we need to find MAC address of the dongle ESP32 device. At the end of esp-now-usb-pc-dongle.ino file there is commented code that prints MAC address. Upload the code to the dongle ESP32 and note down the MAC address. The macropad will send user button presses to the dongle on this MAC address.
If required update the esp-now-usb-pc-dongle.ino
file as per your ESP32 dev board then upload the code to the dongle ESP32.
Connect the dongle to an USB port where you are going connect it permanently. Note down the COM/USB port, e.g COM6
on Windows and /dev/ttyUSB0
on Linux.
Open pc-serial-macro-server directory in command prompt. Run following command:
npm install
Depending on your OS edit pc-serial-macro-server/scripts/start-serial-macro-server.bat|sh
script.
On Windows add it to Task Scheduler to run it on user login.
On Linux add command shortcut in .bashrc
to run the shell script. After login run the shell script to start the NodeJS server.
Run the server using the script file or following command:
node index.js <dongle com/usb port>
Edit esp-now-ender-macropad.ino file as per your device and update the pin numbers. Update MAC address of the dongle ESP32. Upload the code to the macropad ESP32.
Connect the dongle to PC. Then start the PC macro server. Power the wireless macropad.
Now monitor the PC macro server logs. Press all the keys on the remote control one by one and note down the key codes. Also, get the MAC address from the logs and update it in pc-serial-macro-server/index.mjs
file (update trustedDevices
variable).
Edit pc-serial-macro-server/commands/linux.json
or window.json
and update key codes as you like. Don't touch set_volume
key. Restart the PC macro server.
Restart the PC macro server to make changes live.
Other similar projects: