element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog Time & Temp display for Raspberry Pi
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fustini
  • Date Created: 23 Sep 2012 6:56 AM Date Created
  • Views 1930 views
  • Likes 0 likes
  • Comments 1 comment
Related
Recommended
  • i2c
  • rtc
  • raspberry_pi
  • sparkfun
  • rpiexpert
  • rpi
  • adafruit

Time & Temp display for Raspberry Pi

fustini
fustini
23 Sep 2012
imageWant to build this project?
View Parts

 

I previously wrote about adding a real-time clock and temperature sensor to the Raspberry Pi.  I've now added an Adafruit I2C 7-segment display to create a time & temperature display:

image

simon.monk conveniently ported Adafruit's Arduino library for the display to Python for the Pi as he covers in his blog post: Led Clock using Raspberry Pi.  His i2c7segment Python library is available on Google Code.  Simon describes the setup and installation process:

I had to do the following to get I2C to work, following the instructions here:


sudo apt-get install python-smbus

sudo apt-get install i2c-tools (usefull but not essential)

sudo modprobe i2c-dev

sudo modprobe i2c-bcm2708

 

To simplify the process of using the display, I have created a Python library modelled on the Adafruit library for Arduino. You can download this from here and then cd into the extracted folder and do:


sudo python setup.py install

I also had to install the PySensors Python library which enables reading the temperature sensor via lm-sensors.  I downloaded the library and then installed with:

sudo python setup.py install

I'm using Adafruit's Occidentalis v0.2 image, but I believe this should also work on the latest Raspbian Wheezy image.  Before I go further into the software, I'll go over the hardware setup which is shown in this Fritzing diagram:

image

I must WARN that I have removed the resistors from the Adafruit DS1307 RTC.  It runs at 5V so Adafruit recommends removing them so that it doesn't damage the Pi's 3.3V pins.  Aside from that, the SparkFun TMP102, Adafruit RTC and Adafruit 7-segment display are all connected to the Pi's I2C bus via the Adafruit Pi Cobbler breakout board.  There is also a pushbutton which is connected to the Pi's GPIO #23.  A 10K resistor pulls it up to 3.3V when the pushbutton is not being pressed.  The software displays the temperature for 3 seconds when the button is pressed:

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

This Python script, timetemp.py, runs the show:

 

It is based on Simon's example clock script as well as Adafruit's tutorial on using buttons with the Pi.  I soon realized that I wanted this script to run automically when the Pi boots up rather than having to login in to run it.  I first created this bootup "init" script which is placed in /etc/init.d/timetemp:

 

I then actived this init via this command:

sudo update-rc.d timetemp defaults

 

Then I created a wrapper shell which the init script calls.  It initilizes the RTC and temperature sensor on the I2C bus and then sets the system time from the RTC:

 

However, it turned out that there were other init scripts interfering with the time after I set it.  I disabled these conflicting scripts with the commands:

sudo update-rc.d -f hwclock remove

sudo update-rc.d -f fake-hwclock remove

The 7-segment display now displays the correct time everytime I turn on my Pi.  Here it is perched atop my cube next to a nice Freescale clock: it's a binary and decimal friendly workplace now image

image

 

Cheers,

Drew

 

 

 

Product Name*DescriptionSupplier
Raspberry Pi Model B Raspberry Pi model BRaspberry Pi
Buy Now
Optical Mouse Basic USB optical mouseIONE / Pro Signal
Buy Now
Raspberry Pi Power Supply 120-240v to 5V power supply with micro USB connectorRaspberry Pi
Buy Now
Keyboard Basic USB keyboardGear Head / A4 Tech
Buy Now
Pre-programmed 4GB SD card 4GB Class 4 SD card preloaded with Debian 6 LinuxSamsung
Buy Now
Adafruit Pi Cobbler GPIO breakout kit for Raspberry PiAdafruit Industries
Buy Now
Breadboard Basic breadboard with 830 connection pointsTwin Industries
Buy Now
Jumper wire bundle Jumper wires for use on breadboardBud Industries
Buy Now
10k resistor 10K ohm, 250mW carbon film resistorsMulticomp
Buy Now
DS1307 RTC breakout DS1307 I2C real time clock on breakout boardAdafruit Industries
Buy Now
TI TMP102 breakoutTI TMP102 I2C temperature sensor on breakout boardTI / Sparkfun electronics
Adafruit 4-Digit 7-Segment Display Adafruit 0.56 4-Digit 7-Segment Display w/I2C Backpack, redAdafruit Industries
Buy Now
SPST tactile switch Small SPST tactile switch with through hole connectionsApem
Buy Now

 

*Products and resources listed are listed to help members build their own Pi Projects. They are suggestions and listed for educational purposes. For substitutions of any parts, please post a question asking the original author.

  • Sign in to reply
  • mjtminn
    mjtminn over 8 years ago

    Somehow trying to order the parts for this brings me to the correct place, but I cannot checkout from the location.  Any ideas? 

     

    I would love to build this little project and demonstrate how a Raspberry Pi might work

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube