Skip to content

An Edrys module that enables remote control of microcontrollers and development boards through a Digilent Analog Discovery 2

Notifications You must be signed in to change notification settings

edrys-labs/module-hardware-control

Repository files navigation

Hardware Control Module

An Edrys module that enables remote control of microcontrollers and development boards through a Digilent Analog Discovery 2 (AD2). Students can interact with hardware remotely by controlling buttons and potentiometers through a web interface, while the station with the physical hardware executes the commands.

To add the module to your Edrys class, import the following URL:

https://edrys-labs.github.io/module-hardware-control/index.html

How It Works

Module Architecture

The system consists of three main components:

  1. Frontend Module: An Edrys module that provides the user interface for controlling hardware
  2. Backend Server: A Flask server that runs locally on the station machine and communicates with the AD2
  3. Hardware: Microcontroller or development board connected to the AD2 (e.g., Arduino Uno, AVR128DB48, ESP32...)

Communication Flow

  1. Students interact with buttons and sliders in the Edrys module
  2. The module sends messages to all participants via Edrys
  3. Only the station executes hardware commands by calling the backend server
  4. The AD2 controls the connected hardware (digital I/O for buttons, analog output for potentiometers)
  5. UI state is synchronized across all users in real-time

Features

  • ✅ Remote button control (digital I/O)
  • ✅ Remote potentiometer control (analog output 0-3.3V)
  • ✅ Multiple simultaneous users with synchronized UI
  • ✅ Real-time connection status monitoring
  • ✅ Dynamic component configuration
  • ✅ Support for multiple buttons and potentiometers

Setup

Prerequisites

  • Docker installed (Get Docker)
  • Digilent Analog Discovery 2 connected via USB
  • Microcontroller/development board connected to AD2

Server Setup

You can run the server using Docker:

docker run -it -p 5005:5005 --device=/dev/bus/usb:/dev/bus/usb edryslabs/module-hardware-control-server:latest

Module Configuration

  1. Add the Hardware Control module to your Edrys class (it should only be visible in station)
  2. In the station configuration, set:
    • serverUrl: The URL of your backend server (e.g., http://localhost:5005)
    • components: Array of hardware components to control

Example configuration:

{
  "serverUrl": "http://localhost:5005",
  "components": [
    {"type": "button", "name": "Button 1", "pin": 4},
    {"type": "button", "name": "Button 2", "pin": 5},
    {"type": "potentiometer", "name": "Voltage Control", "channel": 0}
  ]
}

Hardware Requirements

  • Digilent Analog Discovery 2: Connected to the station computer via USB
  • Microcontroller/Development Board: Connected to AD2 (Arduino Uno, AVR128DB48, ESP32, etc.)
  • Proper wiring: See wiring examples below

API Endpoints

The backend server provides these endpoints:

  • GET /: Health check - returns server status and device information
  • POST /press: Press a button
    {
      "pin": 4  // DIO pin number
    }
  • POST /release: Release a button
    {
      "pin": 4  // DIO pin number
    }
  • POST /toggle: Toggle a button (50ms press)
    {
      "pin": 4  // DIO pin number
    }
  • POST /potentiometer/set: Set potentiometer voltage
    {
      "channel": 0,     // Analog output channel (W1=0, W2=1)
      "voltage": 1.65   // Voltage in volts (0.0-3.3)
    }
  • POST /potentiometer/percent: Set potentiometer percentage
    {
      "channel": 0,   // Analog output channel (W1=0, W2=1)
      "percent": 50   // Percentage (0-100)
    }

Wiring Examples

Arduino Uno

AD2 Device          Arduino Uno
─────────           ───────────
DIO4      ────────→ Digital Pin 2 (button input)
W1        ────────→ A0 (analog input)
GND       ────────→ GND

AVR128DB48

AD2 Device          AVR128DB48
─────────           ──────────
DIO4-7    ────────→ PC4-PC7 (button inputs)
W1        ────────→ PF3 (analog input)
GND       ────────→ GND

Development

For local development without Docker:

# Install dependencies
pip3 install flask flask-cors

# Run server
python3 server.py

About

An Edrys module that enables remote control of microcontrollers and development boards through a Digilent Analog Discovery 2

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published