My Current Pi Projects

Featured

Update 19 December 2017

Raspberry Pi's

  • Raspberry Pi 1 - OSMC Media Centre (B rev 1)
  • Raspberry Pi 2 - Weather Logging Rear / USB memory stick/ DNS Server (B+)
  • Raspberry Pi 3 - Weather Logging Front (B+)
  • Raspberry Pi 4 - DNS Server with Ad Blocking 433mhz receiver / Energenie Remote Plug controller (B rev 1)
  • Raspberry Pi 5 - Weather Display Board (A)
  • Raspberry Pi 6 - Gardening Pi connected to 8 way relay board (A+)
  • Raspberry Pi 7 - Connected to a cross trainer to track RPM / time (Zero rev 1.2)
  • Raspberry Pi 8 - Monitoring Station connected to 22" monitor (2)
  • Raspberry Pi 9 - Electricity Monitor connected to multiple SCT-013-000 Current Sensors (A+)
  • Raspberry Pi 21 - Pi Camera and USB Camera running motioneyeos (Front left) (B rev 2)
  • Raspberry pi 22 - Pi Camera and USB Camera running motioneyeos (Front right) (B rev 2)
  • Raspberry pi 22 - Pi Camera and USB Camera running motioneyeos (Rear) (B rev 2)

Broken - 1 x B+ (water), 2 x B rev 3 (ebay arrived broken)
TinyTX3 - Wireless Sensors - http://nathan.chantrell.net/tinytx-wireless-sensor/

  • Bathroom - DHT22 Humidity Sensor (Node 11)
  • Kitchen - DHT22 Humidity Sensor (12)
  • Hallway - DHT22 Humidity Sensor (14)
  • Extractor Fan Pipe - DHT22 Humidity Sensor (15)
  • Freezer- DS18B20 1-Wire Temperature Sensor (23)
  • Fridge - DS18B20 1-Wire Temperature Sensor (24)
  • Spare - DS18B20 1-Wire Temperature Sensor (26)
  • PC Case - DS18B20 1-Wire Temperature Sensor (27)
  • Air Con Fan - dual DS18B20 1-Wire Temperature Probes (29)
  • Door Switch (5)
  • Window Switch (6)

Wemos Devices

  • Wemos 1 - Weather sensing attached to 3 AA rechargeable batteries
  • Wemos 2 - Weather sensing attached to 4 AA rechargeable batteries
  • Wemos 3 - Weather sensing attached to 5 x 18650 batteries
  • Wemos 4 - Electricity Usage monitor attached to a SCT-006-000 current sensor

 

This site is a collection of notes, documentation and web links for my Pi's.

Retired Pi Uses

I mainly buy parts from CPC, ModMyPi, Pimoroni and eBay

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);
  Serial.begin(9600);
  attachInterrupt(0, arduino_anemometer, RISING);
  
  tenseconds = millis() + 10000;
  sixtyseconds = millis() + 60000;
  
  //countarray[]= {0,0,0,0,0,0};
  
  loopcount = 0;
  maxofcount = 0;
  Serial.print("Startup\n");
  //printwait();
  count = 0;
}

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

      //printwait();
      tenseconds = millis() + 10000; 
      count = 0;
      //Serial.print("\n");
    }
  else
     {
        if(millis() < (tenseconds - 20000))
          {
            tenseconds = millis() + 10000;
          }
     } 
}

void arduino_anemometer()
{
  count++;
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
}


void printwait()
  {
      Serial.print("\n");
      Serial.print("                                   Current time - ");
      Serial.print(millis());
      Serial.print("      tenseconds = ");
      Serial.print(tenseconds);
      Serial.print("      sixtyseconds = ");
      Serial.print(sixtyseconds);
  }
  

