| 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.
Enable the I²C bus (for the OLED) and confirm Bluetooth is up:
sudo raspi-config # Interface Options -> I2C -> Enable
sudo rebootVerify the OLED is detected at 0x3C:
sudo apt install -y i2c-tools
i2cdetect -y 1 # expect "3c" in the gridThis 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.txtgpiozero is preinstalled on Raspberry Pi OS; Pillow/smbus2 come from the OS
and are pulled in by luma.oled.
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
# quitThe MAC is hard-coded in bluetooth.py (BluetoothManager(mac=..., port=1)).
Update it there if your module differs.
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.
python3 main.pyThe servo calibrates (0 → 90 → 180°), the background sweep starts, and the radar
renders on the OLED. Ctrl-C stops it.
No module named 'luma'— dependencies not installed; see step 2.- OLED blank — I²C not enabled, or wrong address; re-check
i2cdetect -y 1and the0x3Cindisplay.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_widthinservo.py.