Air Horn Control: Revision 1 and 2

Revision 1: Rapid Prototyping with Off-the-Shelf Solutions

The initial tests used LilyGo ESP Relay Unit with rapid prototyping platforms to create a graphical user interface (GUI).

Platform 1: Blynk

Why Blynk?
Blynk offered features that aligned well with the project’s requirements and showed potential for future use in the EV-Display project, including:

  • Device Management
  • Remote Firmware Updates
  • IoT Connectivity
  • Wi-Fi Setup Modules

Drawbacks:

  • Lack of local BLE connectivity required the ESP to connect via Wi-Fi (e.g., a phone hotspot).
  • Not ideal for scenarios where internet access may not be available.

Developer Experience:
Blynk’s ready-to-go UI elements and pre-built functionality (e.g., interrupts for button presses) made development quick and efficient.


Platform 2: RemoteXY

Why RemoteXY? RemoteXY offered local BLE connectivity and worked within the boundaries of the free license. It allowed control of up to five signals, which was adequate for managing the compressor and air horns.

Drawbacks:

  • Unreliable BLE Events: Handling connect/disconnect events was inconsistent.
  • Worst-case scenario: A BLE disconnect could leave the horn relays stuck in the “on” position, creating a safety hazard.

Revision 2: Custom iOS App Development

To overcome the limitations of BLE in off-the-shelf platforms and meet the project’s learning objectives, a custom iOS app was developed.

Development Approach

  • Native iOS Tools: Chosen over cross-platform frameworks like Flutter to simplify working with BLE.
  • BLE Server Setup: Arduino creates a BLE server with:
    • A custom Service UUID.
    • Characteristics for each relay.

Features

  1. Control Relays:
    The iOS app communicates with the BLE server to control relays on the LilyGo device.

  2. Failsafe Logic in Arduino Code:

    • Maximum horn activation time.
    • Maximum compressor activation time.
    • Disable all relays on BLE disconnect.
  3. Minimal Arduino Logic:
    Logic for custom air horn patterns resides in the app to minimize the chance of missing interrupts or crashes on the microcontroller.


Arduino Code: BLE Server Setup

  • Service UUID: Exposes a custom UUID for the iOS app.
  • Characteristics: One characteristic per relay. Additional characteristics for air tank pressure and battery voltage can be added later.

Guardrails in Arduino Code

  • Limit horn activation time.
  • Limit compressor activation time.
  • Disable all relays if BLE disconnects.

By focusing on safety and stability, the Arduino code ensures essential functionality while offloading complex logic to the app.


iOS App Development

The custom iOS app provides a simple interface:

  1. Scan and Connect:
    Scans for devices with the predefined custom Service UUID and connects to the selected device.

  2. Controls:

    • Toggle Button: Enable/disable the compressor.
    • Push Button: Activate both horn relays.
Bare minimum app to control essential features

Improvements and Next Steps

  1. Pressure Monitoring:
    Replace the analog pressure gauge with a digital one to monitor air tank pressure via the app.

  2. Battery Voltage Monitoring:
    Add a circuit to measure battery voltage (Vbat) and display it in the app.

  3. Pre-Programmed Sequences:
    Add custom air horn sequences.

  4. Cross-Platform App:
    Recreate the app using Flutter to support Android and iOS.


Key Capabilities and Achievements

CapabilityDescription
Rapid PrototypingEvaluated off-the-shelf platforms (Blynk, RemoteXY) for fast iterations.
Custom App DevelopmentDeveloped a BLE-based native iOS app for controlling the hardware.
Failsafe ImplementationIntegrated safety features in Arduino code to prevent unintended behavior.
BLE Server DesignSet up a BLE server with custom Service UUID and Characteristics.
Future-ProofingPlanned improvements for pressure monitoring, battery voltage, and cross-platform support.