int getIndexOfMaximumValue(int* array, int size)
  {
    int maxvalue = 0;
    for (int i=0; i<size; i++)
      {
        //Serial.print("\n");
        //Serial.print("              Array Number ");
        //Serial.print(i);
        //Serial.print("  Array value ");
        //Serial.print(array[i]);
        //Serial.print("  Max value ");
        //Serial.print(maxvalue);
  
        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;
  }

5Pcs USB CH340G Nano V30 16M 5V ATmega328P Micro Controller Board For Arduino
5Pcs USB CH340G Nano V30 16M 5V ATmega328P Micro Controller Board For Arduino $15.99
End Date: Friday Jan-26-2018 8:25:37 PST
Buy It Now for only: $15.99
Arduino Nano V30 ATmega168 5V Micro controller USA seller fast shipping
Arduino Nano V30 ATmega168 5V Micro controller USA seller fast shipping $5.95
End Date: Saturday Jan-27-2018 19:31:35 PST
Buy It Now for only: $5.95
MINI USB Nano V30 ATmega328P CH340G 5V 16M Micro controller board Arduino
MINI USB Nano V30 ATmega328P CH340G 5V 16M Micro controller board Arduino $5.95
End Date: Tuesday Feb-6-2018 21:22:50 PST
Buy It Now for only: $5.95
3Pcs USB CH340G Nano V30 16M 5V ATmega328P Micro Controller Board For Arduino
3Pcs USB CH340G Nano V30 16M 5V ATmega328P Micro Controller Board For Arduino $10.95
End Date: Sunday Feb-18-2018 7:35:38 PST
Buy It Now for only: $10.95
Arduino Nano V30 Micro Controller ATmega328 16M 5V CH340G Ships Today from USA
Arduino Nano V30 Micro Controller ATmega328 16M 5V CH340G Ships Today from USA $4.98
End Date: Friday Feb-9-2018 19:12:09 PST
Buy It Now for only: $4.98
Arduino Nano V30 ATmega328 5V Micro controller USA seller fast shipping
Arduino Nano V30 ATmega328 5V Micro controller USA seller fast shipping $5.99
End Date: Tuesday Jan-23-2018 1:03:11 PST
Buy It Now for only: $5.99
MINI USB Nano V30 ATmega328P CH340G 5V 16M Micro controller board Arduino
MINI USB Nano V30 ATmega328P CH340G 5V 16M Micro controller board Arduino $5.95
End Date: Friday Feb-16-2018 16:30:24 PST
Buy It Now for only: $5.95
USB Nano V30 ATmega328 16M 5V Micro controller CH340G board For Arduino
USB Nano V30 ATmega328 16M 5V Micro controller CH340G board For Arduino $2.90
End Date: Wednesday Jan-31-2018 16:16:05 PST
Buy It Now for only: $2.90
V30 5V 16M For Arduino CH340G Board USB Nano Micro controller
V30 5V 16M For Arduino CH340G Board USB Nano Micro controller $2.29
End Date: Thursday Feb-8-2018 16:51:23 PST
Buy It Now for only: $2.29
Arduino Nano V30 Micro Controller ATmega328 16M 5V CH340G Ships Today USA
Arduino Nano V30 Micro Controller ATmega328 16M 5V CH340G Ships Today USA $5.94
End Date: Friday Feb-16-2018 7:06:41 PST
Buy It Now for only: $5.94

« Previous12345...910

 

Add static IP address to ethernet

Raspbian Jessie

sudo nano /etc/dhcpcd.conf
interface eth0

static ip_address=192.168.1.82/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.162

 

On Older Raspbian

sudo nano /etc/network/interfaces

address 192.168.1.67
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

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 - https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging

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 - https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing

You might wish to record the ar pressure.  Adafruit again has a guide but it looks out of date - https://learn.adafruit.com/using-the-bmp085-with-raspberry-pi/using-the-adafruit-bmp085-python-library?view=all

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

 

Notes

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)

 

Optional

 

Other Stuff

Using Energenie Power Plugs

Forget Energenie's own sample.  See http://bennuttall.com/whats-new-gpio-zero-v1-2/

https://pypi.python.org/pypi/energenie

 

from energenie import switch_on, switch_off
from time import sleep

# turn all plug sockets on and off
switch_on()
switch_off()

# turn a plug socket on and off by number
switch_on(3)
switch_off(3)

sudo apt-get install python-pip
sudo pip install energenie

sudo apt-get install mysql-client python-mysqldb -y