diff --git a/README.md b/README.md new file mode 100644 index 0000000..a06ef68 --- /dev/null +++ b/README.md @@ -0,0 +1,139 @@ +# Sprocket RC-Switch Plugin + +A remote control RF switch plugin for the Sprocket framework, enabling control of 433MHz RF switches and receivers through the Sprocket event system. + +## Overview + +The RC-Switch plugin provides integration with 433MHz RF remote control systems, allowing Sprocket devices to control RF switches, outlets, and other RF-controlled devices through a simple event-based interface. + +## Features + +- **RF Transmitter Control**: Send 433MHz RF signals to control remote switches +- **Group/Device Addressing**: Support for group and device-based addressing +- **Event-Driven Control**: Control switches through Sprocket events +- **Task-Based Operation**: Integrated with Sprocket's task scheduler +- **JSON Configuration**: Easy setup through configuration files +- **Multiple Switch Support**: Control multiple RF devices independently + +## Configuration + +```cpp +struct RcSwitchConfig { + int txPin; // GPIO pin for RF transmitter +}; + +struct RcSwitchPayload { + const char *group; // RF group code + const char *device; // RF device code +}; +``` + +## Usage Example + +```cpp +#include +#include + +// Configure RF transmitter +RcSwitchConfig rcConfig = { + .txPin = 4 +}; + +// Create and activate plugin +RcSwitchPlugin rcPlugin(rcConfig); +rcPlugin.activate(scheduler); + +// Control switches via Sprocket events +// Turn on: publish to "rcswitch/on" with group/device payload +// Turn off: publish to "rcswitch/off" with group/device payload +``` + +## Event Topics + +The plugin responds to various Sprocket events: + +- `rcswitch/on` - Turn on specific RF switch +- `rcswitch/off` - Turn off specific RF switch + +## Message Payload Format + +Control messages use JSON format: + +```json +{ + "group": "A", + "device": "1" +} +``` + +## Hardware Requirements + +- **RF Transmitter**: 433MHz RF transmitter module +- **Antenna**: Wire antenna (typically 17.3cm for 433MHz) +- **Power Supply**: Adequate power for RF transmission +- **GPIO Pin**: Digital output pin for transmitter control + +## Supported RF Protocols + +The plugin supports common 433MHz RF protocols: +- **Group/Device Addressing**: Standard group and device codes +- **On/Off Commands**: Basic switch control +- **Custom Codes**: Extensible for other RF protocols + +## Installation + +1. Include the RC-Switch plugin in your Sprocket project +2. Connect 433MHz RF transmitter to configured GPIO pin +3. Attach appropriate antenna for transmission +4. Initialize the plugin with transmitter configuration +5. Control switches via Sprocket events + +## Dependencies + +- Sprocket-Core framework +- Arduino framework +- RCSwitch library +- TaskScheduler library +- ArduinoJson library + +## Platform Support + +- ESP8266 +- ESP32 + +## Examples + +See the `examples/` directory for complete usage examples: +- `basic/` - Basic RF switch control setup + +## RF Considerations + +- **Frequency**: 433MHz ISM band operation +- **Range**: Typical range 10-100 meters (line of sight) +- **Interference**: May be affected by other 433MHz devices +- **Regulations**: Ensure compliance with local RF regulations + +## Power Requirements + +- RF transmission requires adequate power +- Consider external power supply for reliable operation +- Monitor voltage levels during transmission +- Ensure stable power during RF operations + +## Use Cases + +- **Home Automation**: Control RF outlets and switches +- **Remote Control**: Operate devices from Sprocket applications +- **IoT Integration**: Bridge between Sprocket and RF devices +- **Automation**: Schedule-based RF device control + +## Troubleshooting + +- **No Transmission**: Check transmitter power and antenna +- **Weak Signal**: Verify antenna length and positioning +- **Interference**: Check for other 433MHz devices +- **Range Issues**: Ensure line of sight and adequate power + +## License + +See LICENSE file for details. \ No newline at end of file