relay - wolfen351/public-micropython-iot-platform GitHub Wiki
Overview
The Relay
module controls a relay switch connected to a specific GPIO pin on the microcontroller. It provides functionality to turn the relay on, off, or toggle its state (flip). The module also integrates with the web interface for remote control.
Features
- Control a relay switch via GPIO.
- Web-based interface for toggling the relay.
- Stores and retrieves the relay's state using preferences.
- Provides telemetry data for the relay's state.
- Processes commands to control the relay.
UI Hardware / Pinout Configuration
- The relay is connected to a GPIO pin defined in the
basicSettings["relay"]["pin"]
configuration. - The relay's state is displayed and controlled via the web interface.
Telemetry Provided
relay/S1
: Indicates the current state of the relay (0 = Off, 1 = On).
Telemetry Consumed
- None.
Commands Provided
/relay/on/1
: Turns the relay on./relay/off/1
: Turns the relay off./relay/flip/1
: Toggles the relay's state.- Custom flip command defined in
basicSettings["relay"]["flipcommand"]
.
Commands Consumed
- Processes commands received via the web interface or other sources to control the relay.
Additional Information
- The relay's state is persisted using preferences (
setPref
andgetPref
). - The web interface is defined in
relay_index.html
and provides a button to toggle the relay. - The module uses the
Pin
class frommachine
to control the GPIO pin.