a simple homemade relay board for indigo
To switch my thermostats on and off with Indigo I needed a few relay contacts.
The DSC solution was difficult to get in Holland, and I also wanted a very save and stable controllable solution. I need it to switch the heater in my summerhouse and want to be sure the heater is not running for days without anyone being there and spoiling tons of gas.
I have some experience with hardware, a solder iron, PIC programming and the development of a plugin for Indigo. So all the basic skills to build my own solution are available.
- 2 switchable relays.
- Buttons to switch de relays manually.
- Response back to Indigo when the relays are switched manually.
- Alarm input from a PIR.
- Useable with Indigo.The hardware
The schematic diagram is very simple, a PIC 16F627 does the work, but a 16F628 will also do. The PIC runs on its internal oscillator on 4MHz. The ports RA2 and RA3 are used to switch the two relays via two FET’s. You can also use a standard transistor like a BC547. The ports RB4 and RB5 are used for two buttons to switch the relays manually. A PIR with a normal open contact can be connected to port RB3. The ports RB1 and RB2 are the RX and TX lines of the hardware UART of the processor. The MAX232 is used to bring the RS232 level to the standard +/-12Volt.
If you use an USB2RS232 converter which can handle 5Volt signals, you don’t need the MAX232 and can connect the PIC directly to the RS232.
The relay board has to be connected with your Mac via a standard RS232-USB converter. A converter based on a FTDI chip is the best, as a Mac recognizes this converter natively. I also have good experiences with a 2303 based converter and this driver
The software in the PIC
The program only has the following functions:
- Receive the commands
o RL1ON+chr(10) – Turn on relay 1
o RL1OFF+chr(10) – Turn off relay 1
o RL2ON+chr(10) – Turn on relay 2
o RL2OFF+chr(10) – Turn off relay 2
o STATUS+chr(10) – Returns a status message with the status of both relays
- Check the buttons.
o If button 1 is pressed, the state of relay 1 changes and a status message is sent to the RS232 port.
o If button 2 is pressed, the state of relay 2 changes and a status message is sent to the RS232 port.
- Send a message to the RS232 port when the PIR detects movements.
The baudrate of the RS232 is fixed on 19.200Baud.
The hex file for the 16F627 is here
.The Indigo Plugin
The plugin is here
Unzip the zip file and install the plugin with a double-click.
Open the configuration in Plugin/Relaisboard.
Select the correct serial port and set the baudrate on 19200.
Enable debugging, so you can see all commands in the Event Log.
Now you can configure the devices. Relais1 and Relais2 are the different output devices you can add to your list of devices.
Relaisstatus is an inputdevice. This device is updated by the relaisboard every minute with the actual state of the relays.
This makes it possible to detect externl changes to the relay status. The alarmStatus device is an input device which is triggered by the PIR.