Sensor network

Further to my last post about the water level sensor, I have perused the interwebz and discovered the MySensor site. These fine folk have created a library for using the nRF24L01 or RFM69 radio transceivers along with Arduino technology and a slew of sensors to create a wireless sensor network communicating with a gateway.


They sell an nRF24 based board that includes the microcontroller, however, the RFM69 transceivers have better range characteristics. I have borrowed the (open source) pcb for the “NewbiePCB” for the RFM69 and ordered a few from Oshpark, and a pcb for a Raspberry Pi header connector for an RFM69. These boards will allow an easier and neater integration. I am not a great solder maven to begin with, so loose wires dangling will quickly become a tangled web of poor connections. Hopefully the PCBs will make for reliable connections and allow me to concentrate on software and functionality.


Among the sensors I am prototyping are the Bosch BME280 combined temperature, pressure and humidity sensor, an FS5 air flow sensor, and an addition BMP280 pressure sensor (for differential pressure). I intend to use these on the SPI bus (using a separate GPIO as CS for each sensor and the radio). The FS5 returns an analog reading, so it will have its own input.

Posted in technical | Leave a comment

Water Level Sensor

As mentioned over on my farming blog, I want to measure the water level in my water cistern. We depend on the cistern for all our drinking water needs at the farm. However, short of putting in a dip-stick, I have no way of knowing how much water I have left.

I am going to use an ultra-sonic sensor to measure the distance to the water (from the cap on top), and transmit that data via an nRF24L01 transceiver to my server. The sensor and transceiver will be hooked up to a mini arduino, and a battery pack. I may salvage a garden LED solar lamp for power.

The basic operation will be sleep for a minute. Wake up. Initialize the radio. Ping the sensor and take a reading. Send the data over the air. Go back to sleep.

I have outlined some of the communication protocol stuff here.

Posted in technical | Leave a comment

Samsung Chromebook Plus – quick review

After a strange experience with Amazon, I picked up my Chromebook Plus yesterday (Canadian Thanksgiving). At first glance, this is an impressive product. Sleek and crisp are the first two adjectives that came to mind as I removed it from the box. The stylish magnesium alloy body, the firm but smoothly opening hinges, the edge switches (power and volume), and the very thin rim around the ever so slightly recessed screen all contribute to a very classy looking machine.

The usual (I am so used to it I no longer notice it) lower case keyboard – the only nit I have so far is that the right hand edge of the keyboard seems ever so slightly truncated, leaving a narrow backspace, and a none-too wide return key. The screen is superbly crisp and bright (2400 x 1600). The pen (thankfully) has a positive “click in, click out” insertion dock, so I won’t lose it as easily as I have several of my seemingly identical Samsung Note pens.

Powering up, the keyboard has decent feel and travel. the trackpad is faithful and smooth – or at least it was until I used it with a wet finger, after which it messed up semi-randomly until it dried out completely around the edges – don’t do that! I was able to rescue myself as soon as I remembered that it also has a touchscreen. The overall interaction is buttery smooth, with a wonderful glidey feel to scrolling and moving around the screen.

I appreciate the 3:2 screen aspect ratio, which looks as good in portrait mode as it is in landscape, indispensable when you flip the keyboard and turn your laptop into a tablet. I intend to use it as a music score – and my initial tests show it as admirably suited.

The second thing I tried (because of the music score requirement) was Android. It ran the play store upgrade, and synched up the apps I own from my phone. The guitar tab app I use worked just fine (as one might expect from an app that is designed for tablet). I haven’t tried any more sophisticated android apps or games, because, well, time. I did have time to notice (in retrospect) that my brain treated it as an Android tablet once the keyboard was out of the way, but I had a hard time remembering the touchscreen in laptop mode.

