Showing off

Not that what I’m talking about in this post is something special or unique, but it’s just that the things I completed last week are a big step in the right direction – big enough to post about and show off¬†a bit in a small demonstration ūüėČ

It’s all a logical follow-up on the smart meter we have in our house since September 3rd of this year. I decided to transform this smart meter into a MQTT client so that my Domotica system wouldn’t have to parse the P1 datagrams every 10 seconds and filter what had changed since the previous datagram. Instead I used a SimpleCortex to parse the datagrams and made it publish new values to a MQTT broker (Mosquitto) and I added a MQTT client to my Domotica system to subscribe to the various smart meter topics. The last step in the smart meter project was creating a web page to display the information from the smart meter in real-time.

This all went very well; well enough to upgrade my Touchscreen application that’s running in the living room on a Asus Eee Top, from UDP broadcast to MQTT as well (to receive updated values from my Domotica system).

And I knew I had all the tools available to start working on another type of user interface – web based this time. So I bought a new Andoid tablet (we needed one for upstairs anyway), saw JQuery Mobile, liked it and just started developing and testing some basic web pages, all with the wish of being able to use this new UI on our smart phones as well.

And last week I completed the technical side of things – I (we) can now also control all our roller shutters and lights from our tablets, PCs, smart phones –¬†anything that has a browser.

And to show how it all works together, I made a small video showing (off) a light bulb being controlled in/from 3 different ways – a PC browser, a smart phone and the touchscreen application. Wow!

New User Interfaces

About 2 weeks ago I decided that something had to be done about the (number of) User Interfaces in our house. Especially for controlling the roller shutters from upstairs there was a need for a 2nd user interface. The touchscreen in the livingroom is being used a lot and we wanted the same convenience upstairs as well.

I’ve been tinkering with various touch screens on Arduino, FEZ Panda and the like, but I didn’t really like the size (~3″) and counting all the costs for a setup like that made me wonder if there could be a better choice. Why not buy a cheap 10″ Android tablet and make a web based interface? HTML5, websockets, ….

Setting Thermostat from smartphone

So I started looking around on the web for the right tools and I found jQuery Mobile.

The demos looked good, so I started creating some basic pages while keeping an eye open for a cheap tablet.

The first (test-)page I made was for changing the temperature setpoint of our central heating, just to see how hard it would be for me as a non-web-developer to create something that looked OK.

A slider, radiobuttons and an OK button were made very easy; it felt as if I’d done this before, but I haven’t – it’s very simple!

And if you look at the code (it’s great to create pages this way) I decided that jQuery Mobile will be it for the user interfaces I’m going to add.

And just look at the code; ain’t it sweet? ūüėČ

<div data-role="page" id="tstat">
	<div data-role="header">
	  <h2>Thermostaat</h2>
	</div><!-- /header -->
	<div data-role="content">
	  <br />
    <label for="slider-1">Hoe warm wil je het hebben jochie:</label>
    <input type="range" name="slider-1"
    id="tstatslider" value="20" min="15" max="25" step="0.5"
    data-highlight="true" />
    <br />
    <fieldset data-role="controlgroup" data-mini="false">
    	<input type="radio" name="radio" id="radio-1"
    	value="choice-1" checked="checked" />
    	<label for="radio-1">Tijdelijk (tot volgend
    	  programma)</label>
    	<input type="radio" name="radio" id="radio-2"
    	value="choice-2"  />
    	<label for="radio-2">Continu</label>
    </fieldset>
    <br />
    <input type="submit" value="OK" onClick='do it;'
    data-icon="check" />
	</div><!-- /content -->

	<div data-role="footer" data-position="fixed">
  <div data-role="navbar">
		<ul>
			<li><a href="#home">Home</a></li>
			<li><a href="#">Weer</a></li>
			<li><a href="#">Cams</a></li>
			<li><a href="#luiken">Rolluiken</a></li>
		</ul>
	</div><!-- /navbar -->
	</div><!-- /footer -->
</div><!-- /page -->

Yep, this is definitely what I want and what I need!
So I created some more pages (lights, the roller shutters):

And right now I’m testing this user interface, cause I want to know how well it performs compared to our VB.Net touchscreen application in the living room, before I spend more time on it. First results are very good – 10 times faster than X10 ūüėČ

