Skip to content

Latest commit

 

History

History
82 lines (59 loc) · 2.56 KB

File metadata and controls

82 lines (59 loc) · 2.56 KB

Setup

Hardware

Component Connected to
Servo (SG90 / MG90) Raspberry Pi GPIO18 (PWM), 5V, GND
SH1106 OLED (I²C) Raspberry Pi SDA/SCL (GPIO2/GPIO3), 3.3V, GND — addr 0x3C
Arduino Nano Carries the ultrasonic sensor on the servo
HC-SR04 ultrasonic Nano TRIG=D9, ECHO=D10, 5V, GND
HC-05 Bluetooth Nano TX/RX (serial), pairs with the Pi

The HC-SR04 (and Nano) ride on the servo horn so the sensor rotates with the sweep.

1. Raspberry Pi OS configuration

Enable the I²C bus (for the OLED) and confirm Bluetooth is up:

sudo raspi-config        # Interface Options -> I2C -> Enable
sudo reboot

Verify the OLED is detected at 0x3C:

sudo apt install -y i2c-tools
i2cdetect -y 1           # expect "3c" in the grid

2. Python dependencies

This project runs on the system Python. On Raspberry Pi OS (PEP 668 managed environment) install with --break-system-packages:

pip3 install --break-system-packages -r requirements.txt

gpiozero is preinstalled on Raspberry Pi OS; Pillow/smbus2 come from the OS and are pulled in by luma.oled.

3. Pair the HC-05 Bluetooth module

Pair the HC-05 with the Pi (default PIN is usually 1234 or 0000):

bluetoothctl
# scan on
# pair 20:25:05:00:CB:AD
# trust 20:25:05:00:CB:AD
# quit

The MAC is hard-coded in bluetooth.py (BluetoothManager(mac=..., port=1)). Update it there if your module differs.

4. Flash the Arduino firmware

Open nano/scanner.ino in the Arduino IDE (it includes bluetooth.h / bluetooth.cpp), select the Nano board, and upload. It pulses the HC-SR04, median-filters 5 samples, and sends {"d": <cm>} (or -1 out of range) over the HC-05 serial link.

5. Run

python3 main.py

The servo calibrates (0 → 90 → 180°), the background sweep starts, and the radar renders on the OLED. Ctrl-C stops it.

Troubleshooting

  • No module named 'luma' — dependencies not installed; see step 2.
  • OLED blank — I²C not enabled, or wrong address; re-check i2cdetect -y 1 and the 0x3C in display.py.
  • Bluetooth connection fails — module not paired/trusted, wrong MAC, or HC-05 not powered; re-check step 3 and the MAC in bluetooth.py.
  • Servo jitters / wrong range — check the 5V supply and min_pulse_width / max_pulse_width in servo.py.