From 371557eb7d19c373db2fab17e8c2c09c2cbdc6aa Mon Sep 17 00:00:00 2001 From: Patrick Balsiger Date: Fri, 15 Aug 2025 21:31:56 +0200 Subject: [PATCH] docs: add comprehensive README with GPIO plugin documentation --- README.md | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..07a8f48 --- /dev/null +++ b/README.md @@ -0,0 +1,100 @@ +# Sprocket GPIO Plugin + +A comprehensive GPIO plugin for the Sprocket framework, providing support for various input and output configurations on ESP8266 and ESP32 devices. + +## Overview + +The GPIO plugin extends Sprocket-Core with flexible GPIO management capabilities, supporting multiple input types and configurations for IoT sensor applications. + +## Features + +- **Multiple Input Types**: Analog, digital, audio, and PIR sensor support +- **Configurable Pins**: Flexible pin assignment and mode configuration +- **Event-Driven**: Publishes sensor data to configurable topics +- **Task-Based**: Integrated with Sprocket's task scheduler +- **Cross-Platform**: Supports both ESP8266 and ESP32 + +## Supported Input Types + +### Analog Inputs +- Configurable threshold detection +- Update interval control +- Topic-based event publishing + +### Digital Inputs +- Digital pin state monitoring +- Event-driven state changes +- Configurable pin modes + +### Audio Inputs +- Audio signal processing +- Threshold-based detection +- Real-time audio monitoring + +### PIR Motion Sensors +- Motion detection +- Configurable sensitivity +- Event publishing on motion + +## Configuration + +```cpp +struct GpioConfig { + int pin; // GPIO pin number + int threshold; // Detection threshold + int updateInterval; // Update frequency in ms + const char *topic; // Event topic for publishing + int pinMode; // Pin mode (INPUT, INPUT_PULLUP, etc.) +}; +``` + +## Usage Example + +```cpp +#include +#include + +// Configure analog input +GpioConfig analogConfig = { + .pin = A0, + .threshold = 512, + .updateInterval = 1000, + .topic = "sensor/analog", + .pinMode = INPUT +}; + +// Create and activate plugin +AnalogInputPlugin analogPlugin(analogConfig); +analogPlugin.activate(scheduler); +``` + +## Installation + +1. Include the plugin in your Sprocket project +2. Configure GPIO pins according to your hardware setup +3. Initialize plugins with appropriate configurations +4. Activate plugins through the Sprocket scheduler + +## Dependencies + +- Sprocket-Core framework +- Arduino framework +- TaskScheduler library + +## Platform Support + +- ESP8266 +- ESP32 + +## Examples + +See the `examples/` directory for complete usage examples: +- `analog/` - Analog input configuration +- `audio/` - Audio input processing +- `combined/` - Multiple input types +- `pir/` - Motion sensor setup +- `rotary/` - Rotary encoder support + +## License + +See LICENSE file for details. \ No newline at end of file