The Energy Detective

It has been some time since I got a TED 5000 unit (Nov 2009) – being able to visualize the whole house energy usage is pretty neat, and a nice motivator to see what you can do to save energy.  A while back it seems my TED had gotten stuck and was no longer reporting any usage.

Now this type of problem has happened before, so I wasn’t too surprised. I don’t check it regularly (my attention to it tends to be bursty) so it seems like every second time I go to poke at it, something is amiss and there is inevitably another firmware update available too.

The current versions are:

  • Gateway v1.0.383
  • Footprints v1.0.210

The upgrade instructions are clear and easy to follow. However, unlike previous problems a firmware update/reboot/power-cycle has not magically fixed the problem. Guess it’s time to poke around inside my electrical panel [warning – this can be fatal if you don’t know what you’re doing] and see if something is wrong.

There is a fairly good troubleshooting guide available, in my case it seems working through step 4 was was I needed to do. Finding out what was wrong was pretty easy, the red MTU wire was lose in the panel (Rant: why I don’t like having random people doing work in my house! This mistake was related to some renovations we had done).  Once I knew what was wrong with the hardware setup, it was easy to fix.

Then I noticed the new firmware seems to have some problem, here is the resulting graph:

After some further software / network diagnosis it seems that the gateway (webserver) is hanging up every once in a while. It appeared to be alive and responding for 140 seconds, followed by a 170 second period of failure. Looking at the graph, the red (voltage) square wave represents the alive (120V) dead (zero) pattern.

Ok, no problem let me just push the older firmware back on via the web interface. Bad idea – as the update took a bit longer than the 140 second window, and I managed to get the device into a non-responsive state. Now what?

Well, after some head scratching it occurred to me to download the installer program. This is a java based program, but thankfully it was able to find and restore my TED 5000. There were plenty of somewhat scary java error output messages on the console, but it did succeed after some amount of time. I also performed a full reset at one point – this too may have helped the recovery. So yes, I’m guilty of a bit of a hammer approach here – I’m just glad my TED is back to working. I will treat firmware updates with a bit more caution in the future.

I’m now using

  • Gateway v1.0.350
  • Footprints v1.0.185

Which may have bugs, but it seems to be working ok for me at the moment (at least my graphs are coming out ok).

There is a support forum which is somewhat helpful, but didn’t give me a great sense of comfort. There are a lot of very unhappy customers. The TED 5000 device is a very useful device, but has several technical problems.

  • There are many different (and valid) configurations to use the device in. I’m using one of the more simple setups, but the complexity impacts the software (firmware)
  • There are 3 different communication protocols being used: Zigbee wireless, power line communication and ethernet. Each has potential problems.
  • The firmware update is two separate files, and the web interface makes it too easy to do a bad firmware update.
  • The install of the device is non-trivial. So aside from firmware problems, the actual physical installation may be at fault.

External events can cause havoc too: Installing a new electronic device (or halogen light) may cause noise on the power line such that you disrupt power line communication. If you are using weather updates, there is an external web based weather service which needs to be reachable (and providing the service).

I keep meaning to cook up some RRDTool based graphs to track my usage as I really don’t like the built in TED web graphs all that much. There are also some nice DIY solutions out there for whole house power monitoring now.

I still like having the TED 5000, but I’m not sure I’d recommend it to people due to some of the problems. I’d love to see a simpler product that just provided the data stream and used a pogoplug or similar to handle the fancy graphing using an open source stack.

Unlocked iPhone 3G with 3.1.3

Jenn had been carrying around both her Samsung M300 and iPod Touch, far too often the phone wasn’t charged. Merging the two devices into an iPhone seemed like a sensible move.  She’s somewhat frugal like myself and doesn’t want to carry the cost of a data plan, so an unlocked phone seemed like the best path forward.

My first step was to locate a reasonably priced used iPhone.  With the new iPhone 4 out, you can just go pay full ticket and get an unlocked version if you want.  Yet, with the new model out – there are plenty of 3G and 3Gs devices on the used market.  I watched both usedottawa.com and ottawa.kijiji.com looking for a deal.  A good price was looking like $230 or so for the 3G, and $300 for the 3Gs (the 8Gb versions).

It only took a couple of days watching to come across a 3G going for a good price and I snapped it up.  There was one small snag when the previous owner decided to wipe the phone before I picked it up, they failed to plug it into power during the wipe and the battery gave out. This meant that the phone was non-functional when I got it, but as a bonus I ended up with a lower price.

Recovering from a bad wipe (or any other snafu with an iPhone) can usually be accomplished – you need to get into recovery mode, or if that doesn’t work device firmware update (DFU) mode. In my case DFU mode was what I needed. To get into DFU mode:

  1. Plug the phone into your PC
  2. Power it off
  3. Hold the Home button
  4. Hold the power/wake/sleep button
  5. After 10 seconds, release the power/wake/sleep button – keep holding Home
  6. Once iTunes detects the phone in recovery mode, release Home

