Creating a Headless Raspberry Pi System from an Apple Mac

I’ve a few Raspberry Pis which I run Headless (without their own screen and keyboard) from my Apple Mac using a combination of Finder, VNC and SSH to run the applications. I recently decided to upgrade one of them (a Pi3) to Stretch to see if it was any better (and to play with the latest version of Sonic Pi).

Having tried to upgrade from Jessie to Stretch using the instructions here (https://www.raspberrypi.org/blog/raspbian-stretch/) and failed miserably as the system hung at various places in the upgrade, I decided I would create a new system on a brand new SD Card and start all over again.

Previously, I’ve created put NOOBS onto the SD card and created the system from scratch using a screen and keyboard. This time I thought I would do it all without the need to unpack the keyboard and mouse and to occupy the family TV for a while.

Easier said than done. However, eventually I worked it all out and, having looked around the web, realised that most people in the Raspberry Pi community don’t use Apple Macs and those that do seem to know a lot more about using them than I do.

Here’s how I did it, step by step.

Setup

Although you won’t need a screen or keyboard, you will need to connect the Raspberry Pi to your network using an Ethernet Cable (I have a feeling that you might be able to get it connected to the network using WiFi but I found that step easier to do as part of the Raspberry Pi Configuration after the software was up and running).

You’ll also need to have an SDFormatter Application installed on your Mac.

Most of the work uses terminal on the Mac, either directly on the Mac or through SSH to the Raspberry Pi so its best if you are relatively familiar with that as well.

Procedure

  1. Use SD Formatter to format your SD Card. Eject the SD Card and remove it from your Apple Mac.
  2. Open Safari and head to raspberrypi.org/downloads and click on the latest version. Click Download ZIP under Raspbian (the full version, not the Lite version). (For the sake of argument lets call this “2017-xxx.img”)
  3. Open Terminal.
  4. Enter “diskutil list“. You will see a list of all your drives. If you’re using a Mac with just one hard drive, then two appear: /dev/disk0 and /dev/disk1. If you have external hard drives, or more volumes, then there will be more drives.
  5. Connect the Micro SD Card to your Mac.
  6. Enter “disktuil list” again. Check carefully to locate the new disk. It will be one more on from the last list (ours is /dev/disk2) and have “(external, physical)” after it. Check that its SIZE matches the SD Card. It’s important that you get this right so you don’t end up overwriting content on the wrong drive.
  7. Enter sudo diskutil unmountDisk /dev/disk[n] (replacing with the number of the disk, e.g.: /dev/disk2).
  8. Enter this carefully: sudo dd bs=1m if=~/Downloads/2017-xxx.img of=/dev/rdisk[n] – replacing [n] with the number of the disk
    • Tip: you can use tab to expand file paths in Terminal. Enter “if=~/Downloads/2 ” and press Tab to get the rest of the filename (you may need to add “img” to the end).

The image file will be copied to the SD Card. You won’t get any feedback while it copies, and it can take several minutes. Leave Terminal to do its thing (I find its best to make a cup of coffee because on my machine a 32Gb disk can take about 45 minutes).

  1. When the copy finishes enter sudo diskutil eject /dev/disk[n] to eject the disk.
  1. Remove the disk and its holder from the mac and then re-insert.
  2. Open Finder and there should be a disk called boot.
  3. Open Text Edit and create a new file called ssh in the boot disk. (Text editor will add an extension .rtf to the file, you’ll need to remove the extension. (I’ve created a suitable file on my Mac so I can just copy it across to the boot disk).
  4. Put the disk into the raspberry pi, connect it to the ethernet network using a cable and power it up.
  5. You should now see raspberrypi on the network. (I open finder and browse the network using cmd K)
  6. At this point you may be able to ssh to the Raspberry Pi by ssh pi@raspberrypi.local. However, if you’ve had other raspberrypi hosts on your network in the past there will be a security issue so you’ll need to:
    1. cd /Users/youruser/.ssh
    2. ls (to check for known_hosts)
    3. rm known_hosts (remove known_hosts file) now when you connect to any remote host it will ask you to re-verify.
  7. Now you can carry out the rest of the configuration through sudo raspi-config
    1. Change the hostname (choose a new name)
    2. Change the password for the pi user (for security)
    3. enable WiFi (you’ll need to know the Network SSiD and Password)
    4. Enable VNC
    5. Enable 1-wire
    6. Enable the Camera
    7. Set the screen resolution (to 1024×768) (DMT Mode 16)
    8. Enable Netatalk to allow the Mac Finder to access the Pi as follows:
      1. sudo apt-get update
      2. sudo apt-get install netatalk
      3. Stop the netatalk service (sudo /etc/init.d/netatalk stop)
      4. Now, in order to keep track of what you’re looking at from your hosting Mac, I find it best to change the name of the host volume. (sudo nano /etc/netatalk/AppleVolumes.default)
      5. Then scroll down to the bottom to find ~/ “Home Directory” and change the text in quotes to whatever you want. I find it best to change it to the same name as the Raspberry Pi Hostname.
      6. Finally restart netatalk and the Raspberry Pi will appear in the list of shared devices in Finder (sudo /etc/init.d/netatalk start)
    9. Finally reboot the Raspberry Pi (sudo reboot).

Now you should be able to see the Raspberry Pi under the new Hostname on your network and be able to connect to it using SSH in terminal, VNC, and Finder.

Posted in Raspberry Pi | Tagged , , , | Leave a comment

Recipe: Hungarian Goulash

This recipe is an old one that we’ve been cooking for 30 years or more and the recipe book is falling apart. Like many recipes, we use it for guidance, rather than following it slavishly (like rules, recipes are meant for the obedience of fools and the guidance of wise men).

The recipe says stewing steak but we've used the same recipe with pork and with no meat (just put in a load of vegetables).

Ingredients for 4-6

  • 1kg Stewing beef
  • 2-3 peppers (red or green are best)
  • Oil for frying (the recipe says dripping or lard)
  • 500g Onions
  • 2 tablespoons of mild paprika
  • 500g tomatoes (fresh or frozen)
  • pepper
  • Soured Cream

Method

  1. Chop up the onions, pepper and tomatoes (but keep them separate as they will not all go in together);
  2. Trim some of the fat off the meat and dice into fork sized pieces;
  3. Heat up the pan add the oil and fry the onions until soft and coloured;
  4. Add the meat and cook until browned all over;
  5. Add the paprika, a good grinding of pepper, the tomatoes and peppers
  6. If you're cooking it in the oven put in in the fan oven at about 160C. We cook it in the slow cooker where we put it on high for about an hour and a half and then drop it to low for about four hours.

It shouldn't need any extra water as the idea is that it softens everything together however, keep an eye on it to make sure it doesn't burn.

Serve with rice and a spoonful of soured cream. (We cook an additional green vegetable with the rice - peas, sweetcorn or broadbeans to increase the amount of vegetables we eat and to reduce the total amount of meat).

 

Posted in Recipe | Tagged , | Leave a comment

Recipe: Pork Vindaloo

This recipe is an old one that we’ve been cooking for 30 years or more and the recipe book is falling apart. Like many recipes, we use it for guidance, rather than following it slavishly (like rules, recipes are meant for the obedience of fools and the guidance of wise men). The Turmeric and Tomato Puree make it richer.

Ingredients for four

  • 500g pork (we use belly pork);
  • Dessert spoon demerara sugar (any brown sugar will do);
  • 2 tablespoons vinegar;
  • Oil for frying (the original recipe says dripping or lard which shows how old it is)
  • 1 large Onion (peeled and chopped);
  • 2 dessert spoons curry powder (more if you like it hot);
  • bayleaf;
  • 3 tomatoes chopped (we usually add more) – red or black are best although Tinned or Frozen work equally well;
  • salt and pepper
  • Turmeric
  • Tomato Puree

Method

  1. Cut the pork into 1cm cubes and put in a bowl with the vinegar and sugar then leave for two hours;
  2. Pre-heat the oven to 170c (325F or gas mark 3);
  3. Fry the onion in the oil for 2-3 minutes until slightly softened;
  4. Add the pork, marinade juices and the remaining ingredients to the pan and bring to the boil;
  5. Transfer to a casserole dish and cover tightly with a lid and foil;
  6. Cook in the centre of the oven for 1.5-2 hours, checking every now and then that there is still enough water to stop in burning; (We also found it works well in a slow cooker, instead of the oven, cook it for 2.5-3 hours);
  7. Serve with boiled rice. (We add vegetables to the rice – peas, sweetcorn, broccoli, beans, … more vegetables hidden away from view).

As an alternative way of cooking, we use the slow cooker and cook it on high for a couple of hours, then turning it down to low until we're ready for it.

Posted in Recipe | Tagged , , | Leave a comment

Recipe: Gluten Free Pork Pie

Having decided to be wheat free, pastry is one of the things I find most difficult to be without. Worst of all, I love pork pies and a gluten / wheat free pork pie is one thing I haven’t found anywhere. So, we decided to make one using a combination of a number of recipes.

Ingredients in italics we've grown ourselves (maybe from the freezer).

Ingredients (a large pie)

  • 12 oz pork shoulder
  • 4 belly pork slices
  • 4 smoked/unsmoked back bacon slices
  • 4 anchovy filets
  • 2 tsps chopped fresh sage leaves
  • 1 tsp allspice
  • Nutmeg
  • Pepper
  • Salt (optional depending on how salty you like it and how salty the bacon/anchovy fillets are)

Ingredients for Hot Water Pastry

  • 8 oz gluten free plain flour
  • 0.5 tsp xanthan gum
  • 1 egg
  • 3 oz butter
  • Pinch salt
  • 6 fluid ounces hot water

Other Ingredients

  • One extra egg to wash the pastry
  • A seven or eight inch cake tin for the pie.
Wheat Free Pork Pie

Method

Pre-heat the oven to 180C/350F/Gas 4/170C for a fan oven.

To make the filling, remove any rind from the bacon, belly pork and shoulder and cut into fairly small pieces. Put into a food processor and pulse it to chop the mixture fairly finely. The size of the lumps will determine how coarse the eventual filling is so pulse it carefully because it needs to be the right texture, neither too fine nor too coarse.

Chop the sage and anchovy fillets; grate the nutmeg. Now tip the meat into a bowl and add the chopped sage, anchovy fillets, allspice, nutmeg and pepper. It needs to be well seasoned, but we didn’t add any salt as the bacon & anchovies are usually quite salty and we don’t usually add salt to any cooking.

Mix it well, using your hands is best.

If you want, now is the time to test the mixture by frying a small patty of meat, taste it and correct the seasonning. (However, to be honest, we didn’t taste it and the result was excellent).

Line the cake tin with greaseproof paper or baking parchment, leaving some as handles to lift the pie out of the cake tin when its cooked.

Making the pastry is “interesting”.

Mix the flour, egg, xanthan gum and salt in a bowl. Put the water and butter in a saucepan and bring it to the boil making sure that the butter is dissolved. Pour the water and butter into the bowl and beat the mixture with a wooden spoon until it seems mixed well. Whilst the mixture is still warm tip it out onto a lightly floured board and knead it until its smooth. (You’ll need to do this quite quickly as its important that the pastry is warm at this point).

The pastry will be sticky and it will be fun to handle (it sticks to your hands, flour them or make sure they are wet when handling).

Divide the pastry into 1/3 for the lid and 2/3 for the base of the pie.

Line the tin by dividing the pastry into balls and working the balls of pastry into the base and sides of the tin. (we tried rolling the pastry between two layers of greaseproof paper but it becomes impossible to handle).

Tip the meat into the lined cake tin and then roll the lid pastry between two layers of baking parchment until its the right size to make the lid. Brush the edges of the lid with beaten egg and then turn it onto the base egg side down. Crimp the edges of the lid and base of the pastry to seal it. Make a hole in the middle of the lid so that it can vent as it cooks. Paint an egg wash over the top.

Place the cake tin on a baking tray to catch any fat that cooks out of the pie and put the pie into the centre of the oven and cook it for approximately 40 minutes, checking after 35 minutes to see if its cooked.

If it seems well cooked, take it out of the oven, turn the oven down by 10C and leave it to cool for about 10 minutes. Take the pie out of the cake tin using the “handles” you left on the tin lining and place the pie on the baking sheet using the lining from the cake tin to prevent the pie from sticking.

Paint the outside of the pie with an egg wash and return the pie to the oven for a further 30 minutes. At this point it should be cooked, test by putting a skewer into the meat, any fat should run clear. Don’t test the pie too soon otherwise the fat will run out early.

When its cooked fully, put the pie onto a wire rack and leave it to cool.

The result was excellent, the pastry had taken up just the right amount of stickiness. The only problem we had was that we tested it with a skewer too soon and so the fat cooked out of the meat and marked the lid.

Freezing

We've found that the pie freezes well and is nice with hot baked beans.

This is a recipe I would recommend, it was similar enough to a normal pork pie that you wouldn’t have to do anything special for people who were not wheat free.

Posted in Recipe | Tagged , , , , | Leave a comment

Recipe: Aubergine Rogan Josh

A simple to make supper which tastes (a lot) better than it looks. Its good to eat when aubergines are cheap and fresh in the supermarkets (we can't grow large enough aubergines) and uses frozen chopped tomatoes and tomato puree.

Ingredients in italics we've grown ourselves (maybe from the freezer).

Ingredients (for two)

  • 2 Aubergines cut into small cubes
  • 1 Red Onion
  • Garlic (at least 2 cloves)
  • Red Lentils (4 tablespoons)
  • 600ml Vegetable Stock
  • Tomato Puree (2 tablespoons)
  • Chopped Tomatoes (400g)
  • Curry Powder (2 tablespoons or as much as you like)
  • Pepper

Options:

  • Fresh Corriander (to serve)
Aubergine Rogan Josh, Curry Roast Cauliflower & Rice

Method

Fry the chopped aubergine in a non-stick pan with the onion & garlic over a moderate heat until its browned. You may have to add a little water to prevent it sticking. At the same time in another pan, boil the lentils, curry powder and tomato puree until the lentils are cooked and soft.

Then pour the aubergine mix into the lentils and add the tomatoes (and corriander if used). Serve.

We eat this with curry roasted cauliflower and basmati rice. Mango chutney is a nice addition.

Posted in Recipe, Vegetables | Tagged , , , , | Leave a comment

What Tomatoes to Grow in 2018?

I’m a member of an internet tomato seed swap. The simple idea is that a number of you collect your own seed, bag them up and send them to somebody who (very kindly) gathers them al up and sends them back out to all the members. Thus, for a bit of effort, you get a range of new varieties to try the following year.

The seeds arrived the other day and I’ve been looking through them. As has always happened so far, I am amazed by the number of different varieties that people grow. I sent off three varieties that I’ve been growing for a while and received back 26 packs of seed, 22 of which are new varieties to me. As ever it leaves me with a problem. I have space for about 30 different indeterminate plants and six to ten determinate varieties. Unlike last year when I received about an equal mix of determinate and indeterminate varieties, most of the tomatoes in the collection this year are indeterminate. So I have to decide, out of the (now 140+) varieties in my seedbank, which am I going to grow so that I end up with a mix of colours and types.

Decisions…. Decisions

Posted in Greenhouse, Vegetables | Tagged , | Leave a comment

Recipe: Butternut Squash & Potato Corn Chowder

This is a simple to make rich soup, reheats in the microwave well and freezes.

Ingredients in italics we've grown ourselves (maybe from the freezer).

Ingredients

  • Butter & Oil
  • 3 Onions finely chopped
  •  750g Potatoes cut onto small chunks
  • 750g Butternut Squash
  • 600g Sweetcorn blitzed to make creamed corn
  • 600ml Chicken Stock

Options:

  • Worcestershire sauce to taste
  • Creme Fraiche
Butternut Corn Chowder

Method

In a saucepan, melt the butter and add the oil. Fry the onion over a low heat until soft (we found it best to put the lid on the pan so that it steamed a bit). Add the butternut squash, potato and stock, then bring it to the boil and cook until the vegetables are just tender (10-15 minutes).

Add the sweetcorn, season to taste and heat through for another 5-10 minutes. Then (if you want) mash slightly with a potato masher to break up the texture a bit, leave lumps, you don't want it smooth.

Serve in bowls and add a little worcestershire sauce and/or creme fraiche if you like.

Posted in Recipe, Vegetables | Tagged , , , | Leave a comment

Can a Waterbutt of water affect the temperature in a Polytunnel?

I’ve seen a number of discussions as to whether putting a waterbutt filled with water in the polytunnel would help to avoid frosts and (possibly) encourage earlier growth by raising the average temperature in the polytunnel.

Whilst there was a general opinion that it would help, I had a feeling that any improvement would be negligible.

The only way to satisfy my thoughts was to accurately measure the temperature of the water in a waterbutt and the atmosphere within the polytunnel. So, I set out to do this. My supposition being that the heat given out by the waterbutt would be small to infinitesimal and so have no impact upon the temperature in the polytunnel, but that if the water temperature rose and fell it was doing something (even if not much).

Building the Temperature Sensor Hardware

Around the web, there are many sets of instructions on how to build a temperature sensor using the DS18B20 and I don’t intend to duplicate them here. Suffice it to say that the waterproof DS18B20 has three leads (Black, Red & Yellow) which should be connected to Ground, 3.3v and GPIO4 respectively with a pull up resistor of about 4.6k ohms between the Red and Yellow leads to make the data reliable. You can, in theory, connect as many DS18B20 together as you want with just a single pull-up resistor. (My max has been four but I have no reason to expect that there is a sensible upper limit but for the purposes of this experiment, I connected two).

Its best to solder all the DS18B20s together with no power to the Raspberry Pi and to solder a flying lead with a female connector to the setup so that you can easily connect and disconnect the sensors to the Raspberry Pi. Again, my suggestion is to connect everything to the Raspberry Pi with the power turned off and only power-up the Raspberry Pi when everything is connected.

Preparing the Raspberry Pi

The DS18B20 uses one-wire connectivity so you’ll need to add the line:

dtoverlay=w1-gpio
to /boot/config.txt.

The simplest way that I found was to edit the file using the text editor nano but you’ll need to do this with superuser enabled (sudo nano /boot/config.txt) otherwise you won’t have the privileges to change the file. Then reboot the Raspberry Pi and you’re ready to go.

Checking that its working

Before starting to run your code, its worthwhile making sure that its working by initiating the sensors from the screen.

Each sensor will create a file /sys/bus/w1/devices/28-xxxx where xxxx is the unique number of the individual sensor. So by initiating the 1-wire system you will be able to examine the directory and make sure the necessary files exist and that they contain data.

To initiate the 1-wire system type:

sudo mod probe w1-gpio
sudo mod probe w1-therm

then check that there is one 28-xxxx file in /sys/bus/w1/devices for each of the DS18B20s you have connected.

Possible Problems

If there are no files, check your connections. My most common mistake has been to connect the data line to the wrong GPIO pin, but obviously you have to make sure that the power and ground connections are also sturdy.

If there aren’t as many files as you’ve got DS18B20s, check the soldering of the connections as the wires to the sensor are quite delicate.

Programming the sensor

I’ve written a total of three different programmes in Python to read and store the temperatures. The first two ran permanently recording the temperature every minute to a file. I found a some bugs with Python (the Float command doesn’t work when the value is exactly zero for example), and having it running permanently meant that the Raspberry Pi could’t be used for anything else.

So my final (and so far most successful version) is run from a cronjob (so I had to learn how to do that) and this means that the file is closed when the programme isn’t running and you can choose how often to run the programme (I decided that once every 10 minutes would give me an accurate enough set of readings).

The code can be found here and it seems to work, creating a .csv file which a spreadsheet programme can read and plot.

To set up the cronjob edit the cronjob file (crontab -e) and set up one (or more) commands to run the job as often as you like (I’ve got it running every 10 minutes).

Results (so far)

The graph of the results so far can be seen here. Its only been running reliably for a few days and we’re at the start of winter. The results are somewhat ambiguous. The temperature of the air in the polytunnel changes rapidly, especially when the sun shines on the tunnel (which is what one would expect). The temperature of the water tracks the temperature in the polytunnel with a delay. This means that the water absorbs heat when the polytunnel is enough warmer than the water and gives it out when the polytunnel is enough cooler than the water.

However, the temperature difference is never very large and the water seems to stop decreasing in temperature if the difference is less than 0.3C (in other words if the polytunnel is 0.3C colder than the water the temperature of the water does not decrease and if the temperature in the polytunnel is less than 0.3C warmer than the water, the water does not increase in temperature.

This means that, with this volume of water, the impact would be minimal. The amount of heat given out by the water as the temperature goes down probably doesn’t influence the temperature in the polytunnel and, if the temperature goes down and stays down, the water will quickly lose any effect.

Update (Mid January 2018)

I modified the hardware set-up to include an extra coupe of sensors (one would have been better but I added two). So now I have one sensor in the water, two in the tunnel (one above the water and another just in the atmosphere) and a fourth outside the tunnel in the shade. The resulting graphs are still ambiguous. Yes, the temperature in the water lags behind the rise and fall of the other sensors (and -0.3C is the minimum that it gets to) and the temperature in the tunnel peaks higher than the temperature outside (in the shade) but other than that its difficult to draw conclusions, the only thing to see (here) is that its cold even at the hottest. It’ll be interesting to see how the temperature behaves as the days get longer.

Posted in Blog, Greenhouse, Raspberry Pi | Leave a comment

Recipe: Sausage Casserole

This is a simple to make meal for two which is simple to double (or more) up, reheats in the microwave well and freezes. It also makes a good base for a soup.

Ingredients

  • 1 tblsp Oil
  • 250g Sausages
  • 1 Carrot
  • 2 Potatoes
  • 1 stick celery
  • 1 leek
  • 1 large Onion
  • Thyme
  • 300ml Vegetable Stock
  • 400g Tomatoes
  • 1 can Cannellini Beans
This is a sausage casserole we made in the slow cooker.

Method

Cut the sausages, carrots, leeks, celery, onions and tomatoes into bite sized chunks. Cook in the oil until browned all over. Add the carrots, leeks, onions, thyme and celery to the pan and cook for 4-5 minutes.

Transfer everything to the slow cooker and add the stock & tomatoes. Cook on high for a couple of hours then turn down to low.

15 minutes before you want to eat it add the cannellini beans and turn the slow cooker back up to high.

Posted in Recipe | Tagged , , , , , , , , | Leave a comment

Pruning Autumn Fruited Raspberries

Yesterday I went to the allotment to prune my Autumn Fruiting Raspberries. Raspberries are possibly one of the few reasons why I want to keep my allotment. This year we picked a total of 17kgs of fruit, about half of which are presently sat in the freezer, the rest having been eaten as they ripened.

Accidentally, I’ve got two different varieties Polka (which grows quite tall) and another which is a lot shorter and less productive. Polka is excellent, producing sweet tasting, firm, large fruit over a relatively long season. I’ve always cut them down to the ground and got a single crop. However, this year (if you look carefully at the picture) you’ll see that half of them I’ve left about two feet tall (that 60cm to those who don’t do imperial measures). The idea is (so I’ve read) that, being “primocane”, the plants should provide an early crop if not cut right down. We’ll see.

The reason that I’ve cut them down before is that the allotment is very open and gales blow across. I’ve read that, being shallow rooted, raspberries are likely to rock and get weakened. I don’t know and again we’ll see.

My major problem is couch grass. The allotment suffers from this pernicious weed and I’ve never found a sensible way of getting rid of it. So my perennial beds (raspberries and other fruit) gradually get more and more “infected” to the point where I have to dig everything up and start again. I did this last year with my Summer Raspberries but at the end of the year, despite digging through the bed and pulling out as much of the couch grass as I could, it’s still badly infected and, the only solution I’ve found is to grow sweetcorn. This seems tough enough to overwhelm the couch grass and is well enough spaced that I can hoe between the plants on a regular basis killing the couch grass. The problem is that one bed of Sweetcorn is more than enough for us (54 cobs this year and we’ve got loads in the freezer) so growing multiple beds of sweetcorn to get rid of couch grass isn’t a solution.

If you look at the picture, you’ll see that the Autumn Raspberry bed looks quite bad (even after pulling quite a lot out) and I have no doubt that it will only get worse.

Autumn Raspberry bed after pruning

Posted in Allotment, Blog | Leave a comment