Wednesday, June 29, 2011

Overcoming Text Message Length Limitations

Most home status data like temperature and power status can be easily communicated within the approximately 160 characters alotted by most carriers. But, this limit might include other data, as Verizon says, leaving less for actual status data:

What is included in the 160-character limit of a text message?
The 160 character limit includes the sender's email address (if applicable), the composed message and, if provided, the subject and callback number.
But, that means no detailed video or pictures can be transferred, which might be interesting information about the home. Same for databases of home temperature history. And, although lots of temperature and I/O digital information, like house power status, can be packed into one message, it might not be easily readable by the recipient. For instance compression techniques might allow a great deal of data, but the result would require a program at the receiving end to make sense of it.

One way around this is to use a program at the remote end to do the data transfer, providing a friendlier user interface. A smart phone app could be written to do this, but I don't have one at this time to experiment with. A computer application program that sent and received text messages could also provide a good user interface. It would communicate with the monitor via compressed text messages (using email, for instance) but with the user using an interactive GUI.

Another way around this is to query the database of home data remotely using commands like 'Minmaxo 5' to report the minimum and maximum outside temperatures over the last 5 days. I currently have this command, and several more, implemented and they work quite well. Here is an example response to a query sent via email:

in temps last 5 days: low in temp 71 F on Wed Jun  8, 5 AM. high in temp 80 F on Thu Jun  9, 5 PM. Current: 76

  -----Original Message-----
  From: user@zouck.net
  Sent: Sun, 12 Jun 2011 20:41:46 -0400
  To: 443XXXYYYY@txt.att.net
 Subject: Minmaxi 5
>
>
--
==================================================================
This mobile text message is brought to you by AT&T

Monday, June 27, 2011

Twitter

Yesterday I mentioned that the home monitor can be commanded to periodically tweet its status, using the twitter name 'zouckhome'. The command to control tweeting behavior is actually 'Twit+' to turn it on, and 'Twit-' to turn it off. Here is the Tcl code fragment that processes incoming text messages and sets the variable 'twitterswitch' to 1 if the command 'Twit+' is received. 'twitterswitch' is tested periodically and if it is set to '1', a tweet with house status is issued:
 
        ## Twit+: Enable twittering status periodically and when alarms occur
        set regexp_twiton {(?:\A|\W)Twit\+(?:\Z|\W)}
        if {[regexp $regexp_twiton $body]} {
            puts "Enabling twittering"
            set response "$response (twittering enabled)"
            set twitterswitch 1
            regsub $regexp_twiton $body " " body
            incr commandsfound
        }
    
 
This code fragment is one of many in a procedure that processes every received text message. 

So, to enable tweeting, just send a text message from a phone or via email as described yesterday, with the string 'Twit+' anywhere in it. One way is to send an email with only the subject line:


Subject: Twit+



Sunday, June 26, 2011

A Few Notes

I should have said in my initial post that I am updating this blog from New Hampshire, and the monitor is working in our home in Maryland. This means I can't post photos or check certain physical features until I actually get back there.

I left the monitor working there and have been getting information for about a month so far, so it seems pretty solid. It is set up to measure inside and outside temperatures and house power status.

A nice feature is that the monitor can be controlled and queried via email, as well as by text messages from cell phones. Sending an email to the modem number using the aaaxxxyyyy@txt.att.net format will result in a text message being sent to the modem. It will then reply, if the message contains a valid command. One feature I enabled (from here, via email) using the command 'Twit+' is to have it periodically twitter a status message with temperatures and power status. The twitter account is 'zouckhome', and if you follow it you will see the format of the periodic status reports.

I also left out that the Asus netbook runs a special net book version of puppy linux, not the linux version it came with. I boot from an SD flash chip that plugs into the net book.

I selected Tcl/Tk not only for its flexibility, core simplicity and availability on multiple platforms, but the ability to create single file executables for these platforms called starpacks, which contain in one compact form the application and library code plus the entire Tcl/Tk runtime, so you don't have to install anything but the actual executable file. This is unlike any other software I know of, including Java, and makes for simple distribution and maintenance. Jean-Claude Wippler at Jee Laboratories is responsible for developing the starkit and starpack technology. For more on this technology see http://equi4.com/starkit/  .

Saturday, June 25, 2011

The Beginning

We spend increasing amounts of time away from our house, and I always worry about whether it is freezing in the house, pipes are leaking, power has failed, which can produce ugly consequences for food stored in refrigerators and freezers and whether the door has been opened, or left open indicating intrusions.

Here's a picture of the house in the winter of 2010, indicating one source of worry:



This blog is about my efforts to create a wireless monitoring and control system to answer questions about the basic state of our home. Not only that, but  that can be endlessly customized by adding sensors, remotely controlled switches and remotely accessed software to perform open-ended functions at home. I plan to update the blog as the design progresses. My hope is that others can benefit from my experiences in building their own systems.

The system needs to be reliable and inexpensive to operate on a monthly basis. In particular it could not require an internet connection at the home being monitored, since we live in a rural area that has only wireless internet connectivity, which is relatively expensive if used just for the home monitor. The availability of inexpensive GSM modems and text messaging (Short Message Service, or SMS) plans suggested their use for this purpose. GSM modems can be purchased for as little as $30 and AT&T cell phone plans can be had for as little as $30 every 4 months, with text messages costing about a penny ($0.01) per message if no voice time is used.

My first attempt at a monitoring system was to use a telit 865 GSM modem with an internal temperature sensor and multiple digital inputs and outputs. I connected one of the digital I/Os to a house power monitor to indicate whether there had been a power failure. The Telit modem allowed for running 'AT' commands issued in text messages, and with no programming I could interrogate the temperature of the chip (which was close to room temperature due to the low power dissipated on the chip) and the house power digital input bit. I rigged up a 6V lantern battery through some diodes and voltage matching circuitry to supply modem power when house power fails. I will not go into detail on this, my first blog entry, on this system since I currently no longer use the Telit modem.

The Telit approach was less flexible than I anticipated, in programming convenience (it uses embedded Python which I did not get going well enough to do what I wanted), I/O capabilities, database functionality and numerous other things I thought I might want to do with it. My current system is based on a USB GSM modem, which cost about $30 used, an old Asus netbook I bought several years ago (the first netbook on the market), a SIM card which I initialized as an AT&T Go-Phone account, an Arduino microcomputer board with 6 analog and 12 digital I/O lines and some custom circuitry to measure temperatures and digital bits. I program the system using Tcl/Tk, which allows me to run programs on a wide variety of computers, freeing me from needing to use any particular computer or operating system and allowing me to update inexpensively using newer cheaper laptops.

In development I use Dropbox to share source files between the Asus and my main development computer, an old IBM T42 laptop. I edit on the IBM, and run the programs immediately on the Asus computer.

The system uses wired sensors at present, but I plan to switch to using wireless devices based on the work of Jean-Claude Wippler at Jee Laboratories in the future. See http://jeelabs.org/

I'm out of time for now, but plan to continue ASAP.