Introduction: Remote Control of Christmas Lights With Ether IO24

This project includes both software and hardware

Introduction:

This was a Christmas light controller I used one year to run a set of relays with the EITHER IO24 module, as I wanted to run them over the internet. The original project was completed several years ago. I added a wireless bridge to the network to make this a wireless Christmas light controller. The IO24 module was connected to a simple relay module there are several that you can get from the internet

This can be used either for direct control through the TK GUI, or can read a file, in this example called blink.blk which will allow complex patterns to be driven

For this setup I have 12 relays connected to the IO24 module, but more can be added, easily. The format of the code, and use of arrays should make an extension fairly strait forward for anyone that knows a little about programming

It looks fairly simple, but there were many versions to get to this point, I hope it will be useful for someone, it can serve as the basis for many other home automation tasks as well.

This uses UDP format with no checking so there is no confirmation the actions happened or not.

Caution: As Christmas lights are not safety critical there is no handshake to verify the command made it to the module, if using for other purposes, change this before implementing or you may get hurt when a packet is lost.

Step 1: Goals/Status

1.Direct control from the TK gui on a PC shown in the image

2.Ability to create patterns from a file that will run autonomously

3.Direct control through the file to allow complex scripts to be written later to generate patterns

4.Keep costs fairly low and complexity fairly low

1.Either IO24 was a low cost solution at the time (project is 2 years old)

2.PERL/TK are free and easy to program and distribute

3.Commercially available relay boards connected to the either24 board made the electrical connections very simple

4.The entire system was build in an old PC chassis which already had 5 and 12 volt power supplies to run the hardware

Status:

•The basic program and system are all in place and work well.

•The help, whats_next buttons are not functional, or needed

•Currently limited to one IO24 device on the network

•All communications are assumed to be on the local network, no effort has been placed into accessing for WAN side of the router (feel free to hack the code and re-post if you make this change)

Step 2: Shopping List for Hardware

1) Locate either a PC or Raspberry pi for the main controller

2) Elexol IO24 Ethernet IO module, --> https://www.elexol.com/IO_Modules/Ether_IO_24.php

3) Any relay boards that will interface to the logic, you can find these in many places, for instance if you go to Amazon.com and type "relay board" in the search several will come up. There are some available at Robotshop.com, and several others that you can search on Google.The main thing is to make sure it has a 5 volt logic interface as this is what the Elexol uses. For a good discussion on a board that will work with this part look at the following link.

http://www.electronickits.com/kit/complete/elec/ck...

4) Find an old computer case with installed power supply. For most of the relay boards you will need 5 volt and 12 volts available from the power supply. You can get these from Amazon, Fry's, or you may have on laying around the house already.

5) Fuses for all the relays to make sure we don't have an accident, I used in line fuses 5 amps each, shouldn't require a lot of current for these, make sure not to overload the circuit with the total load. These can be found at Digikey, Amazon, Mouser, or several other places. Also make sure the fuse rating is lower than the relay rating

6) Power cables to connect to the relay's. To save cost I purchased extension cords and cut the end off that wasn't needed. These you can get from Amazon, or a hardware store.

.

Step 3: Assemble the Hardware

The good news, is this is fairly easy to assemble now as there are not many components. Just wire the Elexol part to the relay board and the fuses and power cables up. Connect the 5 volts from the computer chassis to the Elexol board, and 12 volts if required connect it to the relay board. There are a few tricks to using a computer power supply there is an Instructable for this at the following link https://www.instructables.com/id/How-to-power-up-a...

For debug to start with don't connect the relays to wall power, just power the PC supply use the Elexol interface to test, you will hear the relays clicking if everything is working. Make sure they all click, and use an ohm meeter to verify the connections are correct on all the power plugs.

Also be very careful with the high voltage wiring, make sure to use lots of tape, and keep all enclosed in the power supply case, and don't forget the fuses. Make sure to have grommets as the wires leave the box to make prevent the wires from fraying which cause problems later. To prevent risk of shock close the case up before you connect the high voltage to the relays, use standard precautions any time you work with high voltage. If you don't know, don't do this project until you find someone who does to help you.