The next step was to jailbreak the iPhone, this is necessary to install the unlock. Since I was using Windows to do this work (I didn’t want to mess with Jenn’s Mac) many of the how to guides didn’t apply.  I found one on iClarified.com that did work for me. There is some confusion as to if you need a SIM card to allow you to jailbreak with redsn0w or not – I did not need one installed at all in order to complete the jailbreak.  I simply followed the entire guide (including step 2) as I didn’t care about reflashing the 3.1.3 firmware (again).  It was easy – but pretty scary.  Read the guide completely and carefully.

After you’ve run redsn0w, you’ll probably want to reboot your windows box.  I found that without a reboot iTunes was not happy about the phone.

Now that you’ve got a jailbroken phone, you can install ultrasn0w to unlock it. The version of Cydia that was installed already had the correct repository enabled, so it was just a matter of installing it via Cydia.  I did find that Cydia was very slow, you need to be patient the refresh does take forever (15mins?).

Reboot the phone, install SIM card. Tada – I’m rocking an unlocked iPhone 3G. So very tempting to install this as the boot logo.

For what it’s worth, I did actually run through the entire wipe / jailbreak cycle twice. The first time something bad happened to Cydia causing it to completely fail for me. Re-doing the jailbreak worked fine the second time. One other useful resource I came across was jailbreakmatrix.com which helped me understand what options I had for jailbreaking and unlocking.

As you can see from the picture on this post, Jenn’s using PetroCanada Mobile as her provider. I didn’t have to do any magic to disable data usage, as the pay-as-you-go plan she uses has no data support.  There is something in the Cydia market that will let you control data usage if you need to do that. The iPhone works well as a phone, and sending an receiving text messages – data is provided exclusively over WiFi and for Jenn’s needs, that’s just fine.

When Android Fails

I really have myself to blame.  Android is the right smart phone platform for me: provided you have a rooted phone, you can get inside the device and tinker and there are community created ROMs which let you change the base system.  It is effectively an embedded Linux platform with a java like application stack.  I tend to follow the CyanogenMod crowd.

On my ADP1, I’ve got the developer friendly “fastboot”.  Using this you can install what is called a “recovery image” – a secondary boot mode which lets you get in and do maintenance etc.  Recently I found myself in a state where I had lost my recovery image.  The forum has some good basic advice if this happens to you.

As I found myself needing to reinstall.  The recommended recovery image is Amon_RA.  I used the fastboot flash method, from my Ubuntu desktop using the fastboot binary.  Once I had the binary, it really was as easy as booting into fastboot mode (hold camera button while phone is booting) and runnning the fastboot program.

fastboot flash recovery recovery_of_choice.img

Now what got me to this state of no recovery image, was most likely a finger fumble while I was trying to recover the phone from a bad state.  (Did I mention I was to blame here?)  Now I suspect there is some sort of latent bug in the Dalvik cache management that leads to this bad state, but I don’t yet have enough data to make a strong statement here.

What happens is at one point, apps stop opening properly for me.  Specifically things like the web browser.  The 1st time this happened, I ended up wiping the phone and starting again from scratch. While this is a recommended step if you’re going to play in the ROM scene, it is annoying to lose all of your state.  To my dismay it happened again.

The symptom is a boot loop when you reboot.  Using some of the tools from the Android SDK, you can watch things as they happen on boot.  I use ddms for this.  In the most recent failure, the loop looked like this in the log:

07-04 16:17:28.114: DEBUG/AndroidRuntime(249): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
07-04 16:17:28.114: DEBUG/AndroidRuntime(249): CheckJNI is OFF
07-04 16:17:28.284: DEBUG/AndroidRuntime(249): --- registering native functions ---
07-04 16:17:28.544: ERROR/AndroidRuntime(249): JavaVM unable to find main() in 'com.android.internal.os.ZygoteInit'
07-04 16:17:28.544: DEBUG/AndroidRuntime(249): Shutting down VM
07-04 16:17:28.544: WARN/dalvikvm(249): threadid=3: thread exiting with uncaught exception (group=0x4001e178)
07-04 16:17:28.574: DEBUG/dalvikvm(249): DestroyJavaVM waiting for non-daemon threads to exit
07-04 16:17:28.574: DEBUG/dalvikvm(249): DestroyJavaVM shutting VM down
07-04 16:17:28.574: DEBUG/dalvikvm(249): VM cleaning u
p

Not good.  Something can’t be found that is fairly critical, so the Dalvik system is continually bailing out on its start-up, then trying again.

The fix was quite easy (if we ignore the step where during the investigation, I mess up my recovery image).  The adb tool found in the Android SDK is much more powerful than I initially understood it to be.  We can use it to stop the Android sytem.

> adb shell stop

This effectively stops the boot loop from spinning around and around.  Now issuing:

> adb shell

Gets you into the device, and we can go and fix the filesystem.  I located and cleared the Dalvik caches (deleted the contents of the directories).
cache/dalvik-cache
sd-ext/dalvik-cache
data/dalvik-cache

You may only need to clear the 3rd one, but that is the list I cleared out to get back into a working state.  Much easier than a full wipe and reconfigure.