mirror of
https://gitlab.com/wirelos/sprocket-plugin-gpio.git
synced 2025-12-13 21:06:49 +01:00
master
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
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
#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
- Include the plugin in your Sprocket project
- Configure GPIO pins according to your hardware setup
- Initialize plugins with appropriate configurations
- 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 configurationaudio/- Audio input processingcombined/- Multiple input typespir/- Motion sensor setuprotary/- Rotary encoder support
License
See LICENSE file for details.
Description
Languages
C++
80.2%
C
19.8%