Ventures of an ex indie game developer


It's fun to solder and build stuff with your hands! I'd forgotten how fun it is since I last built stuff 20 years ago.

The controller is an Arduino Leonardo, which I connect to a server via micro USB. It acts like a normal serial port with the USB chip built in to the micro controller.

The 230VAC-to-12VAC transformer for the horn is switched on and off by a solid state relay, the PIR (Passive Infra-Red sensor) is plain 5V. The current state is shown on the LED and I'll simply keep an on/off switch hidden away somewhere. (Didn't want to bother with controlling a pin pad.)

I use the Arduino pretty much as a control device, and keep the main program flow in a Python program on the server. The software on the Arduino is written in a C-like syntax which pretty much boils down to

where the "handleCrash" turns off the siren if nothing is heard from the computer in 15 seconds to avoid leaving the alarm on during vacation. I'm going to mount the horn on the outside of the house; neighbors tend to get annoyed if they haven't slept for a week or two.

The bulk of the code was very small, but I had to inject a bunch of failsafes, timeouts, sound indicators, e-mail alerting, logging and so forth to cram all the features I wanted in there. The current Python+Arduino code is 421 lines, and I also have an additional 100 lines of unit testing. I wanted to send SMS's as well, but it looks like a jungle so perhaps I'll just skip that. This is the bulk of the main loop in the computer code (stripped of sleeping, logging, etc.):

Remains to do proper soldering and installing. I'll do that when I'm done with our 104 m2 decking. Peuh!

About the author

Mitt foto
Gothenburg, Sweden