07
Oct
Using Peripheral Device to Control Motors using ESP NOW
Parth Agrawal foray communication peripheral device joystick keyboard esp nowI was looking for ways to control the motors using peripheral hardware. I initially used Keyboard to control the motors. The input characters were sent to an ESP32 device (Master) via serial communication. The data was sent to another ESP32 device (Slave) connected to the motor drivers. I used a 2.4 GHz ESP NOW protocol for communication.
I further used a game controller to control the motors. I am using a python script to read the input from the controller and redirect it to a serial port connected to an ESP32 device (Master).
Key Observations
- Different controllers have different drivers which leads to different behaviors for the same python script. In my case, pygame was able to read the input from the game controller. Inputs library was not able to read the input from the game controller. More libraries support popular game controllers like PS and Xbox controller.
- ESP NOW has to be preconfigured with the MAC address of the slave device. To switch the control from one blimp to another, we simply need to change the MAC address of the destination in the packet. NodeMCU also supports ESP NOW protocol.
- Sometimes, the value read by the ESP32 over serial port is incorrect. I need to find the source of the bug.