Skip to content

Control an esp32 robot with Oxenode client scripts through WebSockets

License

Notifications You must be signed in to change notification settings

matiasvlevi/esp32-ws-car

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esp32-ws-car

This is proof of concept for my upcoming project Oxenode.

Repository contains:

  • An esp32s3 firmware. Provides a set of commands called through websocket buffers, allowing a web client to control the device. See more

  • An Oxenode plugin. Provides bindings for sending instructions through websockets. Acts as a web client to the esp32 firmware. See more


Robot & Hardware

The firmware is meant to be used with an ESP32-S3-DevKitC-1, wired to a l298 motor controller and an HC-SR04 ultrasound sensor.

Close Up Top View

Oxenode Client Script

Plugin CDN

https://cdn.jsdelivr.net/gh/matiasvlevi/esp32-ws-car@latest/oxenode/esp32-ws-car

Websocket creation

We first need to establish a connection with our end device.

mbot-begin

We can use the Websocket Create node from the oxenode-std-ws plugin to create a reference to a websocket and store it in a global variable.


Key down event (WASD controls)

We can use a Switch node to match keys to motor websocket commands

To prevent spamming our end device with the same commands, we add an if codition checking if the key was repeated.

mbot-key

notice that we need to supply the socket reference since the nodes in this plugin use WebSockets under the hood.


Key up event (Stopping motors)

Do not forget to add a way to stop.

mbot-key

We send a brake command to the end device when the user releases a key



License MIT