Build your own baby monitor revisited

8 11 2012

(Quite) a while ago I wrote about my attempts to make my own video baby monitor. I had also written about a few other approaches as well, but they were pretty involved and complex and tended to break after a few days.

Wanting to simplify the approach and make it easier to set up, I came up with a slightly more refined solution that works much better. I’ve been using it successfully for about a year and it works with multiple cameras and screens. Now I have a second bundle of terror it has proved very useful.

Rather than trying to reinvent the wheel I decided to use products already out there, but ones that aren’t actually designed to monitor babies with and thus don’t have the crazy high price tags. I use an IP webcam, that connects to a WiFi network, this can then be viewed on any laptop or android device you have. It should also work with the iPhone as well, but not being a fan of Apple’s walled garden, I haven’t yet investigated this in any great detail.

The most important part of all this is the camera and I’ve stuck with the same camera I used last time, the IP Night Vision webcam. These can be found all over eBay, or there are also variants available on places like ebuyer.com and dabs.com. It has a WiFi and an ethernet network connection, night vision up to a couple of meters, two-way audio (so you can both listen to and talk to your baby – though I don’t suggest the latter, that is one big brother step too far) and it can be panned and tilted around so you can ensure the baby stays in view even if it moves. Most of these cameras are made by Chinese manufacturers, but some are of better quality than others. Foscam is a really good brand it seems, I have two and they have been running non-stop for the last year with no problems what so ever. The model I have used and would recommend is the Foscam FI8918W.

Foscam FI8918w

Foscam FI8918w

It is relatively simple to set up, you just need to connect it to your wireless network following the instructions included in the box. Once this is done you can then view the camera in many different ways. There is an internal web address that you can use to view it from any laptop connected to your wireless network using a web browser. You can also use the free media software VLC to view the video feed, the advantage being this approach also gives you sound and will work on pretty much all platforms supported by VLC (so Windows, Linux and Mac OS). I have written a number of scripts that can be run on Linux (Ubuntu) and Windows that launches the necessary video feeds and restarts the video every hour, since the audio can sometimes get out of sync with the video.

However, the best way to view the video feed I have found is via an Android app, called IP Cam Viewer. There is a free version which works perfectly for my needs, but if you want to say thanks to the developer, you can get the Pro version which is only a few pounds and gives you a few more features. I run this app on my Android tablet, an Android set top box and my Android phone. It allows me to view the the video feed of the two sleeping terrors on a TV in the kitchen using the Android set top box, anywhere in the house on my Android tablet or whilst out and about pretty much anywhere in the world (with a mobile data connection) on my Android phone. The app allows you to move the camera around if you need to and you can put widgets on your home screen that update as fast as once every second, so you don’t even need to run the app to see what is happening.

IP Cam Viewer in action

IP Cam Viewer in action

There is some technical cleverness that needs to be carried out to allow you to view the web cam outside of your wireless network on your phone, but this is very simple to set up and can be done for free.

All in all, this set-up works really well. So much so that the BBC just interviewed me about it! It is certainly a much cheaper and more flexible approach than the dedicated solutions on the market currently and rather than only being able to view the video feed on one tiny screen, you can view it on pretty much any screen you wish pretty much anywhere you want.

If you want to do this yourself, do get in contact via the Contact page. I might put together some more detailed information into a PDF, maybe with a “Pro” version that contains simple step-by-step instructions for a small fee or something. It seems all the rage these days ;)

UPDATE: Gosh, so the story has got a bit of traction on BBC News and I’ve got quite a few comments and emails to read through. I’ll read and respond to all your comments over the weekend and I am sure I can produce a PDF with instructions.

Glad other people are keen on this idea!





How to backup and sync your rooted Android phone automatically

1 03 2012

I have for a while now been working on a custom automatic sync solution for my HTC Hero running Froyo (Froydvillain ROM). As I am a Linux junkie and love scripts and hacks I wanted to do it all via cunning hacks and I’ve finally got it nailed.

