Thursday, May 30, 2013

Node.js, Raspberry Pi and irrigation control

This is my first post in a long time! I've experienced some severe burn out from a great many things. So after about 9 months I'm starting to get back to normal. So let's get back to Home Automation.

I have an ancient but working sprinkler controller. It's a very simple device and can control: 6 zones and 3, 14 day programs. For most of my needs it's fine (but when has that stopped me?). Also my wife could use a few more custom zones for her potted plants. The problem with the irrigation system is that it sometimes loses it's program and it isn't flexible enough (odd/even days, temperature, rain, wind, etc.) and no web interface. So I have a nice Raspberry Pi which can easily handle the control of a few zones (heck it could handle half a dozen easily). I've already completed one project with the Raspberry Pi, Python and the ADAFruit 16 port PWM driver. I've decided that I like Python and that's it's a nice language to work with. Now I have a tendency to want to play with new technology (it helps to keep up with things) and I've noticed node.js (Squirrel!). So far I've done simple things with node.js and it's been fun but I've decided to jump head first into node.js and use it to interface between the User Interface in the browser and the Raspberry Pi GPIO . I've found a nice Raspberry Pi GPIO library, a nice cron scheduling library and I've begun writing code. I've quickly learned that event based program is confusing when you are not used to it. I'm not convinced that node.js is perfect for many of my projects. I know I won't be using it for my home automation system as I need event based and real concurrency but I think node.js and the Raspberry Pi Irrigation Controller is perfect for this. So far I've been confused by callbacks, anonymous functions, variable scope, and a few other things. Loops are a real pain to do in node.js (forget for and while loops). Obviously I'm doing somethings very wrong as I have no experience with node.js but I must say I'm not too comfortable with event programming. It feels very unnatural especially when you have to wait for the callbacks to finish before you can go onto the next thing (config information that's needed for the rest of the program is not asynchronous). I really need to sit down and read a bit more but I have managed to get some basic parts working. I'm no where near done and I hope to have something operational within the week. Expect a lot of beginner mistakes and some kludges but working code. I'll correct things later.

As far as my main home automation system? I may look at Twisted and Python for the primary programming language for the home automation system of course we have Pytomation which may be a pretty good option.

Sunday, August 12, 2012

Toys, to hack @ IXR

Okay nobody told me ... I should be celebrating International Hack Day (August 11th), so I present my hack for today (a day late a dollar short ;-) ).

Okay, so I joined IXR to meet people of similar interests and to hack computer hardware. It appears I have some toys to hack. :-) IXR has these LED displays that are popular in small stores to post information, such as the current lottery payout. Each display can be programmed with an IR remote.

The displays store the messages and actions and the displays can display the messages and do a few fancy tricks such as flash. Well I opened up the device and found a simple Intel 8039 processor in it. There is an RJ11 connector on it and it appears to be connected to the INT line. My guess is that it's part of the IR signal communication that is sent to the device. I'll pop the bus pirate on the pin and see what it does. In the mean time I have ideas what to do with these displays (big evil grin). I should be able to reprogram the displays to accept new commands even to possibly communicate across a network (RS485 or XBee or Bluetooth possibly). That way messages would not only display on one display but could communicate across many displays. This would allow for more fine grain control of the messages and interface to a PC (using the remote is painful). The current EPROM is a 2764 (8K) so it shouldn't be too difficult to add a larger EPROM if the address lines are not in use. If they are then I'll need to be a little more creative.