mirror of
https://gitlab.com/wirelos/sprocket-plugin-gpio.git
synced 2025-12-14 05:16:50 +01:00
100 lines
2.4 KiB
Markdown
100 lines
2.4 KiB
Markdown
# 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 <GpioConfig.h>
|
|
#include <AnalogInputPlugin.h>
|
|
|
|
// 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. |