Oct 222012
 

I recently bought a 2 terabyte Goflex Home network drive to run as a media server and file server on our local home network. So I figured I’d see how to connect it to the Pi. After searching around various forums, I found a solution that worked. Over the weekend, someone on the Raspberry Pi forums asked how to do this, and so a new “How To” was born.

Pre-requisites for Hooking up goflex drive

  • the drive is already installed on your home network
  • it’s fully up and running
  • You have a userid and password
  • You know the IP address of the network drive

OK let’s do it

From your command line, type…

cd ~ that puts you in your home directory

nano goflex.sh opens a file for editing and calls it goflex.sh

Then you need to type this command, changing the 192…….XXX to the Goflex IP address. Change username and password to your Goflex username and password, and you might need to change Home Public to whatever you want to connect to (e.g. Home Backup or Home Personal).

sudo mount -t cifs '//192.168.XXX.XXX/GoFlex Home Public' /home/pi/goflex/public -o username=blahblah,password=blahblah,iocharset=utf8,file_mode=0777,dir_mode=0777

then…

CTRL+O save
Enter
CTRL+X exit

You might notice I mounted it as a subdirectory of /home/pi This is to ensure you will have full read/write access from user pi. But before we do anything else, we need to create that directory and give it the right permissions…

mkdir goflex make directory called goflex
sudo chmod 777 goflex become super-user just for this command and change directory permissions to full read/write/execute for all users

Assuming you are connecting to “public” we need to create a directory and change its permissions just like we did for goflex.
mkdir goflex/public
sudo chmod 777 goflex/public

Make it executable

Now we need to make the script we just wrote executable so we can run it…

sudo chmod +x goflex.sh

Now, a drumroll and we’ll try to run it…

./goflex.sh (the reason for the ./ is because we are in the same directory as the file we want to run. Anywhere else we would type the full path to the file to run it.)

If you see the normal prompt and no error message, it worked. Now you can go there…

cd goflex/public
ls -l

…and you should see a list of your directories/files :)

If it didn’t work, you’ll get an error message and most likely something in the script is wrong. Check, check, double-check.

Make the Connection Automatic on Boot (optional)

Once you’ve got it working, if you want it to connect every time the Pi boots up, carry on with the next part. I don’t use this myself (but I have checked that it works), as I don’t often want to connect to the network drive, so I’m happy to run the script as and when I need it.

We need to modify the script we wrote slightly.

cd ~
nano goflex.sh

Then add this right at the top

#!/bin/bash this will enable it to run when called from another script

CTRL+O
Enter
CTRL-X

Then we add a line to this file…

sudo nano /etc/rc.local
…this will open a file that contains stuff that runs at boot. This one won’t open unless you use sudo, as it’s a system file.

Go to the bottom just above the line which says “exit 0″. There you should type…

/home/pi/goflex.sh

Then save and exit as usual

CTRL+O
Enter
CTRL-X

And then it should work whenever you boot up.

sudo reboot to give it a try.

I want more!

If you want to mount more than one of the Goflex folders, public, private and backup, you need to have a separate command in the script for each one. You’ll also need a sub-directory for each as we did above – as you can’t mount two “drives” to the same place. This may be obvious, but I thought I’d spell it out anyway. :)

Happy networking :)

Oct 182012
 
16 x 2 LCD Screen attached to Raspberry P

I finally freed up one of my breadboards. I got my semi-permanent temperature sensing interface fully up and running with the Pi Cobbler – logging to COSM.
Last 7 days outdoor temp

So now I could take the components off my other breadboard and free up the Gertboard for other experiments.

LCD Next

The next thing I wanted to get working was a 16 x 2 LCD panel. (£6 from Tandy) Having seen other people get these working, I figured it couldn’t be all that hard and it wasn’t too bad actually. But I did make one small mistake along the way. I got it working the second time I tried it.

16 x 2 LCD Screen attached to Raspberry P

The mistake I made was trying to run it from a separate 5 Volt supply instead of directly from the Pi. I hadn’t connected it to the Pi’s earth, which I think is why it didn’t work first time round. Properly grounded, I think it would run from a separate supply (but don’t connect the +ves together or the regulators will have a fight).

5V or 3V3?

There are 3V3 (3.3 Volt) versions of these LCDs available, but the 5V ones are more common. According to my flavour-of-the-month site, Adafruit, it’s safe enough to use a 5 Volt LCD with the Raspberry Pi as long as the read-write pin (pin 5) is connected to ground. As long as we only “write” to the screen and don’t try to take input from it (like you would on some embedded device with input buttons e.g. a battery charger).

That way, you won’t “send” a 5 Volt signal to the Pi’s GPIO (General Purpose Input Output) ports, which run on 3V3. Sending a 5 Volt signal to a 3V3 port would be very likely to toast the port. This is the basis of the instructions I followed…

http://learn.adafruit.com/drive-a-16×2-lcd-directly-with-a-raspberry-pi/overview

…but I didn’t use the Pi Cobbler this time as it’s already in use with my semi-permanent temperature logging setup. Once I get that onto a permanent board, the Cobbler will be free again.

Identifying the pinouts

I very carefully identified the pinouts on the Raspberry Pi’s GPIO header using this very helpful graphic from the wiki.

And connected eight wires to the ports directly.

Port wiring for the LCD screen

Odd behaviour

I’ve noticed a few times that this screen sometimes needs the scripts to be run a couple of times before it works properly. I don’t have an explanation for that. Once or twice it has displayed what looks like Japanese characters instead of Roman alpha-numerics.

Some Japanese characters?

It might be that I haven’t used the Adafruit scripts properly, or it may be that they’re optimised for their own distro. No matter. On this occasion, the solution lay elsewhere. Eventually I switched to another driver by Matt Hawkins, from here.

New driver cured it

And after a bit of tweaking it finally does exactly what I want, reliably – yay :)

Success at last – degree symbol too ;)

Now this little LCD is displaying data pulled from my COSM temperature feed every 40 seconds. As I progressively add more sensors, I’ll be able to alternate the display, showing each set of readings for a few seconds before going on to the next. I’ve got plans for barometric pressure and light sensors already – who knows what else will crop up to occupy the remaining channels on the ADC? :rotfl: (Currently four channels available).

Oct 152012
 

You would Pi too if it happened to you :(

Just as I was finishing up my last blog post, the review of Adafruit Pi Cobbler, my foot snagged on a network cable and hoiked my Pi onto the floor. It landed on the SD card and the feeble card slot took no prisoners.

Boohoo – I broke my Pi :(

The card slot broke as it was predestined to do, the moment anyone looked at it harshly or in the wrong tone of voice. This Pi, my friend since 15th May 2012, is accustomed to living in a beautiful Yoctopuce case, but was temporarily naked for interfacing. It only agreed to the nudity because it was considered essential to the plot.

So, naked and broken and on the floor, the mighty Pi had fallen from grace. At least it was in a shutdown state, as I’d disconnected it all to do the photos.

We can make this problem go away

There were two ways to fix the problem. Both of them involved my Visa card. One costs about 30 pounds and the other costs not very much at all. So I chose the cheaper option…

Use your credit card to make your problems go away :)

So, how do you do this?

As an aeromodeller, I have supplies of fixit stuff. In this case the required kit is…

  • An old credit card (or similar)
  • Gorilla glue (epoxy would do)
  • Bamboo skewer
  • Piece of paper
  • Craft knife
  • Decent scissors
  • Marker pen

Use the knife to score some lines along the edge of the card slot. This gives the glue a “key”. Gorilla glue is excellent at sticking plastics, but it works better when the surfaces are not polished smooth.

Keying the plastic to help the glue stick well

Locate the area of your card that you wish to use, hold it against the slot and mark one side. Cut to size. Do the same for the other side. Remember the old carpenter’s saying “Measure twice, cut once.”

Measure twice, cut once

Scuff up the inside of the credit card repair patch to form a key for the glue.

Looks as if they were made for each other

Squirt some glue onto a post-it or similar and use this as a palette.

The sticky bit

Use the skewer to smear on a thin coat of Gorilla glue and then scrape most of it off. That stuff expands and if it gets inside the slot you will have trouble putting the SD card in.

Only put glue in the places marked in red…

Where to put your glue. Only on the red bits.

Whatever you do, don’t put any near the copper spring contact.

Once you’ve done that, put the repair patch in place and squeeze tight. Leave it alone for at least two hours (full strength in 24 hours).

The finished article

If you felt you needed to, you could add a load of hot glue on the outside for extra strength. I won’t do that unless it proves absolutely necessary because it will look awful. :)

One more thing

This repair didn’t quite press the SD card firmly enough onto the springy contacts, so it was necessary to wedge in a little strip of thin plastic (more credit card material) between the repair and the SD card. It needs to be pushed in just enough to make contact, but not so much that you break your repair – otherwise you’ll need to visit the ugly hot-glue monster.

Don’t go dropping your Pi again or we’ll send the NSPiCC* round to sort you out!

(In the UK, the NSPCC is the National Society for the Prevention of Cruelty to Children).

Oct 122012
 

Most of my recent posts have been focussed around the Gertboard. Not surprisingly, since not many are out there yet. Now that Farnell Element 14 has started shipping (I got mine today), we should expect to see a proliferation of info about clever things people have done with theirs.

One thing Gertboard has done for me though, is kindled an interest in interfacing. Previously I posted about temperature sensors and logging. Since developing the temperature data logging capability, I now want to keep that going, but still be able to mess around with the Gertboard. So it was time to take the plunge and do it without the Gertboard.

Logging without Gertboard

This required a rather different approach, but in some ways it’s simpler. Previously I was using the Atmega processor to read the temperature sensors and send data through the serial peripheral interface (spi bus). [By the way - don't worry if you don't know any of these terms - I'm only just learning the language myself.] :) Then using a python script to read and display the data and send it off to COSM for logging.

To be able do this without the Gertboard, we need an analog to digital converter, a way of connecting it to the Pi and a python script to calculate, interpret and display the results for us. Enter, stage left the Pi Cobbler from Adafruit

Adafruit Pi Cobbler

I bought mine from SK Pang in the UK for about the same pound equivalent as Adafruit sell it for in dollars (~7). You get a nice little printed circuit board (PCB) with labels for all the port names on it, a 26 pin socket, a 26 pin ribbon cable, and a strip of header pins. Important to note there is a difference between the cable for the Cobbler and the ribbon cable on the Gertboard. The Cobbler uses a “straight” cable, whereas the Gertboard uses one with one connector “the other way round”. This means they are not interchangeable.

You need to solder it together yourself. Mine took about ten minutes to do. I had a fair bit of practise when building the Gertboard, so it went quite well. :)

My Soldered up Pi Cobbler

With the ribbon cable inserted

After soldering, I used a multimeter to check that there was continuity between each pin on the 26 pin socket and its corresponding header pin on the board. All OK. Grins all round. :)

Why I chose the Cobbler

One of the reasons I chose the Cobbler (and Limor, aka LadyAda knows this – it’s the not so secret, secret of Adafruit’s success) was because on the Adafruit website it shows you exactly how to connect it up and gives you working examples of scripts that you can use to achieve a particular purpose. Then you can modify them and make them suit your exact requirements. In so doing, you learn how to do things.

In this case, I unashamedly followed their procedure (it’s how you learn) from this page

Instructions left, my version right.

I want more resolution

Then – the key point – I made it my own. I tweaked it. I decided that I wanted better resolution from the 10 bit analog to digital converter. Using the full scale of 3.3V, it was giving a resolution of about 0.3 degrees. So that means it could only show differences in temperature of 0.3 degrees. I thought it would be nice if it could show me 0.1 degree differences – after all I did study Analytical Chemistry a million years ago. I want more precision! ;)

