Oh No! Hard Disk Errors!

I was so annoyed yesterday when I tried to set up a new TV recording on our MythTV system and it failed with an error message on the server.

This meant that we couldn’t watch any of our recordings and had to resort to recording/watching Sky+, which mere mortals think is fantastic but which is like going back to the dark ages once you’re used to a more capable system like MythTV.

Starting to investigate the problem this morning showed that the system disk had errors and had been set to read-only. I knew that this meant that a full disk check would be started on the next reboot, so I decided I should ‘go for it’ and reboot the system.

The server is ‘headless’ (i.e. has no display or keyboard attached) and as I knew that the disk checking process may need some interaction I moved the server next to the TV, attached a display cable and keyboard, and turned on the power.

The normal ‘Disk check in progress – please wait‘ screen was soon replaced by ‘Serious errors have been detected while checking the disk – Ignore, Skip or Manual recovery‘ – Oh ****!!

I thought I’d go for manual recovery and run ‘fsck’ manually; that way I should see what the serious errors were. At this point I came across something that I’d not seen before: the output looked like this:

 Pass 1: Checking inodes, blocks, and sizes
 Illegal block #9 (463536155) in inode 14109880.  CLEARED.
 Illegal block #11 (1275199487) in inode 14109880.  CLEARED.
 Error storing directory block information (inode=14109880, block=0, num=471166008): Memory allocation failed

Erm, what? Memory Allocation Failed?

After some googling I found a mailing list post from back in 2014 saying that in some instances the disk checking progam ‘e2fsck’ itself can be caused to crash by a particular pattern of corrupt data and suggesting a ‘hack’ to overwrite the specific corrupt data that is causing the crash.

In this instance the command:

debugfs -w -R "clri <14109880>" /dev/sda1

‘zaps’ the contents of the offending inode, overwriting the corruption that was causing e2fsck to try to allocate too much memory, and then fail.

Once I had run this command, then checked the file system again, the remaining errors were fixed and the system then booted normally. Phew!

The MythTV system is so much more capable that Sky+ that once you’re used to it it’s really hard to go back to something so much more basic and primitive.

Hopefully the disk corruption was a ‘one off’ caused by a power glitch and the system is now back to its usual reliability.

Weather sensors, databases and shell scripts…

After spending way too much time trying to get my Arduino Uno to reliably upload my weather sensor information to Weather Underground, first of all running out of program storage space, then upgrading to an Arduino Mega, then putting the ‘once every few days’ system crashes down to my ‘clone’ hardware, then spending time looking for bugs in Arduino library code, I finally decided that I was just trying to squeeze too much processing out of a tiny single-chip processor and to go for a total system redesign.

As I already have a linux computer running 24/7 running MythTV as well as hosting files in a RAID, I decided that it would be best just to do low-level sensor processing using the Arduino and to store the weather information, do the metric-imperial conversion that Weather Underground requires, and do the data uploading.

I already have MySQL on my linux server (installed by MythTV) and although I could have used that, I came across InfluxDB, a database written specifically to handle time-series data. Installing it took all of a few minutes and I soon was looking at this:

Screenshot from 2015-12-18 16:48:31

Creating a new database was a simple as typing ‘create database arduino’ and then I just had to modify my arduino code to send weather sensor data into the database. Again this proved to be just so simple thanks to the excellent information on the influxdb site HERE and again in no time at all I could see my temperature and humidity figures were being saved:

Screenshot from 2015-12-18 16:57:42

I’ll post some more information later about using Grafana to make a nice looking graphical dashboard display, but for now I’ll just cover uploading my weather data to Weather Underground.

WUnderground needs only an HTTP GET request to send data, with the protocol being described HERE, so it should be straightforward to pull the relevant bits of data out of the database, convert some Centigrade figures to Fahrenheit and so on, and actually do the upload. I was initially going to use PERL, but after a couple of experiments I realised that shell script could do the job with a bit of help from ‘bc‘ to do the calculations, so I ‘threw together’ this shell script and after a few test runs and with ‘cron’ set up to run it once a minute my WUnderground PWS (personal weather station) was back online.


# the round function:
echo $(printf %.$2f $(echo "scale=$2;(((10^$2)*$1)+0.5)/(10^$2)" | bc))

barometer=`influx -database 'arduino' -execute 'select * from ExtBaro where time > now() - 1m' -format 'csv' | grep ExtBaro | cut -d ',' -f 3`
BaromIn=`echo $(round $barometer*0.0295333727 2)`

exttemp=`influx -database 'arduino' -execute 'select * from ExtTemp where time > now() - 1m' -format 'csv' | grep ExtTemp | cut -d ',' -f 3`
TempF=`echo "$exttemp * 1.8 + 32" | bc`

