2026-07-20 02:15:37 +00:00
# linefollower_eye
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
ESP32-S3 camera board that finds a coloured blob and reports its position over I2C. Meant to sit on a robot as the “eye”, with something like a Pico as the master.
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
## What it does
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
The ESP runs HSV blob detection on the camera. A MicroPython master can turn the camera on, set colour, and poll for a target. Optionally it can join Wi‑ Fi so you can open a browser page to tune the colour live.
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
Target position from `read_target()` is relative to the image centre (320x240). Positive x is right, positive y is up. No target returns `None` .
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
## Hardware
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
ESP pins for the I2C slave:
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
- SDA: GPIO19
- SCL: GPIO20
- Address: 0x42
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
Example Pico wiring:
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
- GP0 (SDA) -> ESP GPIO19
- GP1 (SCL) -> ESP GPIO20
- GND shared
- Use external pull-ups on SDA/SCL (about 2k2– 4k7 to 3V3)
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
Camera and Wi‑ Fi stay off until the master enables them.
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
## Firmware
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
ESP-IDF project for ESP32-S3. Build and flash as usual:
2026-07-17 06:52:46 +00:00
```
2026-07-20 02:15:37 +00:00
idf.py build
idf.py -p PORT flash monitor
2026-07-17 06:52:46 +00:00
```
2026-07-20 02:15:37 +00:00
## MicroPython master
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
Files live in `mp_i2c_master/` . Copy `vision.py` (and `main.py` if you want the demo) onto the board.
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
```python
from vision import Vision
import time
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
eye = Vision(sda=0, scl=1)
eye.start()
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
# Optional: browser UI for tuning colour
# eye.set_wifi("YourSSID", "YourPassword")
# print(eye.wifi_ip())
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
while True:
t = eye.read_target()
if t is None:
print("no target")
else:
x, y = t
print(x, y)
time.sleep(0.1)
```
Useful calls:
- `eye.start()` — camera on and local detection
- `eye.set_hsv(h, s, v)` / `eye.set_tolerance(...)` — colour (or tune in the browser)
- `eye.set_wifi(ssid, password)` / `eye.wifi_off()` / `eye.wifi_ip()`
- `eye.read_target()` — `(x, y)` or `None`
## Web UI
After Wi‑ Fi is up, open the ESP’ s IP in a browser. You get the live image, colour picker / eyedropper, mask options, and timing. Colour changes there are what the I2C master reads next.
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
## Other folders
2026-07-17 06:52:46 +00:00
2026-07-20 02:15:37 +00:00
- `pc_vision/` — older desktop viewer; the on-device web UI replaces it for tuning
- `main/` — ESP firmware