esp32esp8266micropython

Why Micropython doesn't support any of the keypress modules like pygame/pynput/keyboard.?


I have been trying to work logics on esp8266 and esp 32 via micro python and it turns out that micro python does not let you control the hardware fully with your keyboard.

It is inconvenient to press enter after every command on a serial port and impractical in autonomous applications like robots and drones where there is an infinite while loop running on milliseconds and asking for keypress event


Solution

  • If you want to use keyboards directly to your microcontroller, you either need to support USB or PS2 protocol. To understand why have a look at Ben Eaters comprehensive youtube videos on the two subjects: USB and PS/2

    Your microcontroller is connected to your pc via the terminal, so do not count your computer keyboard as connected to your microcontroller.

    If you want to interface with a remote drone, or other peripheral where you don't want the actual interface to be the terminal prompt (which uses the enter key as the send character), you would have to write an application that handles the keyboard interaction, or touch events on a mobile app, or a joystick/joypad input, and then sending the commands to the device afttwerwards, without waiting for enter or other control characters... that application could be written in regular python using the mentioned libraries, and the appropriate python libraries to send stuff via the terminal. You may also choose to use serial over bluetooth.

    Furthermore, if you want to ensure that the wireless (wifi/bluetooth/433mhz/2.4gz) communication is not intercepted or interrupted/replayed, consider if you would need to encrypt the communication.