intemp=`influx -database 'domoticz' -execute 'select * from MobileTemp where time > now() - 1m' -format 'csv' | grep MobileTemp | cut -d ',' -f 3`
InTempF=`echo "$intemp * 1.8 + 32" | bc`

exthum=`influx -database 'arduino' -execute 'select * from ExtHum where time > now() - 1m' -format 'csv' | grep ExtHum | cut -d ',' -f 3`
rain=`influx -database 'arduino' -execute 'select * from Rain where time > now() - 1m' -format 'csv' | grep Rain | cut -d ',' -f 3`
dailyrain=`influx -database 'arduino' -execute 'select * from "24hRain" where time > now() - 1m' -format 'csv' | grep 24hRain | cut -d ',' -f 3`

# Fahrenheit dewpoint approximation from https://en.wikipedia.org/wiki/Dew_point
DewPtF=`echo "$TempF-((9/25)*(100-$exthum))" | bc`

# Upload it all to WU
wget "http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=IFRESHWA2&PASSWORD=ImNotTellingYou&dateutc=now&tempf=$TempF&humidity=$exthum&baromin=$BaromIn&rainin=$rain&dailyrainin=$dailyrain&indoortempf=$InTempF&dewptf=$DewPtF&action=updateraw" -O /dev/null >> /var/log/wu/wulog.log 2>&1


Resurrecting my blog.

I can’t believe that it’s been four years since I posted anything here – and a lot has happened since then.

We now live in the Isle of Wight – quite a change from the Derbyshire Peak District in a number of ways, probably most significant is the weather, and it was only last week that I cut the lawn, and it really needs cutting again already. The weather is unbelievably mild for late November- over 13°C today – albeit with an incredibly strong wind blowing.

I will post more soon …


A Christmas Wish

If the following story helps just one dog from a rescue into a ‘forever home’ ….

Toby knew what he wanted for Christmas. The same thing everyone here wanted. A ring.
Christmas was close, he could feel it. Ribbons were hung on the walls, and there were special treats with dinner. More people came by to visit, and everybody was in a good mood. Except Emmett. When Toby shared with Emmett his Christmas wish, Emmett just shook his head. “Toby, you and I don’t get rings,” he said. “Look at us, a couple of losers who were given up on. It’s the youngsters that get rings.”

Toby looked at his reflection in his water dish. There was grey on his muzzle and along the tips of his ears. It was true he couldn’t play fetch like he used to. And his legs hurt when he walked too much. But he could still race to the front door when he heard it swing open, wagging his tail like a pup, and go on a slow walk around the block, sniffing here and there. And how he loved to curl up at the foot of the bed, keeping watch during the night. But those were the old days. Now he was here, with Emmett instead of with…

“See, here we go again,” Emmett said as puppies up and down the long hallway yapped and barked, a sign that people had just arrived. Emmett stretched out on the concrete next to his water dish. “Wake me when it’s over.” Toby peeked through the gate and saw a little boy and girl walking slowly his way. They stopped in front of almost every kennel, and sometimes they would kneel in front of one and laugh. Toby wished them closer, his tail wagging. He knew if they saw him, then maybe… just maybe…

“Don’t get your hopes up,” said Emmett, his eyes still closed. “You’ll only be disappointed.”
Toby looked down the hall. The woman in the blue shirt who brought food every day was opening one of the gates. A brown puppy bounded out and into the arms of the girl, who squealed with delight. From her back pocket, the woman in the blue shirt brought out a ring, pale grey, just like all the rings. She slipped it over the puppy’s head. “Everyone wants cute and adorable,” Emmett said as he heard the door close, knowing what surely had happened. “Years ago we were cute and adorable. No more.” But it was Christmas, Toby thought. Things are different at Christmas. There is happiness. There is cheer.
There is hope.

Toby remembered when he had a home and a bed and a yard and a person who loved him. But one day people came and they were crying, and the next day he was here. Now all he wanted was a ring, again. Emmett opened an eye when the barking started again but closed it as he stretched out. Toby pressed his muzzle to the gate and wished again.
“It’s Christmas,” he said. “A season for miracles.” He saw the woman in the blue shirt, and she had by the elbow a man walking very slowly down the aisle. They were talking, but Toby couldn’t hear them over the barking. They came closer. And closer. Almost, thought Toby. Almost. Toby squeezed his eyes shut. He wished harder than he had ever wished before. “Hey, fella, what’s your name?” Toby heard. He opened his eyes. Toby noticed the man had grey around his muzzle and more grey around his ears. He was bent over slightly, and Toby noticed a cane holding the man up. Toby wagged his tail and put his paw on the gate, and when he did, it opened.

The woman in the blue shirt reached behind her. There in her hand was a ring. Grey, like all the rest. But the man shook his head. Please, Toby wished. Please. The man reached behind him and pulled out his own ring. It was red and had green and gold stones that glittered in the light. He slipped it over Toby’s head. Toby was going home!

