pel.ly

Raspberry Pi LCD screen and temperature sensor

by on Oct.06, 2012, under Raspberry Pi

Items needed

Assumptions

  • The Adafruit Pi Cobbler has already been soldered.  See http://learn.adafruit.com/adafruit-pi-cobbler-kit
  • You have soldered pins to the bare wires of the DS18B20 temperature sensor (and covered with heatshrink) to allow them to be inserted into the breadboard.

We’ll be directly using 7 GPIO pins in total to connect the LCD character display and the 1-Wire temperature sensor directly to the Pi.

Wiring Diagram

Connect the cobbler power pins to the breadboard power rail. +5.0V from the cobbler goes to the red striped rail (red wire) and GND from the cobbler goes to the blue striped rail (black wire)

In order to send data to the LCD wire it up like this

  • Pin #1 of the LCD goes to ground (black wire)
  • Pin #2 of the LCD goes to +5V (red wire)
  • Pin #3 (Vo) connects to the middle of the potentiometer (orange wire)
  • Pin #4 (RS) connects to the Cobbler #25 (yellow wire)
  • Pin #5 (RW) goes to ground (black wire)
  • Pin #6 (EN) connects to cobbler #24 (green wire)
  • Skip LCD Pins #7, #8, #9 and #10
  • Pin #11 (D4) connects to cobbler #23 (blue wire)
  • Pin #12 (D5) connects to cobbler #17 (violet wire)
  • Pin #13 (D6) connects to cobbler #21 (gray wire)
  • Pin #14 (D7) connects to cobbler #22 (white wire)
  • Pin #15 (LED +) goes to +5V (red wire)
  • Pin #16 (LED -) goes to ground (black wire)

Then connect up the potentiometer, the left pin connects to ground (black wire) and the right pin connects to +5V (red wire)

Next, connect the cobbler +3.3V power pin to the breadboard bottom red striped rail (red wire). Then connect the DS18B20 temperature sensor as follows:

  • Connect pin 3 on the sensor (red wire) to the 3.3V GPIO pin
  • Connect pin 1 (black wire) to the ground GPIO pin
  • Connect pin 2  (white or blue wire) to the GPIO pin 4
  • Put the 4.7kΩ resistor between pin 2 and pin 3 of the temperature sensor.
  • Ignore the 4th wire (if present)
  • To test that the connections are the right way around, turn the Pi on, then put your finger against the sensor. If it is connected wrong, then it will get very hot within a second or two, in which case, turn the Pi off once it has booted and wait a while for it to cool down. Then take out the sensor and put it back in again the right way round.

 

Software Packages

LCD Screen

This guide is based on Debian’s “Wheezy” release for Raspberry Pi.

Add the latest dev packages for Python

$ sudo apt-get install python-dev

Upgrade distribute (required for RPi.GPIO 0.3.1a)

$ sudo apt-get install python-setuptools

$ sudo easy_install -U distribute

$ sudo apt-get install python-pip

Install rpi.gpio (0.3.1a) or later

$ sudo pip install rpi.gpio

I used the Python code for Adafruit’s Character LCDs on the Pi and it is available on Github at https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code

$ git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git

$ cd Adafruit-Raspberry-Pi-Python-Code

$ cd Adafruit_CharLCD

You can test the wiring from the previous step by simply running the Adafruit_CharLCD.py python code, as it has a little code it in that will simply display a test message when wired correctly

$ sudo ./Adafruit_CharLCD.py

Temperature Sensor

$ sudo modprobe w1-gpio

$ sudo modprobe w1-therm

$ cd /sys/bus/w1/devices/

$ ls

In the listing you will see one with a load of numbers, this is the serial number of the sensor. ie. 123-123456789

$ cd 123-123456789

$ cat w1_slave

You will see two lines of text outputted. The second line has the celcius temperature, its the number after the “t=”. Divide it by 1000 to get the actual temperature two digits, so the example value of “t=18750″ is actually “t=18.750″ Celsius

Combining the Two

$ cd Adafruit-Raspberry-Pi-Python-Code

$ cd Adafruit_CharLCD

$ vi CharLCD_Temp.py

 Python |  copy code |? 
01
#!/usr/bin/python
02
 
03
from Adafruit_CharLCD import Adafruit_CharLCD
04
from subprocess import *
05
from time import sleep, strftime
06
from datetime import datetime
07
 
08
lcd = Adafruit_CharLCD()
09
 
10
file = "/sys/bus/w1/devices/123-123456789/w1_slave"
11
 
12
lcd.begin(16,1)
13
 
14
def get_temp(file):
15
        #Open file written to by temp sensor
16
        tfile = open(file)
17
 
18
        #read all text in file
19
        text = tfile.read()
20
 
21
        #Close file once text is read
22
        tfile.close()
23
 
24
        #pull out the temperature value
25
        temperaturedata = text.split("\n")[1].split(" ")[9]
26
 
27
        # The first two characters are "t=", so get rid of those and convert the temperature from a string to a number.
28
        temperature = float(temperaturedata[2:])
29
 
30
        # Put the decimal point in the right place and display it.
31
        temperature = temperature / 1000
32
        return temperature
33
 
34
while 1:
35
        lcd.clear()
36
        tempVal = get_temp(file)
37
        lcd.message(datetime.now().strftime('%b %d  %H:%M:%S\n'))
38
        lcd.message('Temp %s C' % ( tempVal ) )
39
        sleep(60)
40

Save and run the script:

$ sudo ./CharLCD_Temp.py

Et Viola

Output from the Python script

This post was inspired by the following tutorials:

http://www.cl.cam.ac.uk/freshers/raspberrypi/tutorials/temperature/

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

Leave a Comment : more...

Home Networking Project

by on Feb.22, 2012, under Networking, Projects

As we were getting the attic converted, I decided to take the opportunity to wire the house up for Cat5e and have Node Zero located in the attic.

Equipment:
1 Data Cabinet (6u)
1 Patch Panel
1 Cable Organiser
1 Fanless Gigabit Router
1 Reel of Cat5e
Cat5e Euro modules
16 30cm patch cables
1 Cat5e Crimping Tool
1 Push Down  Krone Tool

I picked up the data cabinet with patch panel and organiser on adverts.ie for €50.  I decided to try and source a fanless router as the attic would also be used as a guest bedroom.   I came across a HP V1410-16G 16 Port Gigabit Switch on misco.ie for €90 (plus €18 delivery) which was a heck of a lot cheaper than I could find elsewhere.  Although it seems I may have gotten that as a misprice as its currently €148 (plus €18 delivery) which is similar to what it was on other website, happy days indeed :)

OK, lets go!

So the plan was to drop 4 Cat5e cables in each room.  At most, probably only 2 would be used but it was just as easy to drop 4 instead and future proof the installation somewhat.

Initial Drilling in Stud Wall

Initial drilling in stud wall partition

Having cut out a section of the dry wall using the lining box as a template, I borrowed some cable rods from a buddy which allowed the cables to be pulled through easily.  Those cable rods are kinda expensive but they really are worth their weight in gold.. I’m so glad my buddy bought them :)

Dry Wall Cut Out

Dry wall cut out with cable rod

 

Cable attached to cable rod

Time to start pulling the first cable through

 

First cable pulled through

Et viola, the first cable is pulled

Rinse and repeat for the remaining 3 cables and then fit the dry lining box.  Note the labelled cables to help with identification.

Lining Box with cables

The lining box fitted with all 4 cables pulled through

Each module was connected using the Krone tool, this is probably the most boring part of the whole project :)

Completed sockets

Completed sockets

Here is the eventual location of where the cabinet will be and where Node Zero will be housed. You can see some of the cables already routed in the background.

Eventual Node Zero

The eventual location of the cabinet housing Node Zero

 

Cabinet

The attic conversion progresses and the cabinet begins to take shape.

I was a little concerned about the amount of space there would be for opening the door of the data cabinet.  It turned out that there was a couple of mm of a gap to spare.

Fitting of data cabinet

The data cabinet gets tried out for size, it fits and the door can just about be opened

 

New sockets

The sockets get added

 

Data Cabinet and sockets

The sockets will be hidden from view once the data cabinet door is closed

 

Cut out for cables

The cut out for the cables to pass through was next

 

Draft Excluder

In order to prevent any unwanted drafts, I covered the cut out with a standard letter box draft excluder

 

The finished article

The data cabinet in place and all equipment connected

The box on top is a SamKnows white box which is used to gather reliable and accurate statistics as part of an EU wide study on broadband performance which I’m taking part in.

Some cable management required for the router/DSL modem

Internal view of the fully connected data cabinet. Some cable management required for the router/DSL modem though...

And that’s it! Its been a nice project to finally get done and have all the equipment neatly stored away and out from the reach of small hands :)

 

