Skip to content

Add local WebSocket relay server and ESP32 ultrasonic firmware example#4

Draft
musfaagv wants to merge 1 commit into
mainfrom
codex/add-websocket-server-and-firmware-example
Draft

Add local WebSocket relay server and ESP32 ultrasonic firmware example#4
musfaagv wants to merge 1 commit into
mainfrom
codex/add-websocket-server-and-firmware-example

Conversation

@musfaagv
Copy link
Copy Markdown
Owner

Motivation

  • Provide a simple local WebSocket relay so an ESP32 firmware example can send sensor data to a web UI and receive commands over the local network.
  • Standardize a compact JSON payload format for ultrasonic sensor data and LED commands for easier integration and testing.
  • Offer a ready-to-run Python server and a matching ESP32 sketch to help users prototype without needing external infrastructure.

Description

  • Add example_websocket_server/server.py implementing a relay server (listens on ws://0.0.0.0:8765) with a connected-client registry, broadcast to other clients, payload parsing/validation, and structured error responses for invalid JSON or unknown message types.
  • Add example_websocket_server/requirements.txt (websockets>=14.0,<16.0) and example_websocket_server/README.md with setup and run instructions (e.g. python -m venv .venv, install deps, python server.py).
  • Add ESP32 firmware sample example_firmware/esp32_ws_ultrasonic/esp32_ws_ultrasonic.ino that connects to configurable Wi‑Fi and ws://<IP_LAPTOP>:8765, reads HC-SR04 distance (cm/inch), sends periodic JSON sensor payloads, and processes {"type":"led","state":"on"} / {"type":"led","state":"off"} commands to toggle a GPIO LED.
  • Update example_firmware/README.md with configuration steps (SSID/password, laptop IP), pin mapping, payload examples, dependency notes, and server run steps.

Testing

  • Ran python -m py_compile example_websocket_server/server.py which completed successfully.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant