i2c Analogue Breakout PCB (ver 1.2)

As part of development of Weather Pi, I wanted to test out Analogue sensors with the Raspberry Pi.  I had a look a some of the commercial available PCB's such as Custard Pi and Quick2Wire but was shocked at the high price (£15 - £20 plus P&P).

PCF8591The PCF8591 I2C chips that these units are based on can be purchased for about £1 so that does not justify the high price. This includes postage from China.


Introducing the Analogue Breakout Version 1.2 PCB.


The PCB uses 2 x PCF8591P i2c chips providing 8 ports for analogue sensors.  The chips are hard coded on the PCB to use i2c channel 48 and 4c.

The PCB has a jumper to allow the chips to run at 3.3 volts or 5 volts.  At the time of designing I was unsure if it was safe to run the chips at 5v when interfacing with the RaspberryPi.  Normally the Pi's only like 3.3 volts.

Also on the PCB are 3 x i2c headers running at 3.3v.

The PCB is compatible with all models of Pi except the compute model.  Only the 3.3v, 5v, GND, SDA and SCL pins are used. Using a 5cm board it's not possible to include space for all 40 possible GPIO pins, hence why they run to the edge.

The PCB's were ordered from SeedStudio, and cost about £7 for 10.



Update on Weather Pi – February (PCB Ver 2)

Testing on the Weather Pi continues.

I already have code for all the sensors apart from the Wind Direction sensor.  The direction sensor uses 8 different resistors to indicate the wind direction using only 2 wires.  Unfortunately I've had major problems calibrating it.  The code is basically the same for detecting the light level using an LDR, but I've not been able to tune it to obtain reliable results.

I've decided that the capacitor method for detecting analogue values is not reliable enough.

PCF8591I've been working on a new PCB design that will use dedicated analogue sensors.  I could have used an 8 port SPI chip but the code looked rather complex to interpret the values.  Instead I decided to use an I2C PCF8591. Unfortunately it only has 4 ports, so I'll use 2 of them.

This is the latest PCB Design.


Major changes have been made to the PCB:-

  • 40 Pin header to connect to a Raspberry Pi A+, B+ and Pi2 (Weather Pi also works with A and B models)
  • Row of breakout pins alongside the GPIO header
  • 2 additional 3.3v I2C headers points, and 2 x 5v points
  • More header points for the temperature sensors (ds18b21)
  • Sensors that work as switches will use an MCP23017 I2C chip (Rain Quantity, Wind Speed, plus the 3 switched used for monitoring)
  • Analogue Sensors will use a PCF8591P I2C chip (Light Level, Wind Direction, Rain Detector and an additional soil moisture sensor).  There's a jumper to allow either 3.3v or 5v operation.  At the time of designing this I'm unsure if it's safe to use 5 volts.
  • The 3 LED's are joined by a 4th Blue LED, and will run via the same MCP23017.  This will allow 4 additional LED's to be added at a later date.  Red - power, Orange - Linux running, Green - script running, Blue - networking working.
  • Points added to allow surface mount Switches, LED's and resistors to be used (SMD components).
  • A 16 row breadboard style prototyping area, with 3.3v and negative power rails.

The PCB has grown from 10cm x 5cm to 10cm square.  The size is required to fit the 2 analogue chips and one digital chip.  Space may be saved in future versions by using surface mount chips.


Update on the Weather Pi – January

A short update on the Weather Pi. The Weather Pi unit has been fully assembled and tested on the bench.

2015-03-02 11.28.18I've slightly modified the stand for the sensors to reduce the number of components required.  On the left hand side we have the wind speed and wind direction.  Right hand side we have the temperature sticking out of the end of the pipe.  Unseen inside the pipe is the humidity sensor.  On top we have the rain detector and the rain quality sensor.  The cables are fed inside the plastic tubes down to the base.

2015-03-02 11.28.31The plastic tubes are made from 44mm drainage pipe normally used to connect sinks and washing machines to the drains.  The bottom of the pipe has been cut at a 45 degree angle to allow it to be driven in to the ground.  I've placed 45 degree bends on to top T section of pipe to try and keep the bulk of the rain out, whilst allowing air to circulate to the humidity sensor.

2015-03-02 11.28.41The Raspberry Pi and the Weather Pi circuit board have been placed inside a "DriBox" enclosure.  This has access points to allow cables to enter the box, and have rubber seals to keep the rain out. I plan to have the LED's sticking out of the case so I can see the Pi has power and is running the scripts.  The case has enough room for the Raspberry Pi, Circuit board, USB WIFI dongle with large areal, and also a large USB battery.  At this stage I haven't been able to route electricity outside to power the box, so am relying on USB batteries





Weather Pi – first one now soldered

Weather-Pi-PCB-SolderedMy first Weather Pi is now soldered up. Took about 45 minutes to solder it.

