How anandchauhan21/esp_101 works
Project type & purpose (from file tree + README)
This repo is an embedded/robotics starter kit centered on ESP32/ESP8266 development, demonstrating:
• Sensor integration (notably ultrasonic distance sensing: ultrasonicTest.py, obstacle avoidance: Obstacle_Avoidance.py)
• Actuator control (motors, servos, buzzer, LEDs: motortest.py, two_motor.py, servoTest.py, buzzerTest.py, ledTest.py)
• Robot behaviors (square path, obstacle avoidance: square_path.py, Obstacle_Avoidance.py, sugarTank1_1.py)
• Concurrency (threading: multithread.py)
• Wi‑Fi control / connectivity (hinted by root esp32_wificar.py)
So your “system” is not just software modules: it is physical hardware + firmware/app logic + optional networked controller/client.
What the file structure implies architecturally
Top-level:
• sugarTank/: a robot/tank platform with many focused scripts:
• *Hardware test utilities*: *_Test.py (LED, buzzer, servo, ultrasonic, motor)
• *Motion primitives*: two_motor.py, square_path.py
• *Behavioral logic*: Obstacle_Avoidance.py, sugarTank1_1.py
• *Concurrency*: multithread.py
• media/, sugarTank/README.md: project docs/assets
This suggests a module-per-feature style typical of embedded learning repos:
• Low-level GPIO/PWM driving modules
• Sensor read modules
• Higher-level behavior scripts composing those primitives
• Optional communication layer (Wi‑Fi)
Microcontroller Firmware (Python/MicroPython script)
• Entry scripts: sugarTank1_1.py, Obstacle_Avoidance.py, square_path.py, esp32_wificar.py (depending where it runs)
Hardware Abstraction / Drivers
• GPIO/PWM control for motors/servo/LED/buzzer
• Ultrasonic timing/echo measurement
Control / Behavior Layer
• Obstacle avoidance logic, path-following, motion primitives
Networking Layer (Wi‑Fi)
• Command receiver / telemetry sender (if used)
Physical Components
• Motor driver (H-bridge), motors, servo
• Ultrasonic sensor (HC-SR04 style)
• LED, buzzer
Key point: for embedded projects, showing signals matters:
• PWM lines to motors/servo
• Digital IO to LED/buzzer
• Trigger/Echo lines for ultrasonic
• Wi‑Fi as a separate communication channel
Suggested components (labeled with file names):
• Obstacle_Avoidance.py → ObstacleAvoidanceController
• depends on UltrasonicSensor
• commands MotorController
• square_path.py → PathPlanner (SquarePath)
• commands MotorController
• two_motor.py / motortest.py → MotorController / MotorTestHarness
• servoTest.py → ServoController / ServoTestHarness
• ultrasonicTest.py → UltrasonicSensor / SensorTestHarness
• buzzerTest.py → BuzzerController
• ledTest.py → LEDController
• multithread.py → Scheduler/Concurrency Wrapper
• Separate loops/tasks: sensor polling, motor control, networking
Test scripts explicitly as “diagnostic mode” components; they are part of how the system is operated and validated.
• ObstacleAvoidanceController → MotorController: “set speed(left,right)”, “stop()”, “turn()”
• UltrasonicSensor → ObstacleAvoidanceController: “distance_cm”
• Wi‑Fi Command Handler → Behavior Layer: “manual drive command”, “mode switch (auto/manual)”
• Behavior Layer → Actuators: PWM duty cycle, direction pins, servo angle
• Sensor polling task → shared state (if multithreaded): show concurrency boundary and synchronization assumptions (even if simplistic)
• ESP32 → Cloud endpoint: HTTP/MQTT telemetry (mark as optional / future)
Architectural patterns/design principles present (or implied)
• Layering: Behavior → Drivers → Hardware
• Composition over inheritance (typical scripting style): behavior scripts compose sensor + motor primitives
• Mode-based operation: “test mode” vs “autonomous mode” vs “manual/Wi‑Fi mode”
• Concurrency (explicit via multithread.py): separate loops for responsiveness
Labels
• Signal/protocol: PWM, GPIO, Wi‑Fi (HTTP/MQTT/TCP/UDP), thread queue/shared state
• Payload: distance_cm, motor_speed, steering_angle, command JSON, etc.
“Don’t overthink it” detail strategy (as requested)
Break into as many components as possible by following this rule:
Panel A — System Context
• User ↔ Phone/Laptop Controller ↔ Wi‑Fi AP ↔ ESP32 Robot
• Optional: ESP32 ↔ Cloud Endpoint
Panel B — Hardware + Firmware
• ESP32
• GPIO/PWM → Motor Driver → Left/Right Motors
• PWM → Servo
• GPIO → LED
• GPIO → Buzzer
• GPIO (Trig/Echo) ↔ Ultrasonic Sensor
• Power → ESP32 + Motor Driver (noting shared ground)
Panel C — Software Components (file-mapped)
• Main behavior: sugarTank1_1.py (if it is the main integrator)
• Controllers: Obstacle_Avoidance.py, square_path.py
• Drivers/tests: two_motor.py, motortest.py, servoTest.py, ultrasonicTest.py, ledTest.py, buzzerTest.py
• Concurrency: multithread.py
• Wi‑Fi control: esp32_wificar.py (with a note “runs on ESP32” or “runs on host” depending on confirmation)