So now it was time to switch on extra power to my brain. I looked at the numbers and realised that if the 1024 “bits” of resolution were spread over a narrower range, I might be able to get my goal of 0.1 degree resolution. But how? Ahaaaaaaaa. “I need to tweak the reference voltage on the ADC – that’s what decides the full scale range.”

So that’s why you can see two extra resistors in my photo that aren’t there on the Adafruit one. (They are done in a very quick and dirty way and I can assure you they’ll be tidied up ASAP. Best not leave large areas of bare metal sticking out or you increase the chances of short-circuiting something.) I’ve tweaked the reference voltage down from 3.3 volts to 1.03 volts using a 20 kOhm and a 10 kOhm resistor to make a voltage divider. So now I can get 0.1 degree resolution. The only downside to this is that I have reduced the usable range of the sensors (and the full scale range of the ADC). Now I can only read temperatures of up to 50 degrees C instead of 150 C.

For my application, room temperature and outside temperature, that’s no real loss. How often does room temperature go anywhere near 50 C, let alone 150? :) But more importantly than that, I used my brain! I did something that wasn’t in the instructions. I took it further! I developed it! I’m living on the edge ;) OK. I’m exaggerating, but I did get a bit of a buzz out of it.

The other difference between mine and theirs is that I’ve put a second sensor in and tweaked the script to read from two channels. This ADC has eight channels, so I will be adding more sensors in due course (bearing in mind the “new” voltage range).

I want my breadboard back

Now I’ve calibrated two new sensors (I adjust them in software to read the same as a known thermometer) I’ll be looking to take this design off the breadboard and put it on perfboard or stripboard for a permanent installation. I want my breadboard back! I’ve only got two breadboards at the moment and I need to play. :)

Next blog will be…

I’ve just accidentally kicked my network cable and the naked Pi flew off the desk and landed on the SD card. This Pi is usually cased. I only took it out of the case for interfacing. :( So my next blog will detail how to fix a broken SD card slot. :(

Oct 082012
 

I spent much of last week’s “Pi time” wrestling to get temperature sensors working through the Atmega on the Gertboard.

It was quite time consuming, but I managed to find some great helpful web sites and glean a bit of info from each. Once I’d got two different types of sensors calibrated, installed and working (and a third type temporarily abandoned), I started fooling around with logging the temperature readings. As things do, it evolved roughly like this…

  • View the temperature data on the screen updating every second
  • Make the temparature data stop scrolling and stay in a fixed place

    Temperature Measurement

  • Log the data locally on the Pi
  • Log the data on local media server so other local users can view it
  • Put it in a self-refreshing html file so it updates in the browser every few seconds

    Displayed in browser

But this was still insufficient. So the last step, pending the arrival of more sensors, was…

  • Log the data to the internet so that everybody can view it.

    Temperature logging on the web

Needless to say, each step threw up different challenges, and there was some frustration and trouble-shooting along the way.
I’m not going to fully document everything I did this time (for the moment) but I will share the sites I used for info gleaning and give you the edited highlights of the process.

Indoor/Outdoor Temperatures Logged per Minute

I now have Indoor and outdoor temperature sensors logging temperature data every minute to the internet. The scientist in me loves measurement and data logging. It seems like a million years ago (must have been summer ’89) that I did a module on electronics as part of my BSc (Analytical Chemistry). I don’t remember much of it, but I do remember I enjoyed it.

So, which sensors worked out?

I can heartily recommend two analogue sensors:

  1. TMP36 – costs about £1.50 and is a very simple to use, Celsius based sensor
  2. LM335z – costs about £1 is fairly simple to use, but needs an additional resistor and is Kelvin based

And the one I had trouble with?

That was the DS18B20 digital thermometer, which I’m sure is a brilliant piece of kit, but I couldn’t get it working in a useful timeframe. I will come back to it when I know what I’m doing. :)

Other time wasters?

After getting frustrated with the DS18B20, I wasted a lot of time trying to get the right resistor on the LM335z to make it read something like the right voltage. Unfortunately there are web sites out there where people give bad advice, so it’s a good idea to stick to good sources like MIT :) I did have a look at the datasheet for the sensor, but didn’t quite understand it. Basically you have to use good old R = V / I to calculate what value resistor to use according to what voltage you will be hooking the sensor up to (3.3V in my case) to get the required current.