This solution uses Scripting Layer 4 Android (SL4A) and Tasker alongside a custom ROM with rsync (any ROM should do so long as it has rsync). For those that don’t know, rsync is an awesome application that allows for remote backup and sync across machines. It turns out you don’t even need a ROM with rsync built in, as you can install an app that provides rsync, the app is called rsync backup for android and can be found here: https://market.android.com/details?id=eu.kowalczuk.rsync4android&hl=en

The only issue is you can’t call rsync from the command line using simply “rsync” since it isn’t in your systems path. However, if you use the following string instead,replacing calls to “rsync” with the following, the scripts still work: /data/data/eu.kowalczuk.rsync4android/files/rsync

SL4A is used to set out what to do via a script. You can write scripts in various languages in SL4A but I am using Bash as I am familiar with it. Rsync is used to actually handle the sync / backup and Tasker is used to launch the scripts when certain conditions are met.

I have created two scripts in SL4A, one backups my photos folder to my main photo folder on my server. The server runs the rsync daemon which rsync on the phone connects to. The other script does the reverse and copies a remote folder in my server that contains a bunch of music to my phone.

Tasker is set up with a profile that activates when my phone is plugged in and it’s between midnight and 7.00 am. This then connects to my WiFi network and then runs the two scripts via the SL4A plugin. Since I charge my phone each night this is effectively automatic.

The key here is getting permissions correct with rsync during the file transfer, as the memory card uses fat32 it hasn’t got any permissions. The rsync daemon doesn’t like this and errors out, hence the need for various settings. The second key here is exporting your password as an environmental variable. This is inherently insecure but since my server has multiple redundant backups and is only locally accessible I don’t care much. I could use trusted keys but I’m too lazy.

Here are the two scripts. First the music script that syncs from server to phone:

#rsync sync
export RSYNC_PASSWORD=password
DATE=$(date)
LOG=/mnt/sdcard/rsyncmusic.txt
echo rsync started $DATE > $LOG
TRY=1
rsync_com ()
{
DATE=$(date)
if [ $TRY = 15 ]; then
echo rsync failed, quitting on $DATE >> $LOG
exit
fi
sleep 10
echo rsync attempt $TRY started $DATE >> $LOG
rsync --progress -vHrltD --chmod=Du+rwx,go-rwx,Fu+rw,go-rw --no-perms --stats --password-file=/mnt/sdcard/scrt prupert@prupert::amusic /mnt/sdcard/amusic >> $LOG 2>&1
EXIT=$?
TRY=`expr $TRY + 1`
echo exit code is $EXIT >> $LOG
echo "********************" >> $LOG
}
rsync_com
while [ $EXIT != 0 ]; do
rsync_com
done
echo rsync finished $DATE >> $LOG
exit

The second script syncs the phones photos folder to my server:

#rsync sync photo
export RSYNC_PASSWORD=password
DATE=$(date)
LOG=/mnt/sdcard/rsyncphoto.txt
echo rsyncphoto started $DATE > $LOG
TRY=1
rsync_com ()
{
DATE=$(date)
if [ $TRY = 15 ]; then
echo rsync failed, quitting on $DATE >> $LOG
exit
fi
sleep 10
echo rsync attempt $TRY started $DATE >> $LOG
rsync -vHrltD --chmod=Du+rwx,go-rwx,Fu+rw,go-rw --no-perms --stats --password-file /mnt/sdcard/scrt /mnt/sdcard/DCIM prupert@prupert::apics >> $LOG 2>&1
EXIT=$?
TRY=`expr $TRY + 1`
echo exit code is $EXIT >> $LOG
echo "********************" >> $LOG
}
rsync_com
while [ $EXIT != 0 ]; do
rsync_com
done
echo rsync finished $DATE >> $LOG
exit

I have put some logging in to check progress and also some retry code that retries the sync if it timesout. It seems my HTC Hero’s WiFi connection claps out after a while so the script retries up to 15 times to run successfully based on the rsync exit code.





The Best, Most Useful and Most Awesome Android Apps

9 08 2010

I’m a big fan of Google’s Android OS and have been using my Android phone for about ten months now. It seems one of the most common questions on the interwebosphere related to Android is “What are the best Android apps?”. Well, I aim to give my small contribution to that question by listing the apps I use most often on my HTC Hero running Android 2.1.

