Bluetooth Motor Control
An embedded system to control a Raspberry Pi-driven motor from an iPhone app via Bluetooth LE.
View on GitHubSystem-Level Description
This project demonstrates a complete, end-to-end embedded system. The goal is to provide seamless wireless control over a physical motor from a custom-built mobile application.
Data & Control Flow
The flow of control begins with the user on the **iPhone app**. When a user adjusts the speed slider or taps a direction button, the app writes data to a specific characteristic on the BLE peripheral.
The **Raspberry Pi**, acting as the peripheral, constantly listens for these BLE characteristic updates. A Python script running on the RPi receives the new data, parses it, and translates it into hardware commands.
These commands are sent to the **L298N Motor Driver** via the RPi's GPIO pins, managing both the speed (using PWM) and direction, which in turn drives the **DC Motor**.
High-level system architecture
Component Breakdown
The system is divided into three core components, each with a distinct responsibility.
1. iOS Application (The Controller)
The user-facing controller. This native app acts as the BLE Central device.
- UI: Built with SwiftUI.
- Function: Scans, connects, and sends commands.
- Tech: Uses the CoreBluetooth framework.
2. Raspberry Pi 4 (The Brain)
The central hub and BLE Peripheral. It receives commands and manages hardware.
- OS: Raspberry Pi OS.
- Logic: A Python 3 script.
- BLE: Uses `bleak` or `bluepy` library.
- Hardware: Controls GPIO pins via `RPi.GPIO`.
3. Motor & Driver (The Muscle)
The physical hardware that translates digital signals into motion.
- Driver: L298N H-Bridge.
- Motor: Standard 5V DC Motor.
- Function: H-Bridge handles direction and power.
- Control: Speed managed by PWM signal.