Skip to content

Module Design

doomke edited this page Jul 6, 2023 · 11 revisions

Due to the highly variable number of inputs/outputs that might be connected to a single ESP32, the software should reflect this variability and be able to adapt to changes in the setup. Additionally, the communication protocol must allow for the exchange of data and instructions in a flexible way.

This is achieved by organizing every function in modules, that can be dynamically added to the system. Each module encapsulates a single specific function or task, offering methodes to control and reflect the current state of that function. Each module is independent and assumes as little prior information as possible about the outside world, the functioning of other modules or the state of itself and other modules. For example both WiFi and socket are modules that specifically manage the connection to a wireless network and a socket server, respectively. They are the backbone of every component and propagate their current connection state only based on internal events that other modules can react on when they occur. If the connection is established or lost, this information is immediately handed over to every other module on the board, allowing them to return to a safe state by switching off voltages etc.

Consequently, the modules rely on 3 basic ways of communication:

  1. by command: instruction a module to take a specific action
  2. by internal events: notifying other modules on the same ESP32 of specific situations
  3. by status messages: reporting all relevant information about the current state to the server
graph LR
    subgraph hardware
    direction TB
        voltage((voltage))
        relay((relay))
    end 

    subgraph ESP32
    direction TB
        module1(input module)
        module2(output module)

        module1 <--> |internal events| module2
    end

    module1 .-> |reads| voltage
    module2 .-> |controls| relay

    subgraph serverGraph [server]
        server[socket.io]
    end

    module1 & module2 <-- command/status --> server
Loading
graph LR
    subgraph ESP32
        manager(module manager)

        subgraph modules
            wifi(WiFi module)
            socket(socket.io module)
            input(input module)
            output(output module)
        end

        manager --> |distributes events| modules --> |issue events| manager
    end
Loading

General

Guides

Principle of Operation

Modules

Software Hardware
camera camera
infoLED infoLED
input input
macro macro
output output
servo servo
socket socket
stepper stepper
WiFi wifi

Clone this wiki locally