For some reason the resisters I ordered from CPC seem to be smaller than what I would class as "normal" size. This caused delays in bending the legs to the correct size.

After further research I bought resisters about 3.2mm in length rather than the normal 6mm in size.  I still haven't worked out what the difference is between them.

I decided the first Weather Pi would be a low profile version, so used 90 degree Molex connectors.

The PCB includes 3 LED connection points, but decided just to solder the LED's straight to the PCB.


Weather Pi – PCB Design

weather-pcb-10-x-5-Ver1-2_pcbUsing the initial Proto Plate design, I was able to turn that in to a PCB layout.  Again this was done using the Open source Fritzing computer program.

It took many iterations to obtain the best layout of the board as there's no set layout required.  Initially I tried a 5cm x 5xm layout but just couldn't get it to fit.  Then a 5cm x 10cm board was tried with the Molex connectors round the edges.  Also tried a 10 x 10cm board. Finally after many days work I managed to put all the connectors down one side of a 5cm x 5cm PCB.

Using Fritzing I was able to export the design as a Gerber file.  This is an industry standard design file for producing PCB's.  I'd used SeedStudio PCB fabricators before and was happy with the quality so decided to use them again.

SeedStudio charge about $15 for 5 copies of a 5cm x 10cm design.  Delivery can be up to 6 weeks unfortunately.

It was easy to upload the Gerber PCB files to SeedStudio and the order is now in progress.

Weather Pi – Prototype

Weather-Pi-Prototype-Proto-PlateThis is the first version of my Weather Pi for the Raspberry Pi.

I've built 4 Pi setups that have included various weather monitoring hardware - light, temperature, humidity, pressure, wind speed, water detector etc. Each has been slightly different - like GPIO pins used and style of connectorss. Each has required custom software to make it run unfortunately which has meant simple things took longer. I thought it was time to make a standard platform that I could quickly build and use.

Introducing the Weather Pi prototype:-


 Initial Design

The initial design was done using an open source program called Fritzing (http://fritzing.org/home/).  Once the Adafruit extensions are installed you can design a circuit board fairly easily.  Unfortunately there isn't an Adafruit Raspberry Pi Proto plate in the library so I had to kind of make one up.  Unfortunately the Pi connector on the Pi proto plate takes up more room than my design.

I like to use Molex connectors on my project to allow sensors to be replaced easily.  Rather than having to unsolder a sensor I can just unclip it, and clip in a new one.  This has saved so much time over the years.

Using Fritzing allowed me to minimise the amount of space used on the board for future use.  Hadn't noticed I'd basically used all the GPIO's so this was fairly pointless.

The Stand (white pipe)

In the past I've built wooden frames for my projects.  This takes a bit to design, paint and maintain.  As this project could live outside, I decided to use 40mm white drain pipe and connectors.  This pipe should be joined using welding glue but I'll probably just use hot glue.


Using existing code I was able to set up the scripts quickly.

  • Get-Weather.py - gather the data from the sensors and upload to MySQL database hosted on the web.  Run via a CRON automated job every 10 minutes
  • Rain.py - this script runs continuously waiting for the rain gauge to "flip". Once it's flipped it inserts a line in to a database hosted on the web.
  • Wind.py - This script runs for 1 minute and counts the number of times the wind sensor spins. This data is uploaded to a separate table in the database.  The script then starts for the next minute and starts again.  This effectively means it's only uploading 30 times an hour given the time it takes to upload.
  • Take-Photo.py - take a photo on the Raspberry Pi Camera and upload to the web. Run via a CRON automated job every 15 minutes
  • Monitor.py - Check networking and if there is no networking, try and start it.  Also checks the Get-Weather script is running, reboots if not.


It wasn't till I tried to plug the Molex connectors in that I realised you can't put 4 connectors side by side. There just isn't room.  This meant that one of the 4   temperature sensor sockets couldn't be used.

This was the first time I've used a wind direction sensor and it turns out it's an analogue device that returns a different resistance depending where the wind direction is.  I put this through the same kind of circuitry as the Light Sensor (LDR). Unfortunately I can't get repeatable values out of this.  Will need to see how it is long term.

The Future

Next step will be to design a PCB and have it manufactured, then further testing.  I may try redesigning this to use an MCP23017 IO Expander to handel the "switch" type devices (wind speed, rain gauge, 3 push buttons) and an MCP3008 analogue to digital converter for the LDR and wind direction sensor.

Once it's all perfected I'm looking to sell kits of the main PCB.


How to update Raspbian – firmware, kernal and software

Check which Kernel you are running

uname -a

My current version is 3.10.37+

Update the list of software repositories

sudo apt-get update

Updating the Firmware

sudo rpi-update

sudo reboot

Updating the Kernel

sudo apt-get -y dist-upgrade

Update the software

sudo apt-get update

Or all in one

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

Warning - all of the above could be bogus