Backup SD card online to external USB card

Piclone (gui) only backups the actual data -


To run from command line

Copy this script

On raspberry pi, run

sudo nano

paste in the text

cntrl-x then y to save and exit

sudo chmod 777


I'm using a Sandisk external SD card and USB micro SD card reader

16gb Sandisk class 10 Micro SD card -

Kingston Micro SD card reader USB -


Run lsblk

sda           8:0    1 14.9G  0 disk
├─sda1        8:1    1 43.2M  0 part
└─sda2        8:2    1 14.8G  0 part
mmcblk0     179:0    0  7.5G  0 disk
├─mmcblk0p1 179:1    0 43.2M  0 part /boot
└─mmcblk0p2 179:2    0  7.4G  0 part /



To run


sudo ./ /dev/sda /dev/macblk0





Items to add to a new Pi install

sudo apt-get update
sudo rpi-update
sudo apt-get -y dist-upgrade
sudo apt-get update

sudo apt-get install python-smbus i2c-tools mariadb-client-10.0 python-mysqldb git minicom build-essential python-serial python-dev python-pip fswebcam git scons swig python-openssl python3-lxml python-lxml -y


sudo pip install paho-mqtt

sudo pip install --index-url=  paho-mqtt


git clone

cd Adafruit_Python_DHT

sudo python install



git clone
cd Adafruit_Python_BMP
sudo python install



git clone
cd rpi_ws281x

cd python
sudo python install



curl | bash

Using an Arduino Nano to sense wind speed

I tried using a Raspberry Pi to count the number of times the Wind Speed Anemometer revolved, but the Pi was unable to keep up.

So I used an Arduino Nano to do the counting.  The Raspberry Pi then looks for the output from the Arduino Nano

volatile byte count;

unsigned int loopcount;

unsigned int maxofcount;
unsigned int araysum;

unsigned int duration;
unsigned long tenseconds;
unsigned long sixtyseconds;

int countarray[6];

void setup()
  pinMode(13, OUTPUT);
  attachInterrupt(0, arduino_anemometer, RISING);
  tenseconds = millis() + 10000;
  sixtyseconds = millis() + 60000;
  //countarray[]= {0,0,0,0,0,0};
  loopcount = 0;
  maxofcount = 0;
  count = 0;

void loop()
  if (millis() > tenseconds) 
      countarray[loopcount] = count;
      if (loopcount > 5)
            maxofcount = getIndexOfMaximumValue(countarray, 6); 
            araysum = getSumofArray(countarray, 6);
            Serial.print("Current Count#");
            loopcount = 0;
            sixtyseconds = millis() + 60000;

      tenseconds = millis() + 10000; 
      count = 0;
        if(millis() < (tenseconds - 20000))
            tenseconds = millis() + 10000;

void arduino_anemometer()
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW

void printwait()
      Serial.print("                                   Current time - ");
      Serial.print("      tenseconds = ");
      Serial.print("      sixtyseconds = ");

int getIndexOfMaximumValue(int* array, int size)
    int maxvalue = 0;
    for (int i=0; i<size; i++)
        //Serial.print("              Array Number ");
        //Serial.print("  Array value ");
        //Serial.print("  Max value ");
        if (maxvalue < array[i])
            maxvalue = array[i];
    return maxvalue;

int getSumofArray(int* array, int size)
    int sumofarray = 0;
    for (int i=0; i<size; i++)
        sumofarray = sumofarray + array[i];
    return sumofarray;


Add static IP address to ethernet

Raspbian Jessie

sudo nano /etc/dhcpcd.conf
interface eth0

static ip_address=
static routers=
static domain_name_servers=


On Older Raspbian

sudo nano /etc/network/interfaces


So you want to record the temperature over time?

So you want to record temperature measurements over time?

I have used the Adafruit guides to teach myself how to log the weather.  They're fairly easy to follow and the guides are updated regularly.

See this Adafruit guide on how to publish temperature and humidity readings to Google docs -

The Adafruit guide uses a DHT11 sensor that can measure temperature and humidity.  My advice is to use the slightly more expensive DHT22 sensor as it's more accurate, has higher and lower humidity sensing, and is more stable.

You can add multiple DHT sensors to a Pi but each sensor requires one dedicated pin on the pi (26 pins are usable of the 40 available).  You can also use DS18B20 1-Wire Temperature sensors to record the temperature.  These can be "networked" together requiring just one pin on the Pi.

Adafruit guide on DS18B20 temperature sensors -

You might wish to record the ar pressure.  Adafruit again has a guide but it looks out of date -

My Setup

I have 2 Raspberry Pi's running 24 x 7 x 365 days a year measuring the weather.  The data is dumped to a MySQL database running on a website.

Pi 1 (at rear of property) - 2  DHT22 sensors (one inside, one outside), 20 DS18B20 temperature sensors, 2 Light sensors (inside and out), pressure sensor, Pi camera

Pi 2 (at front of property) - 2  DHT22 sensors (one inside, one outside), 5 DS18B20 temperature sensors, 2 Light sensors (inside and out), rain sensor, wind sensor, pressure sensor



Raspberry pi 3 chosen as it has built in wifi and low energy Bluetooth.  Cheaper older models are available but you'll have to buy Wifi adapter.  Most guides are written for Pi 3.  This would run on a Pi Zero (£5) but you then have extra problems with things like 1 usb port, soldering on the headers etc.

You can run a Raspberry Pi 3 from a normal USB power supply (mobile phone charger) as long as it can supply at least 2 amps.  The Pi will run on power adapters supplying less than 2 amps but you may run in to problems.

Sometimes you can buy higher capacity memory cards cheaper.  You need at least a 4gb memory card and I currently use 8gb cards.  I backup my cards every time I make a major change, so backing up 16gb card's would require more space.  The Pi supports up to 64gb micro SD cards.

Equipment Required (total about £60)




Other Stuff