Step 4: Prepair the Software

If you simply want remote control you can use the Elexol board to turn on the relays. But if you are looking for more control you can proceed with the following steps.

1) Install Perl on your computer, Google will give you many examples on how to do this. If you are using the raspberry PI for this, it will already have Perl, but you will have to add the TK extension. You may also have to add the IO ::Socket module. There are may places on the internet that can help you with this step

2) Add the attached files to your computer

3) In most cases you should be able to click on lightblink10.pl and it will start. If not you may have to go to the windows input and type CMD. Then in the CMD window type "perl lightblink10.pl" to make it start.

Step 5: Software Buttons

The attached picture pretty much explains all the features of the program. The buttons on the right will turn on/off an individual relay, and will turn green when the relay has been enabled. the buttons on the left have some uses for debug such as all on, stop, and strobe. A few of the buttons don't have features yet as explained in the picture.

As this is an internet project the first task when using the interface is to connect to the module. To do this make sure the Elexol module and computer are both on the LAN side of the router. It can be helpful to have something like the "fing" app for the IPhone to make sure the module is on the internet before you start. When you are ready to start click the "connect" button. If all goes well the status will change to connected and the buttons will start working.

Also you may have some firewall issues with your computer depending on the configuration, my setup worked without any modifications. You can see in the program that $Port is set to 2424 so this port needs to be open on your computer.

The file name at the top left will be the input command file to execute, and the play_file button will start executing the file until the stop button is pressed or the file is complete which ever comes first

Communications background

This project uses UDP packets, and when doing the connect step there is a INADDR_BROADCAST to look for responses from the IO24 module. The program assumes there is only one IO24 module on the network, if you have more I don't know what happens, probably takes the last for first one found. The code could be modified to feed these responses into an array to expand to more modules. When the IP address of the response is captured, that is the device that the GUI will talk to. All communication are simple one way, with no handshake to assure completion. If the message gets clobbered due to traffic jams you will have to send again. This is rare that a UDP message fails to reach the destination.

Step 6: Writing Your Pattern in the Blink.bk File

The file attached earlier has some examples, but here is the detail breakdown of what you can have in the file.

GENERAL DESCRIPTION:

•In general the file can have comments throughout the file as long as a # is in the first character for each comment line

•There needs to be a tempo command at the beginning of the file to set the pace, usually set to 10, a temp of 10 will set 10 seconds between time units in the file

•There are two input formats to control the relays

MORE DETAILS ON HEADER DATA

•Key words, not case sensitive

–# at the beginning of a line is a comment

–Tempo = NN where NN is the temp and integer

•10 is common

–Loop = NN where NN is an integer for the number of times to repeat

MORE DETAILS ON FORMAT

•Details on lighting commands there are two formats

•Full addressing

•Direct addressing

•Format for the full lighting command is

•“time” “ |=“ integer , “light” = “state” “value”

–Details

“time” can be (time|t)

Integer can be 0 to 65000, and must be sequential

“light” can be (lNN|all)

where NN is an integer from 1 to 12

when set to all will do the same for all lights

“state” can be (blink|b) NN

where NN is an integer from 0 to 100

when set to 100 the light will be on all the time, when set to zero the light will not be enabled.

•Format for the direct lighting command is

–(time|t) ( |=) MM, h0xNNN

–Time|t is a command indicator

–MM is an integer time offset monotonic

–h0xNNN is a hex value to command all the lights 0 through 12 on.

EXAMPLES

Simple command to disable all lights

t 0, all = blink 0

Simple command to enable all

time 1, all blink 100

Simple command to turn on light 8 using shorthand notation

t 3, l8 = b 100

Simple command to force every other light with direct mode

t=5, h0xaaa

See the attached file for more examples. you can name the files anything you want to, but will have to make sure to change the name in the GUI, and add path if you place in a different location than the TKPerl script.