<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Open Source Medicine</title>
	<atom:link href="http://www.ossmedicine.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ossmedicine.org</link>
	<description>Open Source Software +/- Medicine +/- Drivel</description>
	<lastBuildDate>Tue, 13 Dec 2011 10:52:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>GU10 halogen bulbs are bad &#8211; a year on</title>
		<link>http://www.ossmedicine.org/home_automation/12/gu10-halogen-bulbs-are-bad-a-year-on/</link>
		<comments>http://www.ossmedicine.org/home_automation/12/gu10-halogen-bulbs-are-bad-a-year-on/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 10:52:04 +0000</pubDate>
		<dc:creator>danfish</dc:creator>
				<category><![CDATA[home_automation]]></category>

		<guid isPermaLink="false">http://www.ossmedicine.org/?p=207</guid>
		<description><![CDATA[About a year ago I wrote of my move to low energy gu10 LEDS (http://www.ossmedicine.org/?p=138). A year on and I can now look at the results this has had on our electricity bill. I&#8217;ve gone a bit further than just &#8230; <a href="http://www.ossmedicine.org/home_automation/12/gu10-halogen-bulbs-are-bad-a-year-on/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>About a year ago I wrote of my move to low energy gu10 LEDS (http://www.ossmedicine.org/?p=138). A year on and I can now look at the results this has had on our electricity bill. I&#8217;ve gone a bit further than just replacing the bulbs in the kitchen and living space, and replaced every bulb I can with LEDs or CFL&#8217;s if no suitable LED bulb available. The result has been quite remarkable. Our quarterly electricity bill has gone from approximately £200 to £100, and this doesn&#8217;t take into account the energy price increases we&#8217;ve seen this year. Not one of the bulbs has blown (compared with at least one a week with the old halogens).</p>
<p>Overall a result!</p>
<p>I think the phasing out of incandescent bulbs is long overdue. I understand phasing out halogen bulbs is also on the cards. Makes sense.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ossmedicine.org/home_automation/12/gu10-halogen-bulbs-are-bad-a-year-on/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Recycle, Recycle, Recycle</title>
		<link>http://www.ossmedicine.org/uncategorized/11/recycle-recycle-recycle/</link>
		<comments>http://www.ossmedicine.org/uncategorized/11/recycle-recycle-recycle/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 13:54:49 +0000</pubDate>
		<dc:creator>danfish</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ossmedicine.org/?p=204</guid>
		<description><![CDATA[This morning during my post slumber repost, whilst watching &#8216;Curious George&#8217; with the offspring, a piercing scream of &#8220;B**l*cks, what is this stuff on my clothes&#8221; rang out from on high. Naturally I moved faster than a neutrino* and arrived &#8230; <a href="http://www.ossmedicine.org/uncategorized/11/recycle-recycle-recycle/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This morning during my post slumber repost, whilst watching &#8216;Curious George&#8217; with the offspring, a piercing scream of &#8220;B**l*cks, what is this stuff on my clothes&#8221; rang out from on high. Naturally I moved faster than a neutrino* and arrived upstairs before I&#8217;d left, to find the better half surveying clothes from her wardrobe with a grey fluffy mould on them. &#8220;There&#8217;s damp in the room&#8221; she proclaimed. Of course I immediately accepted full responsibility and proffered my lifelong apologies.<span id="more-204"></span></p>
<p><strong>Background</strong></p>
<p>The wardrobe of hers occupies a whole wall of the bedroom &#8211; probably 4m of wardrobes. My wardrobe space, on the other hand, occupies a width equal to the wavelength of light. They are fairly standard Ikea jobs that I installed 6 years ago when we moved in. They are against an outside wall of a house built in the 1910&#8242;s, ie no cavity insulation etc, and areconsequently rather cold and stuffy.</p>
<p>Two hours of dismantling a section of wardrobe revealed no damp, gushing pipes or <a href="http://en.wikipedia.org/wiki/Pixie">Cornish water pixies</a>. What I did discover were clothes packed so tightly that not even the tiniest wiff of air could circulate. My suggestion that maybe a cloths &#8220;cull&#8221; could be the answer was rightly met with a blow to the back of the head. An alternative solution had to be found.</p>
<p>Being of the geeky persuasion, I have a number of PC carcasses spaning two decades in the garage. The common element to all of them is the humble fan. A quick trip to Bodge-it and Quick, and I had myself a 70mm hole cutter and a number of vents. I&#8217;ve drilled two 70mm holes in the bottom of the wardrobes and two 70mm holes in the top. The bottom holes have been filled with the vents and the top ones have had 80mm fans placed over them to suck the air out. The 12v for these fans is being supplied from an old phone charger and is on a timer plug. The timer is set to come on for an hour a day when we are at work. Will it work?</p>
<p><strong>Disclaimer</strong></p>
<p>My wife is a saintly, mild mannered angel who wouldn&#8217;t hurt a fly (apparently it ruins the taste)</p>
<p>*otherwise known as the &#8220;Eric Pickles at a free buffet phenomenon&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ossmedicine.org/uncategorized/11/recycle-recycle-recycle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deterring foxes, the arduino way</title>
		<link>http://www.ossmedicine.org/home_automation/arduino/09/deterring-foxes-the-arduino-way/</link>
		<comments>http://www.ossmedicine.org/home_automation/arduino/09/deterring-foxes-the-arduino-way/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 13:10:01 +0000</pubDate>
		<dc:creator>danfish</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[home_automation]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.ossmedicine.org/?p=196</guid>
		<description><![CDATA[We&#8217;ve a real problem with foxes here in leafy South London &#8211; there&#8217;s a den in one of the gardens nearby. A neighbour feeds and medicates them to make them nice and healthy! Yes, I know they&#8217;ve got a right &#8230; <a href="http://www.ossmedicine.org/home_automation/arduino/09/deterring-foxes-the-arduino-way/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve a real problem with foxes here in leafy South London &#8211; there&#8217;s a den in one of the gardens nearby. A neighbour feeds and medicates them to make them nice and healthy! Yes, I know they&#8217;ve got a right to live as much as anything else&#8230;blah, blah, blah, but in the case for my defence they</p>
<ul>
<li>crap everwhere</li>
<li>dig up the lawn and vegetable patch</li>
<li>chew through everything, including goal netting, toys and garden hoses</li>
</ul>
<p>All in all I&#8217;ve have enough, especially with two young kids &#8211; the 2 year old is afraid to go out in the garden because of the foxes. I&#8217;ve already tried the deterrent powders, ultrasound devices and better fencing, but none of them work. After a bit of googling, it seems that the most effective (non-lethal) method is an infrared sensor attached to a water sprayer. They are widely available online as a complete package, but where&#8217;s the fun in that? <span id="more-196"></span></p>
<p>So, I present, the FoxDuino <img src='http://www.ossmedicine.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> &#8230;&#8230;well sort of. I&#8217;m awaiting a couple of parts but the basics are there and comprise</p>
<ul>
<li>A<a href="http://jeelabs.org" target="_blank"> jeenode</a> (arduino clone) &#8211; I&#8217;ve a few lying around</li>
<li>A <a href="http://www.coolcomponents.co.uk/catalog/product_info.php?cPath=36_57&amp;products_id=312" target="_blank">PIR sensor </a>- on order £6.51</li>
<li>A <a href="http://www.vendingspareparts.co.uk/product.asp?urn=9039&amp;c_urn=173" target="_blank">12v DC Solenoid Valve</a> &#8211; again a couple of these in the garage</li>
<li>Hose pipes and sprayers &#8211; again, no shortage of these.</li>
</ul>
<p>It&#8217;s quite simple really &#8211; Mr Fox triggers the PIR and the jeenode switches on the sprayers for 5 seconds in a nice sharp blast. Given the jeenode&#8217;s inbuilt wireless capabilities, I&#8217;ll get it to send out info on activation times etc.</p>
<p>More to follow when I&#8217;ve built the thing!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ossmedicine.org/home_automation/arduino/09/deterring-foxes-the-arduino-way/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Upstart and Python</title>
		<link>http://www.ossmedicine.org/ubuntu/03/upstart-and-python/</link>
		<comments>http://www.ossmedicine.org/ubuntu/03/upstart-and-python/#comments</comments>
		<pubDate>Sat, 12 Mar 2011 11:52:15 +0000</pubDate>
		<dc:creator>danfish</dc:creator>
				<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.ossmedicine.org/?p=180</guid>
		<description><![CDATA[I&#8217;ve got a Currentcost Envi device connected to my Viglen MPC-L. A python script runs on a loop parsing the data from the serial cable and sending it to a remote Mosquitto instance. The problem is that the exception catching &#8230; <a href="http://www.ossmedicine.org/ubuntu/03/upstart-and-python/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got a Currentcost Envi device connected to my Viglen MPC-L. A python script runs on a loop parsing the data from the serial cable and sending it to a remote <a href="http://www.mosquitto.org" target="_blank">Mosquitto</a> instance. The problem is that the exception catching bits aren&#8217;t very good..in fact they are rubbish. I should just take some time and effort to improve the script, but I&#8217;ve got the attention span of&#8230;.oooh, there&#8217;s a birdy out of the window. Anyway, at the moment the script falls over once a day or so, and stays that way until I restart it (via a screen session).</p>
<p>I&#8217;ve looked at a number of approaches, including monit, but have never got any of them to work very well. So step forward <a href="http://upstart.ubuntu.com" target="_blank">Upstart</a>. From the website -</p>
<blockquote><p>Upstart is an event-based replacement for the <code>/sbin/init</code> daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running.</p></blockquote>
<p>You can add a service to upstart by adding a configuration file to /etc/init/ and then running &#8220;sudo initctl reload&#8221;.</p>
<p>Here&#8217;s my config file for my python script</p>
<blockquote><p>description &#8220;CurrentCost Monitor&#8221;<br />
author &#8220;meeee!&#8221;<br />
start on runlevel[234]<br />
stop on runlevel[0156]<br />
script<br />
chdir /usr/bin/scripts<br />
exec /usr/bin/python currentcost.py<br />
end script<br />
respawn</p></blockquote>
<p>There&#8217;s probably more in there than there needs to be, but so far it&#8217;s been working for a week with no problems, so I guess I&#8217;ve got a working solution.</p>
<p>Anyway, a big thanks to Upstart and the team that are working on it!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ossmedicine.org/ubuntu/03/upstart-and-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Watering the Garden OSS style &#8211; A Year with (some) Open Hardware</title>
		<link>http://www.ossmedicine.org/home_automation/arduino/12/watering-the-garden-oss-style-a-year-with-some-open-hardware/</link>
		<comments>http://www.ossmedicine.org/home_automation/arduino/12/watering-the-garden-oss-style-a-year-with-some-open-hardware/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 22:11:10 +0000</pubDate>
		<dc:creator>danfish</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[home_automation]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.ossmedicine.org/?p=141</guid>
		<description><![CDATA[It all started with the seemingly simple question &#8211; &#8220;How can I water the garden without leaving my laptop/phone/sofa using tech?&#8221;. So during the last year I&#8217;ve been looking at a number of low cost, low power and partially open &#8230; <a href="http://www.ossmedicine.org/home_automation/arduino/12/watering-the-garden-oss-style-a-year-with-some-open-hardware/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It all started with the seemingly simple question &#8211; &#8220;How can I water the garden without leaving my laptop/phone/sofa using tech?&#8221;. So during the last year I&#8217;ve been looking at a number of low cost, low power and partially open source hardware devices for home automation and monitoring. I&#8217;ll share my opinions and thoughts on each of them.<br />
In no particular order I&#8217;ve checked out -</p>
<ul>
<li>1-wire</li>
<li>arduino and jeenode</li>
<li>currentcost</li>
<li>the joggler</li>
<li>a cheapo USB controlled 8 way relay from ebay</li>
</ul>
<p><strong><span id="more-141"></span>1-wire</strong></p>
<p>These were originally from Dallas Semiconductor, but  Maxim have now carried the brand forwards. They are not an open source design, but the individual components are cheap, and a <a href="http://www.owfs,org">good community</a> has developed to provide open source libraries. The devices can be connected together in a chain using simple telephone wire or cat5 &#8211; the maximum cable length is about 100m. Libraries have been written for the arduino to interface with these chips. A number of chips are available from temperature sensors to A/D converters and relays.</p>
<p><strong>Arduino and Jeenode</strong></p>
<p>The <a href="http://www.arduino.cc">arduino</a> is an open hardware platform based around the ATMega series of chips. As the platform is open, a number of clones have popped up including the <a href="http://www.jeelabs.org">jeenode</a>, which handily integrates an RF12 radio module at a price that won&#8217;t hurt your pocket too much. Additionally, the creator (&#8216;JCW&#8217;) blogs well and frequently, and is very helpful on the forums. They are programmable in C/C++ &#8211; not languages that I&#8217;ve had much previous experience, but it&#8217;s been fun nonetheless.</p>
<p>At my (medical) practice, we&#8217;ve put a number of jeenodes in the vaccination fridges to keep an eye on temperatures etc, logging to a central database &#8211; fairly basic in the scheme of things, but welcome change from the twice daily manual measurements and excel spreadsheets!</p>
<p><strong>The Currentcost Envi</strong></p>
<p>Not much to say here, but these energy monitoring devices are now fairly widespread, with some energy companies sending out units to customers for free. They are available with a serial &#8211; usb connector for linking up to a PC for data logging/analysis. I&#8217;ve written about them before <a href="http://www.ossmedicine.org/ubuntu/06/omg-the-electricity-bill/">here</a>.</p>
<p><strong>The (O2) Joggler</strong></p>
<p>These touchscreen Atom-based small PC&#8217;s have been sold by O2 in the UK for approximately 18 months. In the Spring, O2 dropped the price to £49.99 inc shipping and naturally a lot of folks snapped up the offer. The default software is a very stripped down version of ubuntu with a flash based interface on top. It uses EFI rather than BIOS which makes installing another OS a bit tricky. It also has only 1gb of on-board flash. A number of people have devoted their time to getting other OS&#8217;s running, including <a href="http://joggler.exotica.org.uk/">Ubuntu 10.10 and Linux Mint</a>.</p>
<p>Actually, when you look at it, only one of these pieces of hardware is Open Hardware (the arduino), but all are relatively inexpensive and have OSS libraries etc &#8211; which brings me to to the crux of my problem &#8211; each of the hardware solutions above have their pluses and minuses, and each will serve my needs in various ways, but how to plug them all together to create a modular, flexible, yet integrated system? Many people with far more talent in this area,  such as Andy Stanford-Clark, have developed their own solutions. What I&#8217;m trying to do is develop a framework that I can grow as my knowledge grows.<br />
But it needs a &#8216;backen&#8217;d to connect it all together. The rather excellent <a href="http://mosquitto.org/" target="_blank">mosquitto</a> project, by Roger Light has really grabbed my attention. It&#8217;s an &#8220;Open Source <a href="http://mqtt.org/" target="_blank">MQTT</a> v3 Broker&#8221; (to quote Roger) that has packages for ubuntu, amongst others. He&#8217;s also put together a rather nice python library (my programming language of choice, just because that&#8217;s what I stumbled on first). An initial sketch of what I envisage&#8230;.</p>
<p><a href="http://www.ossmedicine.org/wp-content/uploads/2010/12/fishland2.png"><img class="aligncenter size-full wp-image-163" title="fishland" src="http://www.ossmedicine.org/wp-content/uploads/2010/12/fishland2.png" alt="" width="680" height="532" /></a>The area I&#8217;m going to start on is the Mosquitto-Python Layer-Web Interface bit. The big question I need to know is there an OSS solution I&#8217;ve not found that does the same thing? Any feedback welcome&#8230;..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ossmedicine.org/home_automation/arduino/12/watering-the-garden-oss-style-a-year-with-some-open-hardware/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>GU10 halogen bulbs are bad</title>
		<link>http://www.ossmedicine.org/home_automation/11/gu10-halogen-bulbs-are-bad/</link>
		<comments>http://www.ossmedicine.org/home_automation/11/gu10-halogen-bulbs-are-bad/#comments</comments>
		<pubDate>Sun, 21 Nov 2010 11:43:55 +0000</pubDate>
		<dc:creator>danfish</dc:creator>
				<category><![CDATA[home_automation]]></category>

		<guid isPermaLink="false">http://www.ossmedicine.org/?p=138</guid>
		<description><![CDATA[When we moved into our current house we refurbished the kitchen and living area extensively. As was/?still is the fashion then, halogen down-lighters were duly installed &#8211; 12 in total. Not the low voltage ones, but the 240v GU10&#8242;s. In &#8230; <a href="http://www.ossmedicine.org/home_automation/11/gu10-halogen-bulbs-are-bad/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When we moved into our current house we refurbished the kitchen and living area extensively. As was/?still is the fashion then, halogen down-lighters were duly installed &#8211; 12 in total. Not the low voltage ones, but the 240v GU10&#8242;s. In retrospect, not the best idea to be honest. Each used 40w making a total draw of 480w. Additionally they blew at the rate of about 1 a week.  Say they were on 25% of the time on average, and £1/watt/year (at 100% usage), meant that these lights are costing near enough £120 to run (+ the cost of 52 replacement bulbs/year).</p>
<p> I tried LED GU10&#8242;s about 2 years ago and found them expensive and the light emitted far too &#8216;cold&#8217;. A couple of months ago I decided to give them another go and things seem to have progressed nicely. An eBay search coughed up a number of suppliers with a wide array of light colors and led numbers/bulb. In the end I went with this http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&#038;item=170565002537#ht_1468wt_907 (disclaimer &#8211; I have no commercial interest or connection with this seller!) and chose the 48 led &#8216;warm white&#8217; at the very reasonable price of £4.29. They draw only 3w each and I actually prefer the light from these compared to the halogens. The seller claims that the bulbs last for 50,000 Hours. I&#8217;ve only been using them for 2 months, so I have a long way to go before I can confirm that claim (25 years!). In summary, from a total estimated annual electricity cost of £120 (+ cost of replacement bulbs), we&#8217;ve now gone to an annual bill of £9! By my estimations, the bulbs will have paid for themselves within 6 months.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ossmedicine.org/home_automation/11/gu10-halogen-bulbs-are-bad/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Why do people &#8220;do&#8221; open source</title>
		<link>http://www.ossmedicine.org/ubuntu/10/why-do-people-do-open-source/</link>
		<comments>http://www.ossmedicine.org/ubuntu/10/why-do-people-do-open-source/#comments</comments>
		<pubDate>Sun, 31 Oct 2010 07:43:46 +0000</pubDate>
		<dc:creator>danfish</dc:creator>
				<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.ossmedicine.org/?p=124</guid>
		<description><![CDATA[My brother is taking a break from his career at the moment. He works in finance &#8211; I&#8217;m not sure of the actual details but I know it involves targets, bonuses etc. It&#8217;s a job a the heart of our &#8230; <a href="http://www.ossmedicine.org/ubuntu/10/why-do-people-do-open-source/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My brother is taking a break from his career at the moment. He works in finance &#8211; I&#8217;m not sure of the actual details but I know it involves targets, bonuses etc. It&#8217;s a job a the heart of our capitalist society. Don&#8217;t get me wrong, I have no problem with capitalism per se. However it does lead to another question  &#8220;Why do people &#8220;do&#8221; open source&#8221;. When I talk to people about open source, probably the most common question I get asked is &#8220;why do people write this software if they&#8217;re not being paid?&#8221;. I can see understand that thinking. So what really motivates us, not just to be involved with open source, but motivates us in general? I think this clip sums it up rather well. It&#8217;s 10mins long, but I&#8217;d urge you to watch it to the end, but skip to about 8 mins in if you&#8217;re inpatient. </p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/u6XAPnuFjJc?fs=1&amp;hl=en_US" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="640" height="385" src="http://www.youtube.com/v/u6XAPnuFjJc?fs=1&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ossmedicine.org/ubuntu/10/why-do-people-do-open-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OMG! The electricity bill!</title>
		<link>http://www.ossmedicine.org/ubuntu/06/omg-the-electricity-bill/</link>
		<comments>http://www.ossmedicine.org/ubuntu/06/omg-the-electricity-bill/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 15:14:51 +0000</pubDate>
		<dc:creator>danfish</dc:creator>
				<category><![CDATA[home_automation]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.ossmedicine.org/?p=78</guid>
		<description><![CDATA[The quarterly bill tumbled through the letter plate. Normally I just leave in the heap of unopened mail nearby but I decided to open it. Quarterly electricity bill &#8211; £430!! After uttering some choice expletives at high volume, I decided &#8230; <a href="http://www.ossmedicine.org/ubuntu/06/omg-the-electricity-bill/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The quarterly bill tumbled through the letter plate. Normally I just leave in the heap of unopened mail nearby but I decided to open it. Quarterly electricity bill &#8211; £430!! After uttering some choice expletives at high volume, I decided something needed to be done. A hour or two on a few money saving websites (mostly moneysavingexpert.com), I found a better tarrif, and more interestingly for the geek inside, a tarrif that included a free currentcost envi energy meter! These normally retail at about £45 and consist of two units 1)  a current clamp which you clip around the cable going into your fuse box and 2) a receiving unit that can be placed within 100ft (it&#8217;s wireless). It displays current watt usage, local temperature. More importantly it has a serial port on the back which spits out XML data every 6 seconds.</p>
<p>A serial port to usb adapter is available from the manufacturers for about £10, but a quick trip to google revealed that many mobile phones shipped with a USB cable that was in fact a USB &#8211; serial converter. I never throw anything away &#8211; to my wife it&#8217;s my deepest character flaw. Needless to say a quick rummage in my man drawer yielded 6 mobile phone USB cables. A win for the man drawer! (If the portuguese escudos ever gets reintroduced, I&#8217;m quids in by the way). Plugging them into the laptop and checking dmesg showed that 2 were indeed usb-serial cables. 10 mins with a soldering iron and an rj45 plug, I had a rather ugly, but free, usb-currentcost adapter. It&#8217;s now plugged into my revo running ubuntu 10.04.<span id="more-78"></span></p>
<p>There&#8217;s loads of info on the interweb about the structure of the XML feed that the currentcost device produces.</p>
<ul>http://stanford-clark.com/power/</p>
<p>http://chemicaloliver.net/programming/mqtt-mosquitto-and-php/</p>
<p>http://code.google.com/p/currentcostgui/wiki/MQTT</p>
<p>http://andypiper.wordpress.com/2008/04/27/current-cost/</ul>
<p>I am not a natural coder, but when I do, python is my language of choice.  It&#8217;s pretty simple to get at the serial port with the python serial module and then parse the xml data into something useful. Here&#8217;s the code I&#8217;m using &#8211; you have been warned, it&#8217;s ugly!!</p>
<pre>#!/usr/bin/python -u

import re
import MySQLdb

dbName = "db"
tblName1 = "power"
uName = "username"
pswd = "password"
hostName = "mysql_server_IP"

import serial
import shlex
import subprocess

pub_cmd = "mosquitto_pub -t cc128/raw -l -q 2"
pub_args = shlex.split(pub_cmd)
pub = subprocess.Popen(pub_args, stdin=subprocess.PIPE)

ser = serial.Serial(port='/dev/ttyUSB0', baudrate=57600)
db = MySQLdb.connect(host=hostName, user=uName, passwd=pswd,db=dbName)

c = db.cursor()
prevWatts = 0
deltaT = 0
prevTemp = 0

while 1:
        line=""
        line = ser.readline()   #read a '\n' terminated line
        pub.stdin.write(line)
        pub.stdin.flush()
        print line #prints the output so you can see it working
        m = re.search('.*[0]*([1-9][0-9]*).*',line)
        n = re.search('.*([0-9][0-9]):([0-9][0-9]):([0-9][0-9]).*',line)
        o = re.search('.*([0-9\.]*).*',line)
        if m is not None:
                watts = m.group(1)
                hours = n.group(1)

                mins = n.group(2)
                secs = n.group(3)
                temp = o.group(1)

                totalTime = (int(hours)*3600) + (int(mins)*60) + int(secs)

                if deltaT == 0:
                        deltaT = 6

                else:
                        deltaT = int(totalTime) - int(prevTime)

                prevTime = totalTime
                deltaTemp = float(temp) - float(prevTemp)
                deltaW = int(watts) - int(prevWatts)
                joules = (prevWatts + int(watts))*0.5*deltaT
if (deltaW &gt;= 40) or (deltaW &lt;= -40):
                    c.execute("INSERT INTO power (watts, joules) VALUES (%s, %s)",(watts,joules))
                    print watts+"W"

                    print hours+":"+mins+":"+secs
                    print temp+"C"
                    print deltaT
                    print deltaW
                    prevWatts = int(watts)
                else:
                    print "No Change"

pub.stdin.close()

pub.wait()</pre>
<p>Where does this put the data? Mainly it&#8217;s into a MYSQL database with three columns &#8211; stamp (timestamp, default value current_timestamp), watts, and joules. It&#8217;s also publishing it to a mosquitto instance running on the same machine. <a href="https://launchpad.net/mosquitto">Mosquitto</a> is an <a href="http://mqtt.org/">mqtt</a> message broker as used by <a href="http://stanford-clark.com/">Andy Stanford-Clark</a> in his twittering house. I&#8217;m just messing around with mqtt and I&#8217;m not entirely sure what I&#8217;m going to do with it, but what the heck.</p>
<p>The next stage is to graph this data to get some meaningful power usage pattern and display it on a webpage. Initially I used matplotlib, but nice as the graphs were, they loaded way too slow. I&#8217;ve now  moved to using google visualizations, the associated <a href="http://code.google.com/p/google-visualization-python/downloads/list">python API</a> and an addon for it called <a href="http://danvk.org/dygraphs/">dygraphs</a>. This now produces rather nice interactive graphs that can be seen <a href="http://fishms.homelinux.com/power.html">here</a>.</p>
<p>Rather worryingly it shows that the house has a &#8216;resting&#8217; power need of about 400w. It was probably more &#8211; I used to leave two &#8216;servers&#8217;,  the laptop and a macmini, powered on 24/7. I now use wakeonlan to power these up if needed. So now the only PC&#8217;s permanently on are the revo and a viglen mpc-l. Between them they probably only account for about 35W. I&#8217;ve also installed <a href="http://grano.la/">granola </a> on all my machines, which seems to be improving energy use.</p>
<p>On the domestic appliance front, the main energy gobblers are the oven, tumbledryer and dishwasher. I rather think the chest freezer in the garage may be accounting for some of the baseline consumption &#8211; it&#8217;s about 10 years old so may need replacing. To further isolate power usage, CurrentCost have some new &#8220;Individual Appliance Monitors&#8221; coming out soon, which will link into the CurrentCost Envi base unit. I will be first in the queue.</p>
<p>In the meantime, I&#8217;m taking the plugs off the tumbledryer, dishwasher, wife&#8217;s hair straighteners and her hairdryer. In retrospect, maybe not the last two&#8230;&#8230;&#8230;&#8230;I&#8217;m not quite that stupid.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ossmedicine.org/ubuntu/06/omg-the-electricity-bill/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Garden Automation Post 2</title>
		<link>http://www.ossmedicine.org/ubuntu/04/garden-automation-post-2/</link>
		<comments>http://www.ossmedicine.org/ubuntu/04/garden-automation-post-2/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 11:29:42 +0000</pubDate>
		<dc:creator>danfish</dc:creator>
				<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.ossmedicine.org/?p=50</guid>
		<description><![CDATA[Wow. This weekend it felt like the long and depressing winter we&#8217;ve had in the UK has finally come to an end. This has given added impetus to my automation project. I&#8217;m still testing stuff out at the moment, but &#8230; <a href="http://www.ossmedicine.org/ubuntu/04/garden-automation-post-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Wow. This weekend it felt like the long and depressing winter we&#8217;ve had in the UK has finally come to an end. This has given added impetus to my automation project. I&#8217;m still testing stuff out at the moment, but I&#8217;ve found an arduino clone with inbuilt wireless that&#8217;s nice and cheap &#8211; the<a href="http://http://news.jeelabs.org/" target="_blank"> jeenode</a>. I ordered a pair of the jeenode v4&#8242;s last Wednesday and they were delivered on Friday. Some self assembly is required and rudimentary soldering iron skills needed, but the instructions on the website are excellent. I did make a slight error &#8211; unlike the arduino mega which has an on board usb-ftdi combo, the jeenodes need a separate usb-ftdi lead&#8230;.which I didn&#8217;t have. That&#8217;s on order and I look forwards to putting them through their paces.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ossmedicine.org/ubuntu/04/garden-automation-post-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Goodbye Dr Crippen</title>
		<link>http://www.ossmedicine.org/medicine/03/goodbye-dr-crippen/</link>
		<comments>http://www.ossmedicine.org/medicine/03/goodbye-dr-crippen/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 17:12:04 +0000</pubDate>
		<dc:creator>danfish</dc:creator>
				<category><![CDATA[medicine]]></category>

		<guid isPermaLink="false">http://www.ossmedicine.org/?p=52</guid>
		<description><![CDATA[One of the stalwarts of medical blogging, Dr Crippen at NHSBlogdoctor has decided to retire. It was always a good read that held no punches. I didn&#8217;t always agree with him, but he&#8217;ll be missed.]]></description>
			<content:encoded><![CDATA[<p>One of the stalwarts of medical blogging, Dr Crippen at <a href="http://nhsblogdoc.blogspot.com/" target="_blank">NHSBlogdoctor</a> has decided to retire. It was always a good read that held no punches.</p>
<p>I didn&#8217;t always agree with him, but he&#8217;ll be missed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ossmedicine.org/medicine/03/goodbye-dr-crippen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