First off, there is the choice over the biggest app of all, which version of Android to use. Although I use a HTC Hero, I am not a big fan of the Sense interface, so instead I have chosen to install a vanilla (plain) rooted version of Android. As I am using a custom ROM (the name given to the OS that the phone runs) I can choose to use a more modern version of Android than is currently available on the HTC Hero. Thus, whilst other UK Orange HTC Hero users are still waiting for Orange to get their update out there, I have been rocking Android 2.1 for over two months now. I use RaduG’s VanillaEclair ROM which is pretty damn perfect. For those that don’t know, the advantage of running a rooted version of a ROM means you can install certain apps that have added functionality and you have greater control over your phone, more about this later.

The second most important app (and from now on I am only talking about real apps here) is what Home app to use. The Home app is the one that you see and use almost all the time. It is the first screen you see after you unlock your phone and it is what displays the menu of all your apps . The default Android Home app isn’t bad, but there is certainly room for improvement. There are a number of Home apps out there, both free and paid for with various functions. I have settled on the rather awesome LauncherPro. LauncherPro is based on the stock Android Home app, but it has a myriad of improvements. First off, it has a dock at the bottom, that is fully customisable, allowing you to put shortcuts to apps, contacts and folders right on the bottom of your Home screen. Even better, you can have up to three docks, which you can swype between, so you can have 12 shortcuts. Furthermore, a newly released feature allows you to add a gesture shortcut to each of those shortcuts, so swiping up on a shortcut opens up another shortcut, so you can have in effect 24 shortcuts in all. As you can see on my screenshot, I have a shortcut for the browser, the phone, messaging and gmail. The middle “blocks” button takes me to my menu of apps. You can also see another excellent feature of LauncherPro, the ability to give message indications for certain shortcuts, in this screenshot it is showing I have 2 unread gmails, ooh, how popular I am. LauncherPro also features some of the more popular features from alternative Home apps, like ADW Launcher and HTC’s Sense – a “helicopter” overview of all your home screens and scrollable widgets, more about them in second. There are two versions of LauncherPro, the free version, called LauncherPro and a paid for improved version called LauncherPro Plus. LauncherPro Plus includes additional features (and more are being added all the time), the main ones are three built-in widgets: bookmarks, calendar and people. You can see the calendar widget in the screenshot to the right, it basically shows you your upcoming appointments. The great thing is that it is scrollable, so you can scroll through about a month ahead to see what is coming up. The people widget shows a pre-selected group from your contacts and is also scrollable, clicking on a contact pops up a context sensitive menu with various options to interact with that person. The bookmark widget shows thumbnails of all your bookmarks, though I have not used that widget yet, so can’t say more than that. I’d highly recommend the Plus version, if only to support the excellent developer of LauncherPro, as it is a one-man show.

My next awesome app is Tasker, but I have already mentioned this app in a previous post so I wont go on about it here. Basically, Tasker allows you to set up various profiles that enable or disable various settings. It essentially allows you take full control of your phone. Lifehacker wrote some cool guides on how to take full advantage of Tasker. You can see some examples of the profiles I use in the screenshot to the right. So, for example during the day, I turn on my data connection and auto-sync, but at night these are off, to save battery power. Another profile simply notifies me when the phone is charged, so I don’t leave it plugged in the charger for an age. It is an incredibly powerful tool and helps you take total control over your phone.

Up next is Titanium Backup. This app only works on a phone with a rooted ROM, as I mentioned earlier. It’s one of those awesome apps that you keep installed and only use occasionally, but is very useful when you use it. It allows you to backup all your apps and their associated data. Then, when you come to install a new ROM, you can simply restore that backup and all your apps, with all their settings as you left them. Nice. You can also use it to backup pretty much anything else as well, such as your contacts, text messages, browser bookmarks etc etc.