The next thing I had to try (as I lay in bed late) was to install Crouton. This is the Linux side-by-side ChromeOS install from David Schneider. The machine took about 5 minutes to switch to developer mode (if you are going to try this, do it early, as it wipes your drive). Crouton xfce installed completely (I had to restart it once because I noticed an instruction for the Chromebook Pixel to add touch screen support right after starting it the first time), but it would shutdown the Chromebook every time I tried to run it. A quick google search revealed that the “xiwi” method might work (as opposed to the regular xorg driver). I ran the crouton installer again with the “-t xiwi -u” options (to upgrade the existing install, and make the xiwi driver default). I had to then add an X driver separately to complete the update, and lo – “sudo startxfce4″ worked, and not only did I have Ubuntu running, but it would also run inside a Chrome browser tab (which I can “fullscreen” using the dedicated key). Neat. I then installed “build essential” and some of my favourite apps (gimp, Libre Office), and things are off to a flying start before I succumb to the need for sleep.

The USB C charger is neat and much smaller than the power brick that came with my previous Chromebook. I still look for the “up” label on the plug – USB C doesn’t have it and doesn’t need it. Yay.

The speakers are much louder than the ones in my older Chromebook – audible over the hum of an A/C, and good enough when it is sitting on a bed (I used to put my Chromebook on a hardcover book in bed so I could hear it). They sound quite good, and it has a headphone jack for private/quality listening.

So far, everything seems just fine. Samsung and Google have a solid winner here. I find it hard to find fault with a solid product that meets every requirement I have for it, and looks and feels good besides. Given that my original Chromebook became my daily driver for the last 4+ years, I foresee a bright future for the “Plus”.

Posted in technical | Leave a comment

Mail server with local and virtual users

OK, so I wanted an Eierlegendewollmilchsau (Egg laying woolly milk pig). But Linux obliges (hooray), with postfix, dovecot, spamassassin and clamav. Postfix is the basic sendmail transport layer. Dovecot is the imap mailbox handler.

To add to complexity, my ISP doesn’t allow incoming traffic on port 25, so I use Ghettosmtp to relay mail on a non-conventional port to my home. Then I wrapped everything up in ssl using Letsencrypt.

Ports to forward on the router:

2525 => 25 (smtp)
143 => 143 (imap)
993 => 993 (imaps)
587 => 587 (smtps)

I ask Ghettosmtp to forward my mail to my server on port 2525. I configure my nameserver to point its MX records to ghettosmtp as per their specifications. It takes 24 hours for them to honour the request.

Sending mail is another hurdle. I setup postfix to relay outbound e-mail through my service provider.

My main resource for this setup task was the appropriate Ubuntu community help page. Some fidly bits include adding some “standard” folders that were ommited from the add-virtual-user scripts: Archives and Templates – although it seems that Thunderbird will cause auto-creation of the archive folder (and a year folder inside it) when you archive something. I also added a couple of stanzas to the dovecot.conf to allow local unix users to be hosted as well as virtual users, and SSL is not covered by the linked help document.

Finally, when I noticed that the spam-bots of the world had discovered me after only 4 days of operation, I added spamassassin to my setup. Details for setup including configuration files.

Posted in technical | Leave a comment

Add Development tools to the PiServr

As a developer, I would like continuous integration set up on my home server. I am most familiar with Jenkins, and that is part of the debian distro – so I decided to go that route.

$ sudo apt-get install jenkins

Connect via localhost, and configure security (before the next part). use local database, and matrix based permissions. Make sure to “allow users to sign up”, and add read overall permission to anonymous before adding another user and giving them full permissions. Then add yourself (as the full permissions user). Then you can go back and disable allowing users to sign up.

Edited /etc/default/jenkins to enable listening on the actual network interface so you can connect from your network (and port-forward your router to connect from the internet).

Posted in technical | Leave a comment

Privacy, security, low cost – The Self Hosted PiServr.

Your very own slice of Raspberry Pi can host all your personal cloud needs, with real privacy, for less than $100 all told.


Pictured above is a Raspberry Pi single board computer sitting atop a Western Digital Pi Drive – in my case a 1TB disc, which hosts this blog and a few other services.

A complete server solution, including MariaDB (open source SQL) and Apache web server. Not on the cloud. In your living room, or your office shelf. Consuming a few measly watts – cents per month. No Amazon bills, none of your data need be in the hands of the data giants. Now you can have your Pi and eat it.

Hardware costs in USD:

Raspberry Pi                          35.00
WD PiDrive Foundation edition 250 GB  28.99
Blue Square enclosure                 14.99
3A Power supply                       12.99
Total                                 91.97

The 1TB drive I use is available for a mere $30 more.

