RF Switch

../../../../../../_images/stx882.png

Supports basic 433MHz AM transmitter attached to a GPIO pin via 5v buffer. You may be able to get away with connecting the GPIO directly and running from 3.3v, but timing and performance won’t be as good.

Uses hardware timer to generate PWM output using interrupts.

Developed for use with i-Lumos lightswitches which use a 24-bit code. Timing parameters are programmable though so may work with other devices.

namespace RFSwitch

RFSwitch/Controller.h

Copyright 2022 mikee47 mike@sillyhouse.net

This file is part of the IOControl Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

RFSwitch/ControlleDevice.h

Copyright 2022 mikee47 mike@sillyhouse.net

This file is part of the IOControl Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

RFSwitch/Request.h

Created on: 1 May 2018

Copyright 2022 mikee47 mike@sillyhouse.net

This file is part of the IOControl Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

class Controller : public IO::Controller
#include <Controller.h>

Controller for 433MHz transmitter.

Protocol is flexible but tested only with i-Lumos light switches. Written specifically for ESP8266 and uses the hardware timer to generate PWM signal via interrupts.

Public Functions

inline virtual const FlashString &classname() const override

Get the class name for this Controller.

virtual void handleEvent(IO::Request *request, Event event) override

Implementations override this method to process events as they pass through the stack.

struct Timing
#include <Device.h>

Protocol timings in microseconds.

Public Members

uint16_t starth

Width of start High pulse.

uint16_t startl

Width of start Low pulse.

uint16_t period

Bit period.

uint16_t bit0

Width of a ‘0’ high pulse.

uint16_t bit1

Width of a ‘1’ high pulse.

uint16_t gap

Gap after final bit before repeating.

class Device : public IO::Device
#include <Device.h>

Public Functions

virtual IO::Request *createRequest() override

Create a request object for this device.

Return values:

Request* – Caller must destroy or submit the request

struct Config
#include <Device.h>
class Factory : public IO::Device::Factory
#include <Device.h>

Public Functions

inline virtual IO::Device *createDevice(IO::Controller &controller, const char *id) const override

Create a new device instance.

Called by DeviceManager::createDevice()

Parameters:
  • controller – The owning controller

  • id – Unique identifier for the device

Return values:

Device* – The constructed instance

inline virtual const FlashString &controllerClass() const override

Return the expected controller type for this device class, e.g. ‘rs485’.

The Device Manager uses this value to verify that devices are constructed using the correct controller.

inline virtual const FlashString &deviceClass() const override

Return the Device class name, e.g. ‘r421a’.

class Request : public IO::Request
#include <Request.h>

Public Functions

virtual ErrorCode parseJson(JsonObjectConst json) override

Fill this request from a JSON description.

virtual void getJson(JsonObject json) const override

Get result of a completed request in JSON format.

inline virtual bool setNode(DevNode node) override

If nodes are supported, implement this method.

/

/**