Next on the list is the rather awesome CoPilot Live v8. Whilst Google’s Navigation app is certainly useful, it only works online and gets into trouble if you veer off course without an internet connection – which in the UK can happen from time to time, especially if you are on Orange. CoPilot is in a whole different league when it comes to SatNav apps. It is just beautiful, works really well and is very easy to use. It has a few additional features, like nearby Points Of Interest indicators, the ability to route missing out toll roads and bridges and live tracking. You can buy maps for most of the major countries in Europe and the United States for a reasonable amount (way cheaper than the cost of maps for v7). I used it on an 8 hour round-trip and it didn’t flake out on me once. Because all the maps are stored on your SD card, it works offline, so you never loose where you are or where you are going. I wouldn’t be surprised if they come out with a new version next year supporting 3D models of buildings in major cities, ala Google Earth, but that will no doubt require the purchase of a new licence and no doubt a new phone to power it all!

Next on the list is the rather cool SystemPanel. This is a great app for keeping an eye on your phone to make sure it is running OK. It shows you which apps are running, how much memory is being used and which apps are thrashing your CPU (and hence killing your battery). It also allows you to monitor CPU and battery usage as well as data usage. Furthermore, it has an app archive facility allowing you to backup non-protected apps. It does have the ability to kill tasks and apps to “free memory”, but this is advised against, as Android is designed to use up as much memory as possible, just like Linux, so you are always going to be “low on memory”. Android kills apps itself if another app needs more memory, so task killers really aren’t useful. I use it if an app is misbehaving and to track down what app is maxing out my CPU and generally to keep tabs on my phone. It has a lovely GUI and is very reliable.

My final app that I would recommend is the BBC News widget by Jim Blackler. It might only be useful to users in the UK, although it does show World news if you want. It is by far the best news widget I have found. I did use AnyRSS Reader for a long time, but I never liked not having an image to view and it took up too much screen space. The BBC News widget takes up only one “slot” on your home screen, yet manages to squeeze a picture and an informative headline into that space. You can set it to regularly update throughout the day, so whenever you turn your phone on, you are always aware of the latest news around the world. You can see it in action in the screen shot a few images above, showing the news headlines (quite why the BBC thinks an article on being single is a news headline is any one’s guess, but that’s modern media for you) and David Cameron’s latest foreign policy gaff.

There is one more app that I use everyday, but it is quite specific to me. IP Cam Viewer is a great app if you need easy and quick access to images from an IP Webcam. I have a baby daughter and have set up a night-vision webcam to monitor her during the night and day when she sleeps. IP Cam Viewer allows me to keep tabs on her late at night and when it gets dark when we are putting her to bed. The developer of the app is very active, updating it constantly and it even supports audio from some webcams.

It worked perfectly with my cheap Fosscam ripoff from eBay (until I punched a hole through the microphone by accident and the plug literally fell apart in my hand!). If you need a way to view webcam images on your phone, I would highly recommend it.

That then is about it for my favourite apps on Android. Here are some other apps that I use occasionally that deserve an honorable mention: Astrid (for managing your daily tasks), Andromote (an awesome UPnP client), APNdroid (for turning off your data connection), Barcode Scanner (you know, for scanning barcodes), ConnectBot (for logging in to PCs via SSH), Dropbox (for sharing files), DroidWiki (for making awesome TiddlyWiki style notes), ES File Explorer (for browsing my files on the phone and on the LAN), Power Strip and Quick Settings (for quick access to various settings no matter what app you have open) and WaveSecure (for tracking my phone if it is lost or stolen and for backing up contacts online).

I hope you like the apps listed here. It is interesting to note that all the apps I have mentioned are paid-for. Whilst the majority of the apps mentioned here come in a “free” version, I find I like to thank the dev for all their hard work so am happy to upgrade to the fully featured versions.





Python Android Weather Forecast Script

28 04 2010

I am a proud owner of an HTC Hero Android phone.  I’ve recently  been messing around with one very cool looking application, that allows you to run your own scripts on the phone. This app is called Android Scripting Environment (ASE) and it is truly ace. You can use it to write and run your own Python, Shell (Bash), Lua and Ruby scripts directly on your phone. It also hooks into various Android features, allowing you to make use of various cool Android functions, one of which is getting your location and doing cool things with that information.