“C’mon, boy,” the man said. “Cute and adorable, you are. Lots of life left in you, fella.”
As Toby placed one paw outside the kennel, he stopped for just a little. Lowered his head for just a little. Glanced behind him for just a little. The man looked at Emmett, and Emmett looked at the man. “That one, too, if it’s OK,” the man said. “Looks like a set I’d hate to break up. My home may be a bit small, but my heart is big enough.” The woman in the blue shirt took the ring and slipped it over Emmett’s head.

And that’s when Toby knew Christmas miracles do happen.
Emmett wagged his tail and spun in a circle and barked. Just as if he were a puppy.

If you are as touched by this story as I was, and if you think you may be able to help, go to

Stove fan modifications

Well we lit the stove the other night .. and the fan started turning .. WOW! IT WORKS!

BUT .. after about half an hour the blades started to slow down and finally stopped. Checking the fan revealed that everything was rather too hot. The small fan doesn’t move enough air to cool the heatsink adequately, so both sides of the Peltier cells heat up to the same temperature and the fan stops turning.

I need a bigger fan – partly to keep the upper parts of the device cool enough, but also to move a bit more air around the room – while the fan was turning there was barely any perceptible air movement in the room.

Time to hunt for a bigger fan blade – and probably therefore a bigger motor so as to have enough power to turn it. I have more Peltier cells so if necessary I can redesign the base to accommodate a total of 4 cells.

Making a stove fan.

Over the last few days I’ve been making a ‘prototype’ stove fan.

The principle is that a thermoelectric or Peltier cell uses the heat from the stove to generate a low voltage which powers a fan. The fan then both cools the upper side of the Peltier cell to maintain the temperature difference and also circulates the heat from the stove around the room.

OK, so why don’t I just go out and buy one? Well, firstly they cost over £100, and secondly my techie geekiness wouldn’t let me! I’ve hardly used any of my metalworking skills (I must be one of the relatively few people with an ‘A’ level in metalwork) over the last number of years  and I really fancied having a go at making something.

I looked around on the internet for some ideas and found a video on YouTube showing how someone had made one using an old CPU heatsink from a PC (the Peltier effect needs a temperature difference across the cell to maintain he generated voltage, so while the lower surface of the cell is heated by the stove, the top surface needs to be kept cool).

With a second-hand CPU cooler, a low voltage fan, a couple of pieces of aluminium plate and a bit of metalwork and wiring it came together. Here is a close up of the Peltier cells sandwiched between the two aluminium plates.

Close up of Peltier cellsIt remains to be seen how well it works as we’ve not had any cold enough weather yet to light the stove, but initial tests with the fan standing on an upturned pan on the gas hob at least show that it works.I have 2 concerns, firstly that the top of the stove will be so hot that the Peltier cells will overheat, in which case I will have to do a bit more metalwork to make an upturned-U base to raise the base of the unit away from the stove top, and secondly that the fan won’t move enough air to keep the heatsink cool, so both sides of the cell will heat up and the fan will slow down and eventually stop.

Good old Dottie.

In an earlier post I mentioned our Copper Black French Maran hen, Dottie. Well, somewhat to our surprise (we weren’t expecting her to start to lay now until next spring) she has recently started to provide us with the most gorgeous chocolate brown eggs…

Dottie's first eggs

Unlike the ‘egg laying machine’ ex-battery hybrids which we rescued via the British Hen Welfare Trust we don’t expect her to give us a huge number of eggs, but when they look like this and taste absolutely gorgeous, what does it matter?

Cider bottling time!

Back in September we were lucky enough to be offered loads of windfall apples, and while I’d never made cider before we decided to give it a go. We first of all hired a fruit press from our local home brew shop, but after the first batch we’d kind of got the bug so we went out and bought our own press, kind of knowing that we’d be able to make loads of use of it.

Anyway, to cut a long story short, what at first looked like really muddy and sludgy apple juice (yet it tasted absolutey stunning) slowly turned into clear(ish!) and really nice cider!

We’ve already started to drink some of it, but it’s pretty much ready now to go into bottles and containers to be given as Christmas presents (and to be consumed by us of course!). I’d much rather leave it naturally cloudy rather than spending ages adding chemicals just to make it really clear.

Chilly Autumn Mornings!

It’s getting quite chilly in the mornings now (despite what the useless BBC weather forecasters would have you believe!). This morning the sun really seemed to be struggling to get over the horizon when I took this picture, looking up the Goyt Valley towards New Mills and Hayfield, with Kinder Scout in the distance. The chimney in the centre is the Swizzels Matlow sweet factory.

A really successful day!

Our garage and produce sale today has raised an amazing £257.50 for Lurcher SOS. Even the weather was kind to us with sunshine for much of the day and no rain! A really big thank you to everyone who came along and bought something or made a donation 🙂

This slideshow requires JavaScript.