What can it do? I have more than 600 GB of files (mostly movies and music) on it. It hosts my blog sites, and a mediawiki site which I use for project documentation. I have two printers (an HP laser and an Epson inkjet) connected to it, so we can print from anywhere in the house (including from my phone or Chromebook). I can play my music through a connected stereo. I can even access the Pi remotely, using either ssh and a command line or using X11 forwarding to run graphical software from any X Window capable computer (running Linux or Cygwin X-Window).

This project will make available a downloadable image, which you copy to a micro-SD card. This image boots your Pi. Then you connect to your Pi using a web browser (Chrome, Firefox) and enter some simple configuration details to enable each web service. Modify your router’s forwarding to connect your Pi’s services to the internet. Then use a dynamic DNS service to locate your server from the outside world.

Posted in technical | Leave a comment

Now super secure-ish!

Whoopie! I have just successfully installed strong ssl encryption (https) for this WordPress blog. Thanks entirely to the great folks at letsencrypt – with a generous G+ prompt in my feed from +Steven Vaughan Nichols. I say Secure-ish because I hate to tempt fate (or hackers) with over confidence, and as has been said, WordPress has a reputation for insecurity.

Posted in technical | Leave a comment

Ram 1500 ecodiesel review – 6 months, 30,000 km

I have owned Big Blue, my 2016 Outdoorsman ecodiesel for just over 6 months, and driven just over 30,000 km. I have made one significant trip – driving from Hamilton to Orlando and back for a disney vacation, made my daily 65 km commute, and towed Marshmallow (an 11 year old Percheron Mare) 3 or 4 times in her gooseneck trailer. My daughter is a frequent rider in the back of the Quad cab, as well as a couple who sometimes ride-share with me on the work-commute.

Throw in sundry trips to the hardware store (4 x 8 ply, 12′ cedar planks etc), grocery shopping, taking the dogs to the park and you get the life of Big Blue.

She is the Outdoorsman rig, with 4×4, skid plates, tow hooks, trailer mirrors, trailer tow brakes, limited slip diff, Quad cab (like extended in other brands), 6’4″ bed, in dark blue (Blue Pearl) with black lower panels and grill. I took the Comfort package (I hate the cold wheel in the winter), and the deluxe package (which had the multimedia options I consider necessary these days), and the electric sliding rear window. The only option I am not convinced of is the rear window. I did not take the backup camera (and it might have saved me a replacement taillight – cost 175). One serious gripe I have is with the ordering process. Both the online customer facing build tool, and the salesman’s ordering tool, showed that the outdoorsman package would come with the low ratio rear axle (for greater towing capacity). However, the higher ratio was delivered, and we were never able to resolve why, or make some satisfactory arrangement to compensate for what I felt was a mistake on their part.

I have not babied the truck – I haven’t really washed or waxed her since owning her, and I have made small “bondo” patches to the rear after scraping it a couple of times (and busting a taillight) due to my underestimating her size.

My average MPG is 25.56 Miles per US gallon (30.7 miles UK gallon), or 9.2 l/100 km overall. This includes all the driving types I mentioned, over a total of 30,302 km. My mileage has been tracked on, a handy web site that enables you to track mileage fill-up by fill up.

So far, I have had 2 oil changes – every 12000 km. These have been quite expensive – the first at $175, second was around 350 as they did some other maintenance work – tire rotation, brake, exhaust and suspension inspection. I am left not terribly happy about the second service – I will double check the invoice for the work done. That said, the truck has performed perfectly, with 0 problems. I had a gooseneck hitch fitted (by Hitch City) a couple months ago for trailering our horse, which cost around $1000. The next thing I really need to do is to get the truck lined. I plan to buy a bucket of the liner stuff and paint it myself (being a cheap Yorkshireman as my wife says). I have found a source for oil and filters online which would cost me about 150 per oil change – not much saving, but I sometimes like to do it myself anyway. Before our disney trip, I purchased a soft tonneau cover online for about 275.