I’ve been wanting to get into Python for a long time and I decided that now was a good a time as any. ASE comes with a few sample scripts to get you going, one of which gets the current weather conditions for your current location and speaks it outloud (say_weather.py which calls weather.py). As cool as this is, being told the current conditions isn’t that useful, I wanted to know the forecast for the next day. I thus delved in and did lots of Googling, mainly using this awesome page that teaches you how to parse XML files (which is the format Google delivers its weather forecast info in). The biggest issue was the XML feed from Google doesn’t clarify the difference between the five day forecasts until you get to an actual data reading. The XML feed looks like this:

<xml_api_reply version="1">
      <weather module_id="0" tab_id="0" blah>
		<forecast_information>
			<city data="Bristol, Avon"/>
                        <postal_code data="bs167eb"/>
                        <latitude_e6 data=""/>
                        <longitude_e6 data=""/>
			<forecast_date data="2010-04-28"/>
                        <current_date_time data="2010-04-28 12:50:00 +0000"/>
                        <unit_system data="US"/>
		</forecast_information>
		<current_conditions>
			<condition data="Clear"/>
			<temp_f data="64"/><temp_c data="18"/>
			<humidity data="Humidity: 52%"/>
			<icon data="/ig/images/weather/sunny.gif"/>
			<wind_condition data="Wind: S at 16 mph"/>
		</current_conditions>
		<forecast_conditions>
			<day_of_week data="Wed"/>
			<low data="51"/>
			<high data="66"/>
			<icon data="/ig/images/weather/chance_of_rain.gif"/>
			<condition data="Chance of Rain"/>
		</forecast_conditions>
		<forecast_conditions>
			<day_of_week data="Thu"/>
			<low data="46"/>
			<high data="60"/>
			<icon data="/ig/images/weather/chance_of_rain.gif"/>
			<condition data="Chance of Rain"/>
		</forecast_conditions>
		<forecast_conditions>
			<day_of_week data="Fri"/>
			<low data="48"/>
			<high data="55"/>
			<icon data="/ig/images/weather/chance_of_rain.gif"/>
			<condition data="Chance of Rain"/>
		</forecast_conditions>
		<forecast_conditions>
			<day_of_week data="Sat"/>
			<low data="44"/>
			<high data="59"/>
			<icon data="/ig/images/weather/chance_of_rain.gif"/>
			<condition data="Chance of Rain"/>
		</forecast_conditions>
	</weather>

Now, I know nothing about XML at all, but I found it impossible to get the first actual forecast from the XML data, as each forecast was simply called “forecast_conditions”, using the method in the original weather.py. Thus, after reading the handy tutorial from faqs.org (listed above) I realised I needed to use the nested childNodes function of the xml.dom function that you use in Python to parse XML files.

After lots of trial and error, I worked out the following. A node is a name given to a section named via

<some_name>

. First, you assign a name (in this came dom) to the XML you are reading by doing: dom = minidom.parseString(xml_response), then I want to get information out of the node. To move through the nodes, you use the following command dom1Node = dom.firstChild where dom was the name of the original XML file. All this does is move to the first node and give it a name (dom1Node in my case), thus we are now at

<xml_api_reply version="1">

. You then use dom2Node = dom1Node.firstChild to move to the next node and give it a name, thus we are now at

<weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0">

. Finally, we have got somewhere, because the childNodes (i.e. the ones beneath the node we are at) are the ones with interesting info, such as

<forecast_information>

and most importantly

<forecast_conditions>

. So, finally, we can now assign names to these childNodes that we want. So we use current = dom2Node.childNodes[1] for the node (the numbering starts at 0 not 1) and forecast = dom2Node.childNodes[2] for the first forecast. Finally, to get the actual data out of those nodes, we use the following command data['flow'] = forecast.getElementsByTagName('low')[0].getAttribute('data'). What this does is give the name “flow” to the data element with the Tag name “low” from the “forecast” node that we defined just above. So, essentially, it navigates to and extracts the value “51” from it.

Thus, using this technique, you can get all the forecast data you want. I therefore ended up with this script, forecast.py, to replace the weather.py, to return forecast data:
And I then edited the say_weather.py to say the forecast as well as the current conditions, resulting in say_forecast.py:

The only problem I had with this was that the Google XML feed only appears to give the temp in fahrenheit, not celcius. I can see that you can set the iGoogle to display the temp in celcius, but I couldn’t see how to get that info from a feed.

Now, the next thing on the cards is to make a widget that displays this data on the homescreen. I was thinking of saving the output of the python script to a text file and then make a widget that reads that text file and displays the data. If I can do that, I can then modify the python script to do all sorts of cool things (get news, info from my mythtv HTPC etc).

Sadly, it seems on my version of Android (Cupcake (1.5)) you can’t call ASE scripts automatically via Locale or Tasker, since I get an ASE Force Closed message whenever I try to :( So these currently have to be run manually. Still, this is my first piece of Python coding and it was much easier than I thought it would be, once I got my head round it all.





locale VS Settings Profile VS Tasker

28 04 2010

One of the awesome things about Android is that you can customise it how you want and not how that floppy-shoe-wearing-control-freak Steve Jobs decides. There are various apps out there designed to let you change various settings and run various things based on various conditions. The most well known is locale, which was and is very popular, although the $10 cost of moving from the free 0.X beta to v1.X with a subsequent loss of function p!ssed a lot of people off! There are also two main competitors that I know of, Setting Profiles and Tasker. All of them have their strengths and weaknesses, some of which I will go through now.

locale

locale is generally pretty cool, yes, it is pretty expensive for an app, I think they kinda got greedy there, but it still works very well. Recent changes seem to have drastically improved battery life and it is very easy to set up.

You create a new situation, by first adding a condition, such as a time of day, your location (based either on GPS, WiFi or cellular) or orientation.

Then, you add a setting, some of which you can see from the screenie on the right. The cool thing is that locale operates a rather awesome plugin system, allowing you to expand the settings you can change and conditions that you can set. There are loads of plugins available on the market, some free, some paid. They allow you to enable and disable syc, give you fine control over volumes and even make http GET and POST requests, for example. My main gripe with locale is that to get decent functionality out of it, you have to use lots of different plugins, each one using up additional memory. On it’s own, locale doesn’t have that many options, which is a shame. Secondly, in order for it not to be shut down by Android, it leaves a notification icon in the taskbar. Some people find this very annoying, I personally find it useful since it means you can check what locale is doing. Oh, and also that it’s name is in italics ;)

Setting Profiles

The next app, Setting Profiles, is pretty similar to locale, but it doesn’t rely on a plugin infrastructure so much, having many more built in settings. The setup is very similar to locale, in that you create a profile, based on various conditions, of which there are many more than in the default version of locale. Then, you create rules that that profile will run, the rules can either be changing various settings (on the right), of which there are more options than in default locale, or running an app or posting a message. Overall, there are more built-in options and settings than in locale, making it more flexible. My only gripe with Settings Profile is that it doesn’t come with integration with Astrid, the awesome task (to-do) manger. Also, since it can’t be expanded with plugins, you are limited to the in-built features, though it does integrate with some other apps, such as APNdroid.

Tasker

Tasker is the final app in this showdown and one that I am least familiar with, having only used it for a few days. It is free, but still in beta and not yet available on the market. It seems there are plans to make it available on the market and for a price similar to Setting Profiles (so about half the cost of locale). It operates in a similar way to the other two, in that you set up profiles based on various conditions and then each profile carries out various actions. What is AWESOME about Tasker, is that is has so many built in conditions and actions, apparently it has almost 100 built in actions (see right), PLUS, it uses the locale API, so it can use locale plugins as well. For me, it is by far the most powerful out of the three and I have only begun to scratch the surface with it. However, I have found that not all the locale plugins work (for example the ASE and Astrid plugin) but I think these are known issues.

Overall, if I had to choose one, it is Tasker, which is the one I am currently using. It seems to have the most potential, the dev has lots of ToDos which all seem interesting and it is the most flexible. This isn’t to say the other two aren’t great, both locale and Setting Profiles are powerful good apps, I just prefer all the options that Tasker gives me. So, thumbs up to Tasker.








Follow

Get every new post delivered to your Inbox.