The Fritz!Relay
Sometimes it is useful to switch some devices at home while you are somewhere else. I did some circuits that allow just this. The first one was a little circuit, that was built around a Lantronix X-Port. The X-Port is a embedded ethernet-server, that has an ethernet-port as well as a serial port. Bytes that are received at one port are forwarded to the other port and vice versa. So it is simple to attach a cheap 8-bit microcontroller to the internet by just using its serial interface. The board was working very well and I used it about three years.
As I wanted to have some more features, I reworked the board. This time the board didn't have a X-Port, but was connected to the USB-port of my AVM Fritz!Box 7170. Again three years later I needed some more relays. So I did a third board that can switch up to eight relays. It is powered over USB and therefore doesn't need an external power supply.
Features
- Switches up to 8 bipolar relays
- Controlable via IR remote
- Controlable via web-browser
- Tel-Mute (turns off the stereo when a phone call comes in)
- Forwarding of IR remote control commands to ethernet
- Automatic power off a PC after shutdown
- Toggle WLAN on/off via IR remote control
The software
The main software runs on the Fritz!Box. Therefore I modded the FB with the freetz-firmware. That allows to extend the FB with some Linux-software packages. I needed the driver for the USB-port (ftdi_sio) and screen, callmonitor and wget.
The USB-port is used as serial interface from the Fritz!Box to the Atmel-controller on the Fritz!Relay PCB. The job of the Fritz!Box is to provide a small web-server, where the user can set the state of the relais.

Depending on the settings in the browser, a serial command has to be sent to the Atmel-controller.
The first version of the web-server was written with LabVIEW (see the topic Fritz!Box -> LabVIEW).
But now as the software is getting a little more complex, it is written in C. You can find the software in the download-section at the end of the page.
The hardware
The main parts needed are the FT232RL (USB-to-serial-chipset), ATMega microcontroller and the L293D relay-drivers.
Hints:
The TCP-ports of the Fritz!Box can only be accessed from the LAN, not from the Internet, so that the port 1000 on which the small web-server is listening is not reachable from outside the intranet. A little trick I found at http://www.wehavemorefun.de/fritzbox/index.php/SSH/Dropbear helps. The file /var/flash/ar7.cfg has to be edited with nvi. In the chapter "forwardrules" a line is added:
Now you can connect to the webserver even from the Internet.
There is another little problem with the webserver. If it is started from shell via telnet, the application is closed when the telnet session ends. The fastest workaround for me was, to compile Freetz with the screen-package. Before starting the web-server just start a new screen-session. That session keeps running even when telnet is closed.
"screen" can also be used to open a serial terminal to the Fritz!Relay. If attached with an serial-to-USB adapter you may reach the Fritz!relay with "screen /dev/ttyUSB0".
Update:
I finished the software for the Atmel-Controller and the Fritz!Relay is running now. Switching the relays is possible via USB and IR-Remote Control (with RC5 codes, e.g. Philips TVs). The commands send to the Fritz!Relay are quite simple. To switch on all four connected relays it is "C1111E", to switch them off it is "C0000E". After each command the Fritz!Relay responds with the current state of the relays like this "R1010E" when relay one and three are on.
To request the state of the relays without giving the command to switch them, "CUUUUE" can be used. To turn on relay one and leave the rest unchanged send "C1UUUE".
The code is for Bascom-AVR (a free version is available at www.mcselec.com)
Downloads:
Important: The Fritz!Relay project has evolved over time. Originally I planned to develop a version of the Fritz!Relay that is useful for other people. This should have included some more documentation of the features, the source-code and the hardware layout. I'm not sure if I will have the time for this in the near future. So the following download justs represents the current status and is provided "as is".
Sourcecode and Schematics




Fritz!Relay