So now for the driving. The truck rides really well – smooth and well behaved, not jittery and “truck like”, thanks to the all round coil springs. Under load, or towing she rides even better – towing the gooseneck with Marshmallow aboard with great aplomb – all in a days work, and averaging under 15 l/100 km while towing her. The bed lights are great for fishing stuff in and out of the back at night. There is sufficient room in the back even for occasional adults, and I am happy that I chose the Quad rather than the Crew cab – the bed length is good. If the truck was any longer, parking would be next to impossible on my street. As it is, I have to park within an inch to avoid sticking out fore or aft over my neighbour’s driveways.

Acceleration is somewhat modest from start (I was driving a Fiat 500 before this truck), but passing at speed seems fine, and towing power feels good. Turbo lag is somewhat pronounced (compare to my wife’s VW diesel), but not a problem when you get used to it. The brakes are great. The tires are pretty grippy in poor conditions – she felt really sure footed in the tail of of Winter in March earlier this year. The driving position is great, with a commanding view of the road, and reasonable over the shoulder visibility. The mirrors are really good, almost eliminating the blind spot. The seats – firm fabric – are comfortable and very adjustable including lumbar support – good for my back considering how much time I spend in this truck – about 3 hours daily.

The Disney trip was a good test at 2 months and about 7,000 km in. I got my best fuel tank on that trip, making 8.3 l/100km (28.3 mpg US or 34 mpg UK) on a stretch coming back up the coast through South Carolina and Virginia. She pulled up and down the Apalachians like a champ, the 8-speed gearbox switching away handily, but never making me feel unnecessarily. The ride was comfortable (as a 10 hour a day drive can be). On my daily commute, I still average about 9 l/100 km, on an average speed of about 80 km/h (mostly 100 but some start-stop in traffic).

As a cost-benefit analysis of the diesel, I look at for my consumption. I have paid $2,359 in fuel over 30,302 km. If I had purchased the 5.7 Hemi (the pentastar would not have met my towing needs), with an average consumption of 14.7 l/100km, I would have spent about $4,000. So I saved about $1600 in 6 months. Factor in the extra cost of the diesel – $5,700 – 1400 for the hemi = 3300. It will take me less than 3 years to pay off the initial investment. However, since I financed the truck anyway, my monthly fuel savings are way more than the extra monthly billing for the diesel option. In other words, I actually have about $200 extra in my pocket every month when adding both the monthly payments and the fuel costs together. Mind you – I don’t have a hemi – but I consider that a small price to pay next to the savings I am enjoying.

Posted in technical | Leave a comment

Upgrading Mediawiki

So very recently mediawiki became “no longer supported” in debian Jessie. This coincides with the fact that the version in Jessie is a venerable 1.19 (current version is 1.26). I discovered this while trying to get a flexible banner extension working (WikidataPageBanner), and it wouldn’t play nice. So I decided to upgrade my wiki.


Here is the Wiki about upgrading the Wiki! (Proof that it worked).

The one thing I wish I had done before starting is to prevent my ssh connection from timing out. It ended up backgrounding the database backup task and doing stuff every minute just to make sure the shell stayed open.

Posted in technical | Leave a comment

Choosing a php Framework

I have an old (10 years) web application that was designed to build, track and print characters and create spell lists for the 3rd edition of Dungeons and Dragons.

The application is written in php, without a framework, with a MySQL backend. It still works, and prints out nice pdf character sheets, but I don’t play 3.x anymore. We have (happily) transitioned into 5th edition, and I miss the functionality. So my main task consists of a re-write for 5th edition. At the same time, I want to use a framework, both in order to learn something new (I know, sucker for punishment), and to make it more maintainable going forward.

I did a bit of comparison “shopping”, and ended up taking a short dive into zend. Unfortunately, I found zend to be a little too nuts and bolts. Although I was coming from hand coding the whole thing, I have played with Rails, so I was expecting a little more framework than zend seemed to offer (and frankly, better or easier to follow docs). I am now trying Symfony, and I am much more impressed. It seems to have a very rails-like philosophy and layout, and I actually prefer php syntax to ruby. To me, ruby seems like a programming language written by someone who has a grudge against C, whereas php is unabashedly rooted in C like syntax, which is familiar to me.

I just noticed one weird side effect – all my (self hosted) sites now show up with the Symfony logo on the tab. Must be an apache configuration screw up!

Watch this space for details of how this progresses.

Posted in technical | Leave a comment