Category Archives: Project diary

Blog about small electronic or digital projects that I am undertaking

Getting the Raspberry Pi out of the box

I’ve had a Rasberry Pi model B2 on top of my wardrobe since January 2012, but I hadn’t been able to think of a use for it until now.  In particular, I had been reluctant to learn Python.  Perhaps the name had put me off, the same as I won’t drink beers with strange names such as Bladdablasta, on the basis that if it has to have a strange name to make you notice it, probably it’s not very good.

But first I’d better see if I can get the Pi working. I plugged it all in and it came up straight away.  My Eizo monitor has an HDMI input which I’m not using (I use the DisplayPort input for my PC) and I can just switch between the two computers with the monitor’s front panel button, so I can use the Pi and the PC simultaneously.

The first issue was that Eric (or do I mean IDLE?) was out of date.  You have to update it by copying the new IDLE from the Pi website onto a new SD card (never overwrite you old SD card in case the update goes wrong and you have to revert to the old one). There instructions for copying the new IDLE 3 from the Pi website.  I only had a 32 GB SD card in the drawer so I downloaded onto that using my PC and fast internet connection.  It took hours.  And then the Pi refused to boot from it.

When you go to the Pi website, the first thing they tell you is to reformat the SD card, which I had done, but I’d got some error message so I think the card wasn’t properly formatted, which may explain the really slow download.

So I bought a new 8 GB SD card and this time I didn’t try to format it. I decompressed the NOOBS software from the Pi website and copied it straight to the SD card.

I then put the card into the Pi, turned it on and it booted! After doing something (don’t ask me what) with the SD card, the Pi asked you to load Raspian Jessie.  This is the current version of the operating system. Then it tells you it will extract the OS and load it onto the SD card. This took another 30 minutes. I sat there wondering if it would be worth it.

The next problem is that there are (at least) two versions of Python. I decided that in the interests of future-proofing, I’d used the latest, Python 3. But since much of the sample code is written for Python 2, and it seems there are some comaptibility issues, I anticipate that there will be trouble ahead.

Next Instalment – writing the RSS  Parser Code.

How do you use an Arduino’s Wifi?

It seems that the most common application for Arduino WiFi is as a web-server. The idea is that the Arduino acts as the interface to some measuring device or other thing that you want to control from the internet.

However, it is less clear how to use it as a ‘Client’, where the Arduino downloads information from the internet and then processes it.

The Arduino does not have an Operating System apart from a ‘Bootloader’ which loads programs from an external source, such as a PC, and then runs them. All the hardware must be driven by software/firmware that you upload to the Arduino yourself. Once uploaded, the Arduino runs the software/firmware to perform the functions you have designed.

Few programmers know anything about the ‘low-level’ coding of the actual hardware.  PC programmers expect their computers to have ‘drivers’ that handle the complexities of communicating with the actual hardware.  But the Arduino lacks the memory and processing power needed by this approach.

Fortunately, there are many libraries of free ‘utility’ software for controlling the Arduino’s hardware and for communicating with the Arduino.

Unfortunately, many of these libraries are badly documented so it is unclear which are the most appropriate for a particular application, and particularly how to use them. Even worse, they exist in many different versions according to the exact model of Arduino that you have (and there are very many different models), meaning that often they don’t work and you have no idea why. To make matters worse, the libraries are updated frequently, so examples of how to do things are often out of date. Check the date of any post and be wary of anything that is several years old.

I managed to get the Arduino Uno Wifi to work as a web server and as a web client once I realised that I had to update the IDE from 1.6.5 to 1.7.10.

I could communicate from my PC, but this needed several libraries to be loaded. Also, I loaded the stepper class library to drive the stepper gauge motors that had just arrived.  The steppers worked!

I got rather bothered when I found out that the library for the WiFi drivers was apparently incomplete and also that the WiFi library took up a large part of the available memory, leaving little room for anything else. I was advised on one of the forums that I might need to program the WiFi chip manually.  I can see how this would save space, because I would need quite a lot of memory to parse the RSS feed, but I have done hand-coding of UARTs in the past and having been there and got the T-shirt, I had no desire to return!  I started reading how you could store data in the EEPROM, but this had to a done a byte at a time, so again this looked like a huge learning curve.