MIT and Adafruit to the Rescue

This page over at MIT explains it very nicely in language I could understand. Basically 1000 Ohms for 5 volts, but that’ll be OK for 3v3 as well. And sure enough, it works just as it should (I really need to stop being surprised when things work as they should).

Another site which came to the rescue was Adafruit. A brilliantly simple piece of advice for testing analogue temperature sensors can be found here… http://learn.adafruit.com/tmp36-temperature-sensor/testing-a-temp-sensor In fact there’s a really good tutorial on the TMP36 there as well.

I wished I’d found it before I spent so much time piddling about taking advice from bogus sources. It shows you how to hook up your sensor directly to a Voltmeter to check that it is working properly.

And then there was the sofware

It was also necessary to find out what Arduino commands to program into a sketch. Adafruit to the rescue again http://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor

Then connect the Gertboard up in the right way to output data to the serial port.

Then write a little Python script to read from the serial port and output the data.

Now I write about this, and see how many steps are involved, I’m not at all surprised it took so long :rotfl:

Then once that was working well, Adafruit helped with the data logging part too…
(Online Data Logging Tutorial http://learn.adafruit.com/send-raspberry-pi-data-to-cosm/overview)

I pulled a few bits out of that tutorial, but didn’t use their scripts as I was using the Atmega on the Gertboard.

Here’s the result

Without boring you with further details, here’s a link to the the RasPi.TV temperature feed on Cosm.

And here are the current graphs with the most up to date data…

Inside Temperature
Graph of RasPi.TV Temperature stream

Outside Temperature
Outside Temperature at RasPi.TV HQ

I don’t promise to leave it switched on all the time, as I will need my Pi and Gertboard for other things. But I’m going to try and set it up directly (minus Gertboard) on another Pi permanently in due course. At the moment there’s 2.5 days worth of data on the log. It defaults to 6 hours display. The best view is on 1 week display. Then you can clearly see the daily temperature cycle. Not surprisingly, outside it gets colder at night and warmer in mid afternoon. Inside similar, but more even. We haven’t used the heating much yet this year.

It’s been a lengthy learning process. I’ve enjoyed it. Frustrations are what makes the success all the sweeter. But it’s much easier to say that once you’ve overcome all the difficulties. :)

One more thing

I just learned the hard way that you need to stop logging before you mess about with the circuit. I wanted to move some stuff around on the breadboard to make it easier to demo in class tomorrow. I switched over a couple of wires expecting to be offline only a second. It didn’t go as planned and I ended up logging zero volts on both sensors. On the TMP36 this was equivalent to -48.3 C and on the LM335z it gave -270 C. This totally messed up the scale on the graphs, so I had to find out how to delete data points. It’s a bit tricky and you have to learn how to interact with the software API. Best to switch off logging before fooling with the circuit.

To be honest, you really should switch off everything before tampering with the circuit. We all know this, and yet… ;)

Oct 032012
 

This video is about Ken Thompson’s work on TBOplayer. (KenT on the Raspberry Pi forums, KenT2 on Github – where you can download his work.)

Ken’s written a GUI (graphical user interface) for Omxplayer – the only video player currently available which can utilise the full capabilities of the Raspberry Pi’s GPU. (Graphics Processing Unit).

The reason he did this was for a museum display, where they want to play four different videos which are to be user-selectable by pressing buttons. Ken needed to complete the project for £500 or under. And the Raspberry Pi seemed like a good place to start.

TBOplayer is written in Python and Tkinter. You can check out the code at GitHub

https://github.com/KenT2/tboplayer