There are some issues I have to work on; things like the buttons not giving an audible feedback, making it secure so that this can also be used on our smartphones, etcetera.

But for now I’m happy with how this working out so far. A tablet has been bought too yesterday, so it looks like we’ll have our user interface upstairs real soon!

Arduino with TFT Touch Shield

TFT Touch ShieldAfter the TFT Touch Shield I ordered had arrived and some playing around with the examples that were part of the library that can be found here, it was time to do some testing.

For starters I made a small sketch with just a string, 3 ‘touchable’ areas and an icon. The first challenge was making the drawLine() function from the library working; somehow it had problems with drawing the left side of the roof of the ‘home’ icon. No clue why, but it just didn’t work. Only after I changed the parameter types from unsigned int to int and replaced the algorithm with the simplified version of the Bresenham line algorithm¬†the home was correctly drawn.

Next thing I did was printing some touch related information to the Serial and this is what I saw:

X = 611, Y = 442, P = 575
X = 609, Y = 443, P = 536
X = 606, Y = 444, P = 507
X = 599, Y = 447, P = 457
X = 599, Y = 447, P = 449
X = 600, Y = 440, P = 486
X = 601, Y = 434, P = 522
X = 642, Y = 604, P = 470
X = 634, Y = 609, P = 468

Well, so far so good… on to the next phase!

Extra user interfaces

I’ve been looking for an easy way to add some extra user interfaces to my Domotica system, particularly for upstairs. Now that we have a bunch of Radiator Thermostats and Roller shutters both up- and downstairs, the wish for some extra User Interfaces (bedrooms, office etcetera) increased the last couple of weeks. Yes, the Radiator Thermostats can also be operated manually, but that’s not always that convenient; I want something more flexible and versatile.

Should I buy a tablet and put it on the wall? Neh, too pricy and therefore not expandable enough – we would be bankrupt before I could finish this project ;-).

Or is it better to create a User Interface for the¬†smartphones? Useless for this particular ‘problem’, cause we all have the habit of leaving our smartphones downstairs – no one has the urge to Tweet or call while in bed (yet…). Besides that, guests in our house should also be able to lower a roller shutter without too much hassle.

What I’d like to have is something small & simple, touch-driven, communicating wirelessly, with an easily adjustable User Interface without having to change the code too often and, if possible, suitable to take in your hands.

For that I bought this Touch Shield to tinker with during the next weeks. There are some nice videos that demonstrate what you can do with these Touch shields and they look well enough to give it a try. This particular shield can be used with the Adafruit library, which takes care of the low level stuff and provides functions for stuff like drawing lines, circles, rectangles and text on the screen Рwith an SD card it should even be possible to draw 24-bit BMP files Рwell, let that be be step 2 for now.

While this Touch Shield is on its way, I started thinking of how to make this Touch Shield cooperate with my Domotica system. As I said, I don’t want to change the sketch when I want to add another menu option or button or anything else that comes to my mind; the ‘definition’ of the screens, menus, buttons should not be defined in the sketch, but somewhere else. Preferably somewhere on the network in a file; another good option could be stored on a SD card.

This file should contain everything that can be regarded as being subject to change when multiple Touch Shields are going to be used throughout the house: menu options, shapes, buttons, colors, text, actions; so the basic idea is: 1 sketch which can handle multiple User Interface definitions, designed for a specific location/room.¬†So I definitely need some sort of¬†User Interface Markup language for that, like XAML¬†is. ¬†But the markup language to be used should also be really ultra-light-weight, cause we’re still dealing with an Arduino here, where RAM is limited and every bit of overhead leads to problems, very quickly. I mean, you could define a button like this:

<Button Background="Red" Foreground="Green" Content="Light on" Action="C02 ON"/>

but that will consume more memory than

B;BRED;FGREEN;TLight On;AC02 ON

So maybe I’ll create my own Markup ‘language’; we’ll see.

The way in which an action will be communicated with my Domotica system will be something comparable to how our Ethernet Doorbell communicates with the system; for example, when the touch of a button should result in a light going on or off, I can just let the Arduino send a string (the Action property in the examples above) to my system and it will take care of the rest.

