msnrelay:msnrelay

Power Home Automation

This project has stalled

The goal of this project is to provide a cheap and easy way to remotely control the power to 240v devices.

Separating the hardware system into two discrete components, will allow each to be changed and upgraded independently. The two discrete pieces of hardware that will be used will be a microcontroller board and a relay board.

The microcontroller board will be custom designed to keep the footprint of the board small and to keep the component count to the minimum. Off the shelf controller boards have additional components that will not be needed.

The Opto-Isolated Relay Board from Futurlec will be used as this cost of custom building this component would approach the buy price.

Control Head

The smarts of the relay controller will be a AVR 2313. This will however place a constraint on the firmware command set as the whole control system must reside within the limited 2K flash ROM space.

The AVR 2313 microcontroller has up to 15 I/O ports that could be used to control the relays, however only 4 will be used. The firmware can be upgraded easily if a larger relay board is needed.

As the units interface is serial there are several ways in which it may be controlled.

In is most basic form the unit would simply be connected straight to a computer and a terminal emulator would be used to access the command line prompt.

To gain a form of remote control the device may be connected to a serial console port server, this would allow a remote user to connect to the serial device by using a reverse telnet connection.

The ultimate form of remote control would be to have the AVR units serial interface relayed over the internet to a waiting client. The perfect medium for this would be one of the existing internet chat clients: MSN, Skype, IRC, Yahoo

In this model the hardware attaches to an internet enabled PC via a serial port (or USB to serial port adaptor). A custom serial/MSN BOT would provide the gateway between MSN and the serial port. This subproject will discussed in more detail later.

A serial chat session with the firmware running on the AVR will allow you to perform the following functions:

  • switch individual relays on or off
  • toggle individual relays
  • turn all relays on
  • turn all relays off
  • view the current status of the relays
  • get help on the supported commands

Sample interaction with the control program:

RELAY: Ready for commands
>help
Available Commands:
<relay> = 1-4 or ALL
  HELP or ?
  [S]TATUS
  [T]OGGLE <relay>
  [O]N <relay>
  O[F]F <relay>
>status
     Relay 1) is Off
     Relay 2) is Off
     Relay 3) is Off
     Relay 4) is Off
>on 1
>toggle 4
>s
     Relay 1) is On
     Relay 2) is Off
     Relay 3) is Off
     Relay 4) is On
>off all
>off 5
Command 'OFF 5' not recognized
>

Design a dedicated PCB for the 2313/max232. Considering the option of having the 2313 PCB 'piggyback' onto one of the IDC male connectors on the relay board. Not much room for an 'on top' attachment. Perhaps better to use the side facing IDC.

IDC Connector exposes 5V and 0V, but not the 12V that is needed to power the relay board. Need to think of how best to get a 5V supply. If we use a 7805 on the 2313 PCB, it will run quite hot with a 12V input. Since the 12V connector on the relay board is a terminal block, perhaps just add another terminal block to the 2313 PCB & use wires to hookup.

msnrelay_if.jpg mockup.jpg

Layout and PCB in EAGLE CAD msnrelay.zip

The firmware for the control unit is written in BASCOM. Relay Firmware source code.

Serial MSN Relay

The hardware device communicates with its user using the on-board UART normally using a terminal emulator program. By introducing an MSN to Serial port relay program we allow the device to be control remotely using an MSN chat dialog.

  • Selectable comm port number
  • Associate a 'friendly name' with each relay
  • Run in the tooltray
  • Implement MSN 'keepalive'
  • Implement 'auto-off' after a specified time period

Preferences dialogs will allow configurable options to modified and persisted.

serialmsn.zip

It is likely that the Serial MSN software will be sold along with an item of hardware. In order to allow a purchaser to 'test-out' the software, before making a purchase, it would be neat to have a series of plug-in components that emulate the hardware being controlled. e.g. in the case of the four channel relay board, a popup window might show the state of the four 'virtual relays' and allow these to be 'controlled' via a remote MSN session.

This approach would have the benefit of demonstrating the power of the software as well as checking that the program actually works on the users PC. Of course, the user has to buy the 'full version' before any comms to an RS232 port will take place.

Possibly protect this neat application from being used (unpaid for) by third parties. Some sort of 'private' handshake between the AVR2313 and the .exe on startup?

Might it be possible to run two copies of the .exe on one PC (each connecting to a different Comm port & MSN account)?

As the msn bot connects to the internet an authentication system that the bot must handshake with before allowing any internet connections could be used. This would be harder to bypass. ie a serial number used to register the product would be encrypted and sent to an auth bot to allow serial coms (or even better the keep alive function) so the product fully works but won't stay connected.

  • msnrelay/msnrelay.txt
  • Last modified: 2009/11/27 17:54
  • by 127.0.0.1