——Footnote——
This was filmed on location in the wilds of Milton Keynes at the National Museum of Computing, where many rare species of computer still live in their natural habitats. The MK Raspberry Jam was so “happening” that I had to overdub the video as there was so much background noise from these and other wild creatures known as geeks.

Oct 022012
 

BerryIO by Daniel Bull. As demonstrated to me at the Milton Keynes Raspberry Jam Sept 30th 2012.

Apologies for the high background noise level. This was shot live at the event, so we couldn’t ask everyone else to shut up or we’d have been lynched. ;)

If you want a closer look, you can download Berryio from here http://frozenmist.co.uk/downloads/berryio/

In a nutshell, it’s a web browser based IO control system for the Raspberry Pi.

Oct 012012
 

Yesterday I went to my first Raspberry Jam – a get-together of Raspberry Pi enthusiasts. This one was in Milton Keynes at the National Museum of Computing.

MK Raspberry Jam logo

It happened to be run by Peter Onion, who I already knew from the world of aeromodelling. So it was a no-brainer for me to go to…

  • meet an old friend (he’s not that old)
  • visit a museum of computers
  • get to talk to people about the Raspberry Pi and Gertboard and demonstrate them
  • see what other people are doing with the Pi (nobody else had a Gertboard – ner ner nee ner ner :p )

It was great. Fairly intense for me, as nobody had ever seen a Gertboard before, so my stand got quite a lot of attention. (Or maybe it was my “eye-candy” demo? ;) Watch the video and decide.) It’s got a bit of everything, lights, movement and noise :)

It wasn’t all plain-sailing though. Right at the start, while setting up, I connected the 5V servo power supply the wrong way round. Because I’d wired up the servos and Atmega through the buffers, the Pi and Gertboard were fine, but the servo was toast. :(

Toasted servo for lunch. That hole wasn’t there earlier.

Fortunately – well, there’s no fortune about it really, since I always carry spares – I had a spare servo. The refit didn’t take too long either. So the show went on and the demo was demoed (if that’s even a word?)

I did manage to tear myself away from my stand (thanks to my security arrangements :rotfl: )

Rev 1 Pi has no screw mount holes, so I made my own arrangements. :rotfl:

A closer look, you can see the hot glue. No Pis were harmed in the making of this blog – only servos.

On the rev 1 Pi board there are no screw-holes, so I had to make my own arrangements ;). The processor still works though, and you get the heatsink for free. ;) I had the whole lot mounted on a wooden board and a metal bracket attached to the central heating pipe with padlock and chain. The Pi is tied to another bracket under the ribbon cable with tennis racket string.

Great to see ICT teachers there

Of the 40 attendees, about six were teachers, which was very encouraging. I think most of them came to visit the RasPi.TV stand. There were about 5 or 6 other people with things to show. I managed to get some video of a couple of them and talked to most of the others. I’ll release some of that later in the week.

Good Jam, Well Run

The event started with everyone saying a little bit about themselves and their “Pi status” – whether or not they had a Pi, ordered a Pi, were already an expert, or had a specific thing they wanted help with. This was really useful as it enabled people to identify who might be able to help them with any issues they might have. The rest of the session was given over mostly to mingling, with a session in another room about how to set up a Raspberry Pi.

There were two standing jokes – one involving the length of time waiting for a Raspberry Pi (No suppliers’ names mentioned;) ) and the other involved booing and hissing every time a teacher reported that their school had just blown the IT budget on iPads. It was a nice, relaxed, collegiate atmosphere and Peter set the tone very well indeed.

It was busy, it was noisy, a bit chaotic at times with multiple people at once requiring attention (apologies if I ignored you or broke off mid-conversation – I’m a bit like DOS – I don’t multi-task very well).

I had fun and I will be going again if I can get a place.

The Venue is Awesome

Hosted at the National Museum of Computing, home to many old computers including the code-breaking Colossus. I had a walk around the museum afterwards. One room was full of BBC Micros – just like a school IT room from 30 years ago. I’ll put some photos up in another blog post later.