A dual-architecture embedded system combining RISC-V (VisionFive 2) and 8051 (AT89S52) to provide real-time landslide detection with tiered audible/visual alerts and verified sub-millisecond timing accuracy.
Landslides along tropical mountain roads kill silently — passive "Landslide Area" warning signs offer no real-time information about actual slope conditions. This project turns that passive sign into an active sentinel by monitoring two key landslide precursors: ground tilt (slope movement) and soil saturation (subsurface water). When either or both conditions are detected, the system issues calibrated LED and buzzer alerts within milliseconds.
The hybrid architecture splits responsibilities: a VisionFive 2 RISC-V SBC running Python handles sensor fusion, debouncing, and data logging, while an AT89S52 (8051) running hand-written assembly provides hard-real-time alarm actuation immune to Linux scheduling jitter. Communication between the two controllers uses discrete 2N3904 BJT inverters — no level-shifter ICs needed.
Built as part of the EEE226 Microprocessor I course at Universiti Sains Malaysia.
┌─────────────────────────────────────────────────────────────────┐
│ SENSOR INTERFACE LAYER │
│ │
│ Tilt Switch ──► GPIO 40 (Pin 28) ┐ │
│ (10° threshold) │ │
│ ▼ │
│ Soil Probe ──► GPIO 46 (Pin 32) VisionFive 2 │
│ (HW-080, active-low) (RISC-V SBC) │
│ Python Daemon │
│ │ │
│ │ GPIO 45 (Pin 27) │
│ ALERT INTERFACE │ │
│ ▼ ▼ │
│ ┌────────┐ ┌────────┐ │
│ │ 2N3904 │◄────│ 1kΩ │ │
│ │ (BJT) │ └────────┘ │
│ └───┬────┘ │
│ │ Collector + 10kΩ pull-up to 5V │
│ ▼ │
│ ┌──────────┐ │
│ │ AT89S52 │ │
│ │ (8051) │ │
│ │ P3.2/INT0│──► Edge-triggered ISR │
│ │ P1.0 │──► LED (Warning) │
│ │ P1.1 │──► Piezo Buzzer (Critical) │
│ └──────────┘ │
│ 11.0592 MHz crystal │
│ REAL-TIME ACTUATION LAYER │
└─────────────────────────────────────────────────────────────────┘
| Component | Quantity | Role |
|---|---|---|
| VisionFive 2 (RISC-V SBC) | 1 | Sensor polling, risk classification, data logging (Python) |
| AT89S52 (8051 MCU) | 1 | Real-time LED/buzzer actuation (Assembly) |
| Digital Tilt Sensor Module | 1 | Detects slope rotation beyond ≈10° |
| HW-080 Soil Moisture Probe | 1 | Detects near-surface water saturation (active-low) |
| 2N3904 NPN Transistor | 2 | Level-shifting inverter (3.3V → 5V) and indicator LED driver |
| Red LED | 2 | Visual warning indicators |
| Piezo Buzzer | 1 | Audible critical alert |
| 1kΩ Resistor | 2 | BJT base current limiting |
| 10kΩ Resistor | 1 | INT0 pull-up to 5V |
The Python daemon on the VisionFive 2 polls both sensors every 200 ms and classifies the situation:
| Regime | Tilt | Soil Moisture | Meaning | Alert Pattern |
|---|---|---|---|---|
| Normal | Stable (0) | Dry (1) | Slope stable & dry | No output |
| Warning | Tilted (1) XOR Wet (0) | — | One precursor active — monitor closely | Single 100 ms pulse, 1.0 s interval |
| Critical | Tilted (1) | Wet (0) | Both precursors — slide may be imminent | Triple 50 ms strobe, 0.5 s pause |
Python (VisionFive 2) — Sensor Fusion & Logging:
- Polls GPIO 40 (tilt) and GPIO 46 (soil) every 200 ms via
gpiod - Applies software debounce (20 ms for tilt switch)
- Classifies risk level using truth table
- Generates calibrated pulse train on GPIO 45 via
pulse_alert(pulses, on_time, gap_time) - Logs state changes to rotating CSV file (100 KB max, 3 backups) with timestamps
- Console output only on state transitions (no scroll flooding)
8051 Assembly (AT89S52) — Real-Time Actuation:
- INT0 (P3.2) configured for edge-triggered interrupts
- ISR is 2 instructions (~8 µs latency): sets flag at address 30H and returns
- Main loop checks flag → enters BLINK_LOOP → toggles LED (P1.0) and buzzer (P1.1)
- Warning: single flash/beep cycle (INT0 returns high quickly)
- Critical: continuous flash/beep until pulse train ends (INT0 stays low during burst)
- Nested DJNZ delay routine: R2=100, R1=255 → calibrated 55.7 ms per call
The 2N3904 transistor serves three purposes simultaneously:
- Voltage level shifting — converts 3.3V SBC logic to 5V TTL for the 8051
- Signal inversion — Python drives high → collector goes low → falling edge triggers INT0
- Noise immunity — 10kΩ pull-up ensures INT0 rests high during SBC boot/crash, preventing false triggers
With an 11.0592 MHz crystal, one machine cycle = 12 / 11.0592 MHz ≈ 1.085 µs
Inner loop: MOV R1, #255 (1 cycle) + DJNZ R1 × 255 (510 cycles) = 511 cycles
Outer loop: 99 × (511 + 2) + 511 = 51,298 cycles
Overhead: MOV R2, #100 (1) + RET (2) = 3 cycles
─────────────────────────────────────────
Total: 51,301 cycles × 1.085 µs = 55.66 ms
| Measurement | Calculated | Measured | Error |
|---|---|---|---|
| Delay subroutine | 55.7 ms | 55.68 ms | 0.04% (< 1 machine cycle) |
| Warning pulse period | 1.20 s | 1.20 s | Matched |
| Warning pulse width | ~55 ms | ~55 ms | Matched |
| Critical burst (3 pulses) | ~230 ms | ~230 ms | Matched |
| Critical burst period | ~580 ms | ~580 ms | Matched |
| Critical peak voltage | ~4.0 V | ~4.0 V | Full BJT saturation confirmed |
Sensor output voltages verified against TTL thresholds:
| Sensor | Logic 0 | Logic 1 | TTL Margin |
|---|---|---|---|
| Tilt switch | 0.386 V (< 0.8 V ✓) | 3.23 V (> 2.0 V ✓) | > 0.4 V / > 1.2 V |
| Soil probe | 0.315 V (< 0.8 V ✓) | 3.38 V (> 2.0 V ✓) | > 0.5 V / > 1.4 V |
- Fail-safe split architecture — If Linux crashes, the 8051 finishes its current blink cycle safely. If the 8051 loses power, the SBC continues logging data for post-event analysis.
- Low cost — Entire BOM uses common lab components; no expensive level-shifter ICs, datalogers, or telemetry modules.
- Extensible — The SBC can add LoRa/GSM networking, web dashboards, or ML-based prediction without touching the real-time alert code.
- Power efficient — ~110 mA idle draw; can run from a USB power bank or modest solar panel.
- SBC OS: Debian Linux on VisionFive 2
- Python Libraries:
gpiod,logging,RotatingFileHandler - Assembly: 8051 ASM compiled for AT89S52
- Programmer: AVRDudess (for 8051 ISP programming)
- Test Equipment: Oscilloscope, digital multimeter
- MEMS IMU — Replace binary tilt switch with continuous-output accelerometer for creep detection
- LoRa / GSM backhaul — Transmit critical alerts to a cloud dashboard or SMS gateway
- Solar power + Li-ion buffer — Enable months of autonomous operation on remote slopes
- Edge AI — Train LSTM model on the SBC for predictive landslide forecasting
- Multi-node mesh — Deploy multiple nodes along a slope with coordinated alerting
- Huang Run Ping (22304721)
- Cui Yong Kang (22304640)
EEE226 Microprocessor I Mini Project — School of Electrical & Electronic Engineering, Universiti Sains Malaysia (2025) Supervisor: Dr. Ahmad Nazri Ali