Tick off the hardware components you have on your desk right now:
Goal: Wire the optical mouse sensor to the Pico 2WH and verify that it communicates over SPI, reads its Product ID register, and streams real-time displacement counts (dx, dy).
| Sensor Pin # & Label | Pico Physical Location | Pico Physical Pin # | Wire Color | Function & Notes |
|---|---|---|---|---|
| Pin 1: VCC | LEFT Row (3V3_OUT) | Pin 36 | ๐ด Red (1st wire) | 3.3V Power from Pico (Do NOT use Pin 37) |
| Pin 2: MIS | RIGHT Row (GP4 RX) | Pin 6 | ๐ต Blue (5th wire) | Master In Slave Out (Data from Sensor) |
| Pin 3: MOS | RIGHT Row (GP3 TX) | Pin 5 | ๐ข Green (4th wire) | Master Out Slave In (Data to Sensor) |
| Pin 4: SCL | RIGHT Row (GP2 SCK) | Pin 4 | ๐ก Yellow (3rd wire) | SPI Clock Line (2 MHz) |
| Pin 5: SS | RIGHT Row (GP5 CSn) | Pin 7 | ๐ฃ Purple (6th wire) | Chip Select (Active LOW) |
| Pin 6: MOT | Not Connected | — | — | Motion Interrupt Flag (Optional, polling used) |
| Pin 7: GND | LEFT Row (GND) | Pin 38 | ๐ Orange (2nd wire) | Common Ground Reference |
| Pin 8: RS | Not Connected | — | — | Hardware Reset (Leave Open) |
Open Thonny IDE, paste this script into a new file, and click Run (F5):
import time
from machine import Pin, SPI
# Exact pins matching the 1:1 desk wiring layout:
PIN_SCK = 2 # GP2 (Pin 4) -> Yellow wire (Sensor Pin 4 SCL)
PIN_MOSI = 3 # GP3 (Pin 5) -> Green wire (Sensor Pin 3 MOS)
PIN_MISO = 4 # GP4 (Pin 6) -> Blue wire (Sensor Pin 2 MIS)
PIN_CS = 5 # GP5 (Pin 7) -> Purple wire (Sensor Pin 5 SS)
# Power: Red wire (Sensor Pin 1 VCC) -> Left Row Pin 36 (3V3_OUT)
# Ground: Orange wire (Sensor Pin 7 GND) -> Left Row Pin 38 (GND)
cs = Pin(PIN_CS, Pin.OUT, value=1)
spi = SPI(0, baudrate=2_000_000, polarity=1, phase=1,
sck=Pin(PIN_SCK), mosi=Pin(PIN_MOSI), miso=Pin(PIN_MISO))
def write_reg(reg, val):
cs.value(0)
time.sleep_us(10)
spi.write(bytes([reg | 0x80, val]))
time.sleep_us(30)
cs.value(1)
time.sleep_us(35)
def read_reg(reg):
cs.value(0)
time.sleep_us(10)
spi.write(bytes([reg & 0x7F]))
time.sleep_us(160) # t_SRAD turnaround delay
val = spi.read(1)[0]
time.sleep_us(5)
cs.value(1)
time.sleep_us(20)
return val
# 1. Reset SPI port
cs.value(1); time.sleep_ms(10)
cs.value(0); time.sleep_ms(2); cs.value(1); time.sleep_ms(10)
# 2. Power-up Reset command (0x5A to register 0x3A)
write_reg(0x3A, 0x5A)
time.sleep_ms(60)
# 3. Flush motion registers pipeline
for r in [0x02, 0x03, 0x04, 0x05, 0x06]:
read_reg(r)
time.sleep_ms(10)
# 4. Check IDs
prod_id = read_reg(0x00)
rev_id = read_reg(0x01)
print(f"๐ฆ Product ID: 0x{prod_id:02X} | Revision ID: 0x{rev_id:02X}")
print("๐ฎ Live Tracking Active - Swipe surface over sensor:")
while True:
motion = read_reg(0x02)
squal = read_reg(0x07) # Surface quality (0-255)
if motion & 0x80:
dx_l = read_reg(0x03)
dx_h = read_reg(0x04)
dy_l = read_reg(0x05)
dy_h = read_reg(0x06)
dx = (dx_h << 8) | dx_l
if dx >= 32768: dx -= 65536
dy = (dy_h << 8) | dy_l
if dy >= 32768: dy -= 65536
print(f"๐ dX: {dx:+6d} | dY: {dy:+6d} | SQUAL: {squal:3d}")
time.sleep_ms(20)
Connect to your standalone Raspberry Pi 4 host anytime over WiFi without needing a dedicated monitor or keyboard.
# Connect by IP from Windows PowerShell / macOS / Linux: ssh raspberryben@192.168.2.107 # (Or connect by mDNS hostname): ssh raspberryben@raspberrypi.local
Goal: Connect the RASP CAM 3 WN (Sony IMX708) to the Raspberry Pi 4 using the 500mm RASP CAM FPC 50 ribbon cable. Verify clean autofocus video capture and optical clearance in your 3D-printed slot.
sudo reboot to re-enumerate the IMX708 sensor.
Open a terminal on your Raspberry Pi (or SSH) and run:
# 1. Test live fullscreen camera preview with continuous autofocus (5 seconds): rpicam-hello -t 5000 # 2. Capture a high-res 12MP test snapshot: rpicam-still -o test_cradle_fit.jpg --width 1920 --height 1080 --autofocus-mode auto # 3. If mounted upside-down inside the vault, flip it in preview: rpicam-hello -t 5000 --rotation 180
Goal: Connect the Pico 2WH to the Raspberry Pi via USB cable. Verify that the Pi detects the Pico as a serial CDC device (/dev/ttyACM0) and streams live tracking packets directly into the Pi's Python engine.
# Check if Pico 2WH USB serial is detected: ls -l /dev/ttyACM* # (You should see /dev/ttyACM0 appear when Pico is plugged in)
This master script runs on the Raspberry Pi 4, connects to the Pico over USB, streams live $(\text{Lat}, \text{Lon})$ coordinates, and captures 1-shot camera ring snapshots when [ENTER] or the Plunger Button is pressed.
# 1. From your Laptop, transfer cradle_brain.py to the Pi: scp cradle_brain.py raspberryben@192.168.2.107:/home/raspberryben/ # 2. SSH into your Raspberry Pi: ssh raspberryben@192.168.2.107 # 3. Run the Master Space-Time Brain Engine: python3 cradle_brain.py
The TASTER 3305D tactile microswitch will be wired under the flush center plunger of the Ziggurat Dial to trigger instantaneous optical ring capture and print dispensing.
Transform your Raspberry Pi into a plug-and-play appliance. When powered on at a museum, gallery, or exhibition, the system automatically launches the space-time tracking engine in ~20 seconds without needing any keyboard, monitor, or SSH login.
# 1. From Laptop PowerShell, copy service files to the Pi: scp globe-tracker.service setup_autostart.sh raspberryben@192.168.2.107:/home/raspberryben/ # 2. SSH into your Raspberry Pi: ssh raspberryben@192.168.2.107 # 3. Run the 1-Click Installer (enables automatic boot startup): sudo bash setup_autostart.sh # 4. Verify the background daemon is active: sudo systemctl status globe-tracker.service
If the power cord is abruptly unplugged and plugged back in, systemd restarts the engine with zero file corruption.
Tail live coordinate logs anytime from laptop: tail -f /home/raspberryben/cradle.log
Print or tape this 3-step card under the Mother Base console for anyone unboxing and exhibiting the piece at a gallery or venue.