Yes, it would be within my capability to do it, but I had no desire to emulate the man who was asked why he was hitting himself on the head with a hammer: he replied that it was so nice when he stopped.

My objective was to make a device, not to develop a skill that I’d never be likely to use again.

Then I realised that I had a Raspberry Pi on top of my wardrobe. I’d bought it on a whim and apart from testing to see if it worked, I’d never used it.

I knew it had a proper Unix/Linux-type operating system called Raspbian – I had some experience with Unix and SunOs from ‘the old days’.  Moreover, it had a reasonable processor, lots of memory (on SD card), properly-implemented WiFi (using a plug-in USB dongle) and a decent array of GPIO pins (though not as good as the Arduino).

There is even an on-board development environment called IDLE One downside is that the main programming is Python, which I don’t have the faintest idea about, other than the allusions to the TV series are intentional!

The makers of the Raspberry Pi are clearly addicted to bad puns.

Next instalment to come – getting the Rasberry Pi out of its box.


Why a forecasting barometer?

March 2016

I read an article  in The Ringing World asking how clocks were kept right in the days before Greenwich Mean Time. As a result, I found myself studying the issue of solar versus mean time and I wondered about making a solar clock.  I don’t have the skills to machine a mechanical clock, nor the space to set up a machine shop, so I thought about using the Arduino Uno that I’d bought the previous August but had hardly used.

I found some blogs about Arduino controlled clocks, including the ‘Lord Vetinari’ clock that ticks irregularly but keeps perfect time. This is based on modifying an ordinary quartz clock movement. But I though that it would be so annoying that I couldn’t tolerate it (which was Lord Vetinari’s intention of course).

Then I though of a moon-phase clock to show new moon, first quarter, etc.  In long-case clocks, this uses a moving disc rather than a clock dial, so I looked up ways of doing this.  It became clear that this would be best done with a stepper motor, which I knew nothing about.

It is possible to use an ordinary quartz clock movement and to pulse it at a suitable rate from the Arduino: these movements are essentially stepper motors with extra gearing to drive the minute and hour hands.  But I found that the cheapest steppers were ‘car instrument gauge’ motors which can be bought on the internet for as little as £12 for six of them.  I could have a pointer showing the phase of the moon, or it might even be possible to drive a light-weight disc painted with a moon face, as in a traditional long-case clock.

3rd August 2016

Nevertheless, I went round the charity shops in Epsom High Street to find a cheap, working clock, and I got one for £3.99.  In fact, it looked very nice like it was, but the dial was only 6 ” in diameter and there was nowhere for the extra dial or Arduino controller.  Continuing along the High Street, I saw a fancy brass tray, about 12 ” in diameter, but completely black with tarnish. I was £2.99, so I had to have it, and after spending a good few sessions with metal polish, it looked beautiful.

Thinking about the display on the moon-phase clock, I asked Cari what she thought. She’d just come back from making some fused glass she wasn’t happy with. I wondered if somehow she could make something to display the moon phases, but she thought it would be nicer to show the weather, like the little couple with an umbrella you find on some old cuckoo clocks.

I wondered if there were some RSS weather feeds that might be suitable. I found that there were several of these, but how would you get at these from the Arduino?  I wanted a battery-driven thing with no wires, so that its working would be a bit of a mystery.

Obviously, wifi was the answer.  But I found that a wifi ‘shield’ was absurdly expensive (over £50)!  A bit more research showed that I could get an Arduino Uno with integrated wifi for £20 from RS components.  The only disadvantage seemed to be that it had a tiny integrated wifi antenna built in, although you can plug in an external antenna.

The next instalment – How do you use the Arduino’s wifi?

A Forecasting Barometer

I’m going to describe the process I’m going through to create my Forecasting Barometer.

It isn’t really a barometer – it is going to display the weather forecast on analogue dials.  This will need me to deal with all sorts of issues and get hold of a lot of bits and bobs.  I’m quite good at assembling electrical things, not so good at making mechanical things, so I’m going to buy in a lot of those parts.

Having mulled over the project for some weeks, I started in earnest on 8th August 2016. I’m not sure how this blog will develop, any more than I’m sure about how my project will go.  I might even give up, although I have been working on it for over a month and I have made some good progress – and gone down a number of blind alleys too.

Next instalment soon.