Skip to content

wiktorczernik/jepson-robot-suite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jepson Robot Suite

Disclaimer: Project's description may be outdated.

Project Goal

The system provides a live video stream from a camera (ESP32-Wrover) and allows remote control of four motors. The Raspberry Pi Pico measures distance using an HC-SR04 ultrasonic sensor and sends the result to the ESP32 via a simple pulse-based signal. Two LEDs are switched using MOSFETs. The ESP32 operates as a Wi-Fi Access Point and an HTTP server, controlling the motors on demand. Communication with the system is handled by a desktop application that sends HTTP requests to the ESP32.

General Operation Description

  • The Raspberry Pi Pico periodically triggers a measurement using the HC-SR04 sensor and calculates the distance (in centimeters).
  • After each measurement, the Pico generates a single-wire pulse whose duration is approximately equal to the measured distance (in milliseconds) on a communication pin.
  • The ESP32 monitors this pin, measures the pulse duration, converts it back into a distance value, and exposes it via the /distance HTTP endpoint.
  • The ESP32 creates a Wi-Fi network (AP) and an HTTP server with the following endpoints:
    • /video (MJPEG stream)
    • /heartbeat (connection status)
    • /motor/use (motor control commands)
    • /motor/stop (stop motors)
  • Motor operation is controlled using PWM functions (analogWrite) on the motor driver control pins. A safety timeout mechanism is implemented to stop the motors if no new command is received within a defined time period.

Used Components

  • ESP32 Wrover with camera support
  • Camera compatible with ESP32 Wrover
  • Raspberry Pi Pico
  • HC-SR04 ultrasonic distance sensor
  • 2× BTS7960 motor drivers
  • DC motors
  • Logic-level MOSFETs
  • 2× LEDs
  • Resistors
  • 2× AG9905LP

Communication Protocol Between Raspberry Pi Pico and ESP32

  1. The Pico measures the distance in centimeters.
  2. It then uses the communication pin, setting it HIGH for delay(distance) milliseconds, then sets it LOW and waits for a short pause of 10 milliseconds.
  3. The ESP32 monitors this pin in a serialTask loop, waits for a HIGH state, measures the pulse duration in microseconds, scales and corrects it to obtain the distance, and stores it in a variable.
  4. The /distance endpoint returns this value as text with two decimal places.

HTTP Endpoints

  • GET /distance – returns a text value representing the distance in centimeters.
  • POST /motor/use – expects one of the following commands in the request body as text: "forward", "backward", "left", "right".
  • POST /motor/stop – stops all motors.
  • GET /heartbeat – returns ALIVE.
  • GET /video – opens an MJPEG video stream.

Startup Procedure

  1. Assemble the wiring according to the schematic.
  2. Power the system using a stable power supply and turn it on.
  3. Connect a computer to the ESP32 Wi-Fi network ESP32-CAM_AP using the password 12345678.
  4. Launch the desktop application, which will establish a connection with the ESP32.

Software Upload Procedure

  1. Assemble the wiring according to the schematic, excluding the communication line between the ESP32 and the Raspberry Pi Pico.
  2. Power the system using a stable power supply and turn it on.
  3. Connect the ESP32 and the Raspberry Pi Pico to the computer using USB cables.
  4. Using, for example, the Arduino IDE (or another suitable environment), upload the software to both the ESP32 and the Raspberry Pi Pico.
  5. Connect the ESP32 and the Pico according to the schematic to establish the communication line.

Software Description

ESP32 Wrover

  • Operates as an Access Point with IP address 192.168.4.1 and runs a WebServer.
  • On startup, all previously mentioned endpoints are registered.
  • For each client requesting video streaming, a separate FreeRTOS task is created, sending JPEG frames in multipart MJPEG format.
  • Distance reading is performed by measuring the duration of the HIGH signal and storing the result in a variable using portENTER_CRITICAL and portEXIT_CRITICAL to ensure thread safety.
  • Functions motorAForward, motorABackward, motorBForward, motorBBackward, motorAStop, and motorBStop control the motors using PWM.
  • The motorSwitchSafeDelay function prevents simultaneous direction switching. If no further commands are received for a defined period, the motors are stopped.

Raspberry Pi Pico

  • Measures distance using the HC-SR04 sensor by generating a 10-microsecond pulse on the TRIG line and reading the ECHO line using a timing function. The distance is then calculated and corrected using an appropriate formula.
  • LEDs are turned on immediately after startup.
  • Distance information is sent to the ESP32 as a pulse on the communication line.

Schematics

Click on the image to open the full PDF file.

About

The system provides a live video stream from a camera (ESP32-Wrover) and allows remote control of four motors.

Topics

Resources

Stars

Watchers

Forks

Contributors