With just two simple Python files, an inexpensive LCD display and a low-cost digital temperature sensor, you can turn Raspberry Pi into a beautiful LCD clock with IP address and temperature indication facility. There will still be a few GPIOs available to hook up other systems such as an alarm triggered by temperature or time threshold. Since we will be using quite a handful of data, it is better to use a four-line LCD display with characters not less than 16 per line. Fig. 1 shows the author’s prototype.
Circuit and working
Fig. 2 shows the pin configuration of Raspberry Pi. The GPIO connector has seven true GPIO pins, I2C interface, SPI interface, serial TX/RX pins and PWM pins that can be used to control external hardware.
Fig. 3 shows the connection scheme for the clock. The main components used are Raspberry Pi board, temperature sensor DS18B20 (IC1) and 4×20 LCD module. IC1 is a heat sensor with an operating range of -55°C to +125°C. It can derive power directly from the data line, eliminating the need for an external power supply. But, in this project, we have used 3.3V output from Raspberry Pi to power it. The system works on one-wire protocol. Output of temperature sensor IC1 is read by GPIO4 (pin 7) of Raspberry Pi.
Make all the connections as per Fig. 3 and ensure that a small resistor (4.7K to 10K) is connected between data pin 2 and power pin 3 of IC1 to pull-down data-out signal.
Switch on your Raspberry Pi and touch the sensor (IC1) to see that it is not getting over-heated because of any wrong connection. Once all the connections are checked, follow the instructions in software section below to load the temperature sensor module and the clock. The IP and temperature will appear on the LCD.
It is assumed that your Raspberry Pi is already set up with Raspbian ‘wheezy’ operating system. If not, you can refer ‘Getting Started with Raspberry Pi’ article published in April 2013 issue to set it up.
Now, all you need is a network connection for Raspberry Pi to install all the software. Refer ‘Set Up Network for Raspberry Pi’ published in May 2013 issue for getting the network connection up on your Raspberry Pi. Once done, you can either connect a keyboard and a display to Raspberry Pi and start following the installations using Lx terminal, or you can access Raspberry Pi remotely using SSH and execute all the commands directly.
After login to Raspberry Pi, load the DS18B20 module and get the temperature data ready for viewing, using the commands:
You will need ID number of the DS18B20 module to read the temperature through the application program. You can get the ID using the command mentioned below, as shown in Fig. 5:
The ID in our case is 28-000004ee2c8a. In your case, it will be similar but certainly different. Note this ID as it will be used in the application program to get the temperature data.