Plugins/RFSwitches

From Domoticz
Revision as of 08:31, 30 January 2018 by Blauwebuis (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Devices using the 433Mhz frequency to communicate are popular because they are very cheap. The most popular use is the remote controller power sockets, as well as battery powered door and window open/close sensors.

There are multiple ways of connecting 433Mhz devices to Domoticz.
- A powerfull and cheap but relatievely complex way is to build the bulky RFLink
- You can buy the plug-and-play but expensive RFXcom usb stick (100+ euro)

If you are using a Raspberry Pi to run Domoticz, then there is a much simpler and cheaper option: the RFSwitches plugin.

1. This plugin only requires that you have the cheaper 433 transmitter and receiver set, costing less than a euro online.
2. Connect these directly to your Raspberry Pi pins (details below).
3. Install the PiGPIO library on your raspberry pi
4. Install this plugin.
4. activate this plugin.

What is the downside? This plugin can only be used to clone RF commands. That means it works fine for switches, but cannot process the always changing data from sensors. If you only use 433Mhz switches, then this plugin may be all you need.

Installing

1. BUY A 433 SET

Buy the cheapest 433 Mhz transmitters from Aliexpress or Ebay. In my experience these very simple ones work the best. (The Qiachip ones that I usually use didn't work). if you find that other transmitters and receivers work, please add that to this wiki.
https://www.aliexpress.com/item/5v-super-regenerative-receiver-module-wireless-receiving-module-wireless-transmitting-module-433-315MHZ/32238273345.html Example on Aliexpress]

2. CONNECT TO PI

[THIS IMAGE SHOWS HOW TO CONNECT THINGS]

Connect the receiver's VCC to the 3.3v output of your Pi. This is important, because if you use 5v, then its data output will also be 5v, and the Pi can't handle 5v data input.
Connect the ground to a ground pin.
Connect any of the two data pins to GPIO pin 27 on your pi. If GPIO pin 27 is not available, you can choose another one. Make sure to set that GPIO pin number up later on the plugin page.
TIP: do not solder an antenna to the receiver. This will only allow it to pick up more noise from your neighbours, which will mess up the learning proces.

Connect the VCC(+) pin of the transmitter to a 5v out pin on your Pi. Here using 5v is no problem, because this data pin does not send signals to the Pi.
Connect the ground pin to a ground pin on your pi.
Connect the data-in pin of the transmitter to GPIO pin 17. If GPIO pin 17 is not available, you can choose another one. Make sure to set that GPIO pin number up later on the plugin page.

Please be aware that there are a number of different naming schemes for the pins of the Raspberry Pi: Physical, GPIO, and Wiring. This plugin uses GPIO numbering.


3. INSTALL PIGPIO

PiGPIO is a special library and service that allows for very high precision timing when reading and transmitting on the Pi's pins. It's also less susceptible to interference and interruption by other processes running on the Pi.

Open a terminal window and enter these two commands:

 sudo apt-get update
sudo apt-get install pigpio python-pigpio python3-pigpio


4. INSTALL THE PLUGIN

Install the plugin into Domoticz.

Navigate to the plugin directory ("cd domoticz/plugins")
Create a folder RFSwitches in the plugin directory (when in the plugin directory enter "sudo mkdir RFswitches")
Enter the folder ("cd RFSwitches")

Copy the two files form the Github page into that folder. The commands:

 wget https://github.com/flatsiedatsie/433Switches/raw/master/plugin.py
wget https://github.com/flatsiedatsie/433Switches/raw/master/433cloner.py

Make the plugin.py file executable:

 chmod +x plugin.py


5. ENABLE THE PLUGIN

Restart Domoticz, and under 'hardware' enable the RFSwitches plugin.
If you use different receive (rx) and transmit (tx) pins, enter the pin numbers here.
Restart Domoticz again, and now the plugin is active.

Can't see the plugin in the list? Then your python plugin framework is not working. Check the Domoticz logs for details.

Using the plugin

The plugin allows Domoticz to learn arbitrary new 433 codes.

On the switches page the plugin will have created a new master switch called "Add new 433 Switch".

When you press the switch to "on", a new switch is created. More importantly, you now have 10 seconds to teach the new ON code to Domoticz. Hold your remote or device very closely to the receiver, and press the on button a few times. It will pick the best (longest) recording.

Wait until the 10 seconds are over.

Now, click the "OFF" button on the switch, You now have 0 seconds to press the OFF button on your remote a few times.

If all went well, when you refresh the page you will see the new switch that has been created. Test it. If it only picked up the ON or OFF signal, delete it and try again.

You can teach Domoticz a total of 255 RF switches. The failed ones are included in this count.