Leave a Comment :, , , more...

Recovered my sick Canon 350d

by on Dec.11, 2011, under Uncategorized

Location of Internal Date Battery

My trusty Canon 350d was sick, it would switch on but not take a shot.  I tried removing the battery for a while to see if it would reset but it didn’t make any difference.

I came across a post on dpreview.com which said to try the following:

1.) Turn off the camera.
2.) Remove both camera batteries (The main battery and the internal date/time battery which is beside the main battery)
3.) Close battery cover.
4.) Turn on/off switch to “On”.
5.) Let camera sit for at least 15 seconds.
6.) Turn on/off switch to “Off”.
7.) Re-install both batteries and turn camera on.

And it worked! Back in business… :)

Leave a Comment :, , more...

Ariva 120 Combo Channel List

by on Oct.01, 2011, under Uncategorized

I’ve reordered the channel list for the Ferguson Ariva 120 Combo box similar to how the sky channels are ordered.  The pay channels are obviously still scrambled.  The abs file below contains the channel list and a patched version of the 2.15B8 firmware, use it to update at your own risk:

http://pel.ly/y/ariva

Enjoy

14 Comments :, , , , more...

Spanish Grand Prix 2011

by on Jun.02, 2011, under Uncategorized

Had a fantastic time at my third F1 race, we were seated at the first corner and had a great view of the cars.

1 Comment more...

The Hero is up for sale

by on Oct.06, 2010, under HTC Hero

Upgrading to a HTC Desire so the Hero is being sold.

See the listing on adverts.ie

UPDATE: Hero is now sold :)

Leave a Comment more...

Android APN Settings 3 Ireland

by on May.28, 2010, under Android, HTC Hero

So there seems to be couple of versions of APN settings that work with Android when on 3 Ireland.

Most recently reported working version:

Name: 3
APN: 3ireland.ie
Proxy: not set
Port: not set
Username: not set
Password: not set
Server: not set
MMSC: http://mms.um.3ireland.ie:10021/mmsc
MMS Proxy: mms.3ireland.ie
MMS Port: 8799
MMS Protocol: WAP 2.0
MCC: 272
MNC: 05
APN Type: *

2nd Set:

Name: 3
APN: 3ireland.ie
Proxy: not set
Port: not set
Username: not set
Password: not set
Server: not set
MMSC: http://mms.um.3ireland.ie:10021/mmsc
MMS Proxy: mms.3ireland.ie
MMS Port: 8799
MMS Protocol: WAP 2.0
MCC: 272
MNC: 05
APN Type: default,supl,mms

3rd Set:

Name: 3 Ireland
APN: 3ireland.ie
Proxy: not set
Port: not set
Username: not set
Password: not set
Server: http://mobile.3ireland.ie/bb/HutchKey/
MMSC: http://mms.um.3ireland.ie:10021/mmsc/
MMS Proxy: mms.3ireland.ie
MMS Port: 8799
MMS Protocol: WAP 2.0
MCC: 272
MNC: 05
APN Type: not set

 

25 Comments more...

New Car

by on Feb.19, 2010, under Uncategorized

Said “what the heck” and decided to get myself a car…

I’ve driven other cars but this is the first time I can refer to a car as my car… my own policy etc etc and it feels really cool.

Can’t wait to get the keys :)

1 Comment more...

WordPress Android App

by on Feb.03, 2010, under Android, HTC Hero

There’s a new wordpress Android open source app which has just been released. Check it out here:

http://android.wordpress.org/

Looks like a very useful app!

Leave a Comment :, more...

I joined the Hero club

by on Jan.12, 2010, under HTC Hero

So finally decided to upgrade the HTC Tytn II and I ditched the world of WinMo and went for an HTC Hero…

So far so good, the phone feels nice in the hand and the touch screen takes a little bit of getting used to especially for me coming from a resistive touchscreen like the Tytn II but I seem to have the hang of it now.

Have attempted to root the phone in order to put a Modaco ROM on it but I can’t seem to get through the root’ing process.  I keep getting a “backup failed” message when using the FlashRec app… further investigation reveals that I’ll probably need to downgrade my hero in order to be able to root it :(

UPDATE 14 January 2010: Managed to root the Hero by using the downgrade method mentioned here. It seems as though the “one click” rooting method will not work for Hero’s with a Build Version of 2.73.405.66 and a downgrade is necessary in order to root it.

Leave a Comment :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!