Big plans, which also bring a lot of new challenges – and I’m sure, a lot of fun!

Updating the all-in-one remote

Pronto Media Player Activity

Pronto Media Player Activity

I got some complaints lately, from “the people in the livingroom”…

For me, the excitement is in¬†being able¬†to control everything, but not in actually¬†using¬†it in the¬†most convenient¬†way… so sometimes I just don’t finish what I should, just because it’s not that exciting anymore – it works, right? So on to the next job!¬†But this week I was remembered to the fact that I have to keep that WAF in mind a bit more. OK.. lets see how I can keep everybody happy again.

A new media player and a new A/V receiver make watching TV or listening to the radio a bit more complex, and I still hadn’t updated my Pronto to deal with those 2 new devices. So in June this year, when we started using the new A/V Receiver and media player, the number of remotes went up from 1 to 3 again; that’s a lot of new buttons to remember and too much for some; cause we’re all used to using just one remote for all A/V equipment – our Pronto TSU9600! A great remote, which can be totally customized to your own taste and needs. The complaints forced me¬†to do something about the fact that the usefulness of the Pronto had dropped a lot (or¬†slightly, in Onkyo terms…). Listening to the radio and using the media player were the 2 activities that had to be added to the Pronto and some other activities needed some adjustments.

I created a Prontoscript library some time ago which makes it very easy to communicate with my Domotica system. It’s based on XML-RPC and with some wrapper routines a single line of Prontoscript code ‘under a button’ can do just about anything I want: lights, A/V, viewing webcams, opening doors, whatever; as long as my Domotica system can do it, I can control it from my Pronto. As an example, here’s the script that will do all that’s necessary to listen to the radio (the last selected radio station, that is):

XMLRPC_SetDevice('NR709','POWERON;SEL_FM;VOL=26');

With just a single touch of a button on the touchscreen of the the Pronto, this script takes care of turning on the A/V receiver, selecting FM radio and setting the master volume to a preset value.

Was it hard to do this? No, it took me less than an hour.  But the result is, that now everybody considers this (home) automation project finished..

 

New Pronto TSU9600 firmware

Philips Pronto TSU9600

Philips Pronto TSU9600

Today i spent some time on my most expensive User Interface, the Philips Pronto TSU9600.

New firmware was released in December 2009 and also a new version of ProntoEdit Professional (PEP). The previous¬† major firmware update with a lot of new features was somewhere in July 2009, but due to lack of time i didn’t come very much further than updating the firm- and software and that was it. Now it was time to have a really good look at what this latest firmware and PEP version would bring. I must say, i’m impressed. It’s very clear that Philips has done a lot for making life of those who have to work with PEP a lot more pleasant ūüôā

For example the use of PS (ProntoScript) Libraries. Where my old configuration had a lot of the same code on each activity page, it can now be put into 1 PS Library and added to the configuration at system level; no more redundant code!

The HTTP library is also a big improvement. The code i had to interface with my Domotica system was based on a TCPSocket, but when i went through the HTTP Library, i knew i was only 1 step away from implementing XML-RPC on the Pronto. One thing i missed was a way to do a HTTP POST, but that wasn’t that hard to create myself:

  // Convenience method to send text to an HTTP server
  //
  // Parameters:
  //   aUrl      HTTP URL
  //   aBody     the body
  //   aCallback Callback to invoke with text data upon success
  function postHTTP(aUrl, aBody, aCallback)
  {
    var req = new HttpRequest();
    req.postBody = aBody;
    req.open('POST', aUrl, true);
    req.setRequestHeader("Connection", "close");
    req.setRequestHeader("Accept-Charset",
                         "*; q=0.2, ISO-8859-15; q=0.9, ISO-8859-1,utf-8");
    req.onreadystatechange = function (aEvt) {
      if (req.readyState === READYSTATE.COMPLETED) {
        if (req.status === 200) {
          if (aCallback) {
            aCallback(req.responseText);
          }
        } else {
          System.print("HTTP status: " + req.status);
        }
      }
    };
    req.send(aBody);
  }

