Alarm Panel – Programming settings

With the interface installed I needed an easier way to program the settings. Having to recompile the Arduino code each time you want to change something is pretty poor.

The V2 firmware supports

  • 16 zones, each with
    • Name (15 characters)
    • Enabled flag
    • Alarm flag
    • Cancel flag
  • 4 phone numbers, each with
    • Number (15 characters)
    • Enabled flag

Nothing too complicated but enough to get the job done. All the settings are stored in the EEPROM of the Arduino (atmega2560).

First thing I wanted was a simple command line interface. Worst case all you need to program the interface would be a terminal (something like Putty, TeraTerm, HyperTerminal, etc).

Being lazy its always easier to see if something already exists before you roll your own. Even if its not exactly what you want you can get some ideas. Lucky for me, with a few Google searches, I found the serial command library.

So simple, install the library, include the header, add a few lines and a few callback functions – done!

So now via the command line we can

  • enable/disable debug mode
  • update zone data
  • update phone data
  • display the current information
  • enter setup mode
  • turn on/of SMS message sending

This is enough really for the prototype – but – if you want to make it a bit easier for the average Joe to use then it’s time to a make a simple UI.

Behold – the alarm interface programming tool. Of course it looks like crap but it gets the job done. Simple operation Read the data, modify the data, and then write the data back.

Under the covers it uses the serial commands we defined earlier to to read and write settings. The hardware version and firmware versions do work but not in this early screen shot.

Program some settings

Cool – simple programming tools done – now to customize for my alarm panel and see if we get some SMS messages out!

Alarm Panel – SMS Interface Installation

For what seems like forever Simon and I have been working on an alarm panel to SMS gateway device. Mainly to be used with an existing alarm panel, this device will plug into the phone line socket of the alarm panel, allow the panel to “call” and then respond with the proper Ademco tones.

Click here for Simon’s blog posts on the hardware design.

With prototype V2 finally complete and the latest firmware uploaded it was finally time to give it a test run on my alarm panel. Now how to mount it and monitor it for testing? Here is all the stuff where I need to make it happen. Seems like a mess before I even start – this was after I cleaned up the original mess – sigh.

Alarm SMS Items What a mess

  • Alarm panel, alarm SMS interface, phone cable and GSM antenna
  • Raspberry Pi and USB cable for debug interface monitoring
  • 5V switch mode power supply module for the RPI
  • 12VDC Plug pack for the home automation gear
  • 12VAC Plug pack for the alarm

I decided to remove all the existing items from the wall and remount everything on a sheet and MDF. That will make it easier to mount things without the need to locate any wall studs. I roughly measured the wall area, alarm, RF receiver, and power point locations. Marked them up on a piece of MDF the let rip with the drill and jigsaw to get the power point hole removed.

A - Markup B - Drill C - Jigsaw

Looks nice, let’s hope it fits! Of course it did, was there ever any doubt? Now to remount everything. It all went pretty much to plan for a change. The alarm panel was slightly painful as it didn’t really have a lot of movement but some handily placed boxes took care of that.

It fits Remounted Almost done

I rewired my automation input module and finally installed the alarm SMS interface and RPI ready for testing.

Remember this is for testing so yes its all just spread over the shelf for now, the proper installation will not have the RPI and the interface will most likely be mounted inside one of the two cases with just the antenna on the outside.

Now finally I can start testing !



Code Generation Tool

Having to write a lot of simple code once can be tedious and error prone – having to write it again for another language is even worse. Having to maintain both is just plain stupid. It would be quite handy to use a tool to generate all this basic code for us.

In my case I want the tool to create my standard code for my home automation software. I started with Java code but wanted to do an application in .NET and I didn’t want to port* or maintain both code bases – especially if the exact specification was still work-in-progress.

* Porting of the underlying base CDEF library was needed of course.

  • plain old data objects
    • fields can be
      • basic types (int, long, string) or other objects
      • lists of basic types or objects
  • messages
    • requests and responses
      • fields can be
        • basic types (int, long, string) or other objects
        • lists of basic types or other objects
      • encoding and decoding of data into byte buffers
  • languages
    • Java
    • .NET

The input to the tool is a form of specification defining all of the details and I chose to use XML to represent this data. Below is a very basic example of a simple class and message.

Running the tool and generating the code gives me the new source files. Note that the CdefMessage class is essentially a byte buffer. There is a constructor that pulls the data out of the message and an encode function to do the reverse.

In Java we get the same thing more or less. Ordering of encoding and decoding each field is important so we can send the objects between applications written in either language.

Here is the .NET Error message code, the Java is much the same. You can see how I handle lists of data objects and how they get encoded and decoded as required.

There are a few other helper classes that get created to make everything work but already we can create all this basic code with very little effort, no mistakes and knowing that both language libraries are in sync. This suits me as I’m very lazy and the less I have think about the better.

Wall Switches Redux

Another side track/experiment

As part of my obsession with finding the ideal wall switch, I found these Livolo brand switches via Aliexpress. Aliexpress seems to be the “go to” place to find just about anything these days.

I ordered one single switch version VL-C301-81 and one four switch version VL-C304-81. Both without the option radio interface or the A/B switching options. The radio interface, after thinking about it, would have been quite handy–  oh well, they are cheap enough to order more if required.

Why these ones? Looking at the marketing images on the Aliexpress pages seemed to show that they are relatively simple in design, with an upper and lower PCB connected with standard headers. A nice point to be able to hack into it. Also of note to the hacking people among us one of the images showed that the top PCB appeared to have a PIC processor on board – hmmm.

Livolo Assembly

The idea was buy the switch, remove the original back PCB (the one that does the 240V and relay stuff) and substitute my own low voltage PCB – with simple connectors or more advanced CAN interface. The top PCB hopefully wouldn’t be any the wiser. The end result would be a nice looking touch switch that hooked into my home automation system.


The single switch plate went into service replacing the standard Clispsal switch my FutureTAB HQ office.  Installation was quick and easy – just make sure to turn off your breakers before playing with any mains voltage stuff – or better yet get an electrician to do it for you.

Another reason I want to replace all my switches with low voltage equivalents and have other ways to flick the mains to the lights/appliances/etc. I hate touching anything with mains involved.


I like the way they work. The touch area is quite tight around the indicated circle. The blue “idle” LED is very dim, barely visible in the dark, but it is far easier to find the switch in the dark. Generally blue is an annoying color, especially if its bright and/or in your face, but this one could have been a little brighter – maybe a hack for later. The “on” red LED I really can’t see when the light is on – so maybe its useful, maybe not – again maybe a hack to make it brighter. The relay clicking is no louder than a normal Clipsal switch – so nothing to gain there. It is also easier to turn on the lights when my hands are full with food/coffee/etc – less chance of spillage accidents – bonus!

I have a home theater sub woofer with one of these annoying bright blue LEDs – it has a  strategically placed piece of tape covering it up – A bright blue LED shining in your eye while watching a movie in a dark room — WTF were they thinking?

“Don’t Turn It On, Pull It Apart” – EEVblog

In my case I say turn one on, take the other one apart!

The photo above was exactly what it was inside – how nice of the Livolo marketing folks. The photos below show the top PCB that I want to interface with. Clearly visible are the four LED and touch switch areas with some clever use of the silkscreen underneath the clear plastic parts to aid in light reflection. The bottom of the PCB shows the PIC16F960 and the 14 way header used to connect to the bottom PCB. They have even included what looks like a PIC programming header – hmmm.

 Livolo Top PCB A Livolo Top PCB B

Stay tuned for details on how I go with the hacking experiments.


Wall Switches

Over the last few years another obsession has been low voltage wall  switches The requirements for a DIY home automation wall switch sounds simple enough.

  • low voltage (either pull up to V+, or down to GND)
  • momentary
  • control lines for an LED per switch (off / on)
  • look decent enough for family approval factor

The idea was to connect this switch to an CAN Input Module (switch) and CAN Output Module (LED) and then use the CAN messages to “do stuff” like turn on lights, etc, etc

I spotted these WattStopper LxS switches after a lot of searching the web. I ordered one of L5S ones to experiment with – tricky in itself to find somewhere to order it from that would deliver to Australia. It has 4 thin buttons and 1 larger button, momentary, and a single LED for the 4 thin buttons. So almost a match for the requirements and the closest I have found so far.


WattStopper LxS Switches

It’s not until you have it in your hands that you really think how you will hook it up …

Problem 1 – Electrical

The switch did not suit hooking up to my input/output modules directly. With all the redesigns of the input module I still didn’t have what I needed – typical. I pulled the PCB from the switch and modified it slightly to suit my needs – no big problem but you really don’t want to have to do this for anything but a prototype.

Problem 2 – Practicality

I didn’t think about it until I went to wire it up on the bench – to fully utilize this 5 button switch you needed 11 wires – 2 x 8 core CAT5 cables or 2 x 6 core security cables. Cable is relatively cheap, and if you’re pulling one cable, pulling two isn’t that much harder – but it still seems like a waste of resources. In the picture I have only hooked up the top 4 switches and the locator LED.

WattStopper Partial Hookup


One solution is to add smarts to the switch so it does what you want by replacing the stock PCB with my own PCB design. This way I can add the CAN bus directly to the switch, use RGB LEDs and so on. I don’t really like the idea of buying something only to throw part of it away.

Another solution is to make my own PCB and fit it to another standard wall plate – this has its ownset of problems and will be the topic for another post.



Information Displays – Part 2

Time to code … I suspect it wont take too long to get something up and running. For this I will use Visual Studio 2013 Express and code in C#, that way anyone can grab the code from Github and use it for themselves.

Get The Screen Up

LCD screens come in all sorts of resolutions and sizes, so to make this useful we need to able support different configurations. For development and testing we probably want it to run in window mode with smaller fonts, if you have a multi-screen setup maybe you want to to run full screen on your second screen, for installation full screen with larger fonts sounds good, portrait mode maybe?

I chose to have the configuration in an XML file so its relatively easy to edit and parse.

I added the ability to specify the background image at this point. Nothing particularly tricky so far but it loads and re-sizes the form,  and goes full screen on the required screen if needed. 

Adding Some Labels

We could just add Label controls to the Form inside VS2013 but that doesn’t really allow us to change the layout for our different setups. The simplest way to add text to the screen will be to define labels in the XML – It will be slightly painful to do x, y, width and height maths in your head but it will do for now. Hint: Someone could write an WYSIWYG editor I guess or something else?

Initial Label Types

  • static – Just static text – well duh
  • time – Using a timer update the label and print the current time in using the given format.
  • file – Update the label with the contents of a file with configurable refresh rate.

Check out the screen shot so far in window mode. The temperature, light and voltage data is read from files created by another application.

Next up well add code to connect to the server, and display the currently active events in a configurable “list like” view.

 Display Part 1

Configuration Part 1


Information Displays – Part 1

As part of my home automation experiments I want a way to display the current state of sensors or currently active events on an LCD screen and install the LCD screen (or screens) in convenient locations round the house.

The basics requirements of what it should be able to do are as follows

  • Show a prioritized list of currently active events with columns such as priority code, message, elapsed time, etc.
  • Each priority should have configurable colors (foreground/background/flash), sound (file, repeat)
  • Show the current date and time
  • Show some basic status of the application (offline, online, etc) in case a connection to the server is not available.
  • Show the current value of sensor/value type points (temperature, humidity etc)
  • Configurable background image(s)
  • Be able to run in full screen mode (i.e when installed on the wall) or window mode (easier for development or running on the desktop)
  • Be able to auto start the application when the machine boots up if required.

Nice to haves

  • Full screen mode – try to blank the screen when no-one is in the room?
  • Perhaps go silent when no-one is at home?

More things I’m sure, but can’t think of anything else at the moment.

Initial Use Case

The initial use case is to display a message and play a doorbell like sound when my doorbell is pressed.

For reference my front door bell is a wired switch connected to an input module. The input is configured as a momentary input, with a 10 second timer (see input #9 in the screen shot). When pressed the event makes its way to the server for other applications to see.

 CAN Input Module Setup


It sounds possible to implement this in a web browser but being lazy I cant be bothered to learn the latest html5, json, web socket, bootstrap, blah, blah, blah technologies … so initially I go with what I know best and implement this as a .NET application and leave a web version for another time (i.e. probably never) 🙂

Endless Revisions

I find when I’m coming up with my own hardware designs there’s always something else that would be nice to have, could be better,  or just different. Most likely it comes from having no fixed set of requirements up front. Perhaps the exact end application isn’t exactly known ahead of time as sometimes happens when trying to design generic items.

To this end I present the endless revisions of … the CAN input module .. over 7 years (yay for date codes on the PCB silk screens)

2006-05 CAN bus, 16 isolated digital inputs, DIP switch pull ups for each input, hardware debounce, unique ID chip, large aluminium enclosure, large 5mm plug and socket connectors. This version I threw everything in but its just too big and the cost was just too much mainly due to the enclosure but also the number of connectors. I never got around to doing the PCB end plates.


2006-11 CAN bus, RS485 bus, 8 non-isolated digital inputs, 8 open collector digital outputs, unique ID chip, small plastic enclosure, large plug and socket connectors. I think this one was modelled of the popular ADAM4050 module from Advantech. Simplify everything and reduce cost. It’s almost 1/4 of the size of the previous module and much less parts. Still just having the plastic case makes it ugly to install anywhere and look nice. Again I never got around to doing the PCB end plates.


2012-10 CAN bus, 16 non-isolated digital inputs, DIN rail plastic enclosure, screw terminals for inputs and RJ45 for CAN bus. Skip forward few years, I guess sometimes you never get a project “quite right” and you just have to do another revision. This one got most things correct in my mind. Cheap to make, single purpose by removing the outputs, nice to install on a DIN rail and standard CAT5 for bus interconnect and power. The case has a nice recess for the label for all the relevant installation details which is handy.


… but there is always something else … I was writing the firmware and saw that I could use 8 of the inputs as digital or analog inputs – so another revision …

2013-04 CAN bus, 16 non-isolated inputs, the first 8 can be optionally configured as analog inputs, internal pull up or pull down jumper for the analog inputs, DIN rail plastic enclosure, screw terminals for inputs and RJ45 for CAN bus.


Its 2014 and surprisingly I can’t think of anything to add feature wise, but that doesn’t mean there isn’t something else … that can be a topic for another post.