Next i created an additional Javascript library and some wrapper routines, which make it possible to have the Pronto ‘talk’ to the XML-RPC interface of my Domotica system:

  var httpLib = com.philips.HttpLibrary;
  var msg = new xmlrpc.XMLRPCMessage("SetDevice");

  msg.addParameter(Addr);
  msg.addParameter(aValue);
  httpLib.postHTTP('http://xx.xx.xx.xx', msg.xml(), aCallBack);

Now all my User Interfaces (website, ASUS TOP, Pronto) are using the same interface to my system. That really makes me very happy!

After some testing, today i did a complete remake of 2 of the most used activities. And this time it was fun!; i can assure you, it hasn’t always been that way in the past… Now all i have to do is add a ProntoScript one-liner to the Button Action:

XMLRPC_SetDevice("XELOS","MUTE");

This is the script for muting my TV; with no additional code except for the PS Libraries.

I’m very satisfied with my Pronto and how Philips keeps developing new features for it; and i haven’t even come to the features of the latest release yet; there’s still a whole lot more to explore!

ASUS R2H as second Domotica GUI

ASUS R2H

This week the ASUS R2H arrived that i bought from a domoticaforum member.
I’m going to test the R2H and see if it’s suitable as a second GUI to my Home Automation System, next to the Asus TOP that is on the wall in the livingroom.

Maybe the Asus can be placed somewhere on the 2nd floor, or in the bedroom.
The Asus consumes 16W idle on AC Power and is quite audible, compared to the Asus TOP. You can clearly hear the fan blowing out hot air out of the upper heat vent. Time will tell if it’s to annoying. If so, i can always use the R2H as travelling companion on holidays.

I stripped the R2H from a lot of additional (memory consuming) software that’s installed out of the box to make it a bit more lean.
Next thing on my todo-list is develop a small application that should make the Asus R2H function as Domotica Interface.
Only a subset of the functionality that is available on the ASUS TOP will be added to the GUI, cause i don’t want to spend to much time on it; let’s first see if the ASUS R2H is suitable for the task and if so, i can extend the GUI with what i want.

Designing my own Home Automation UI

Ok, so now we have a Touch Screen in the living room. Time to design a UI that works. Not just for me, but for all of us. Where my first design was primarily based on using buttons with text to switch the lights, open the garage door or turn on the pump for the swimming pool, it didn’t feel right. It looked nice, but i just felt it wasn’t finished. Once you get used to using a touch screen, you start getting ideas to make things even better. So last weekend i tried a different approach by using a floor plan as background image and place buttons on it at the right spot:

Touch Screen UI

Touch Screen UI

So now i have a new screen layout that shows a floor plan with buttons for those things that are used the most. It also shows the current temperature in the different parts of the house and outside. By touching the stairs, you are taken to another screen that shows the second floor. And for specific functions like information about traffic, weather forecast, controlling music, TV, showing phonecall history and other things like that, i created a row of buttons at the bottom of the screen. This looks much better than the first design, which was just a bunch of buttons on an empty screen. But i don’t think this will be final; after using this new UI, new ideas will emerge and lead to yet another redesign.. and another… ūüôā

Asus TOP as Home Automation Touch Screen

A couple of weeks ago i bought a Asus TOP. It is an Intel Atom N270 based PC with 15.6″touch screen, 1GB RAM, 160 GB hard drive, Wifi and Windows XP Home. I’m going to use it in the livingroom as primary interface to my home automation system. For that i’ve been developing a VB.NET application that interfaces with my Domotica software system. Last weekend i mounted the Asus TOP to the wall in the livingroom at a central place. I really love the Asus TOP, especially the big surface of the screen, the abscence of noise compared to a regular laptop and the speed with which it runs my Domotica GUI.

ASUS TOP
ASUS TOP

Besides stuff like switching lights, devices by means of either X-10, PLCBUS or Plugwise, i’ve also made pages that shows all the incoming and outgoing phonecalls, weather forecast and maps, temperature and humidity in various parts of the house, but also pages that give control over the radio (stations, volume etc) and TV by means of the IRTrans i have. And ofcourse there are pages that show information about the traffic on the dutch highways and railways, etc. etc.¬† Just all the information and control you need on a daily basis, shown on a ‘big screen’ in the livingroom. The Asus TOP definetely is one of the coolest additions to all Home Automation related hardware i’ve bought in the last 12 months.