We have mostly covered all the Basic Components interfacing with Raspberry Pi in our Raspberry Pi Tutorial Series. We have covered all the Tutorials in simple and detailed manner, so that anyone, whether he has worked with Raspberry Pi or not, can learn from this Series easily. And after going through all the tutorials you will be able to build some High Level projects using Raspberry Pi.
So here we are designing first application based on the previous tutorials. The first basic application is a Reading Room Temperature by Raspberry Pi. And you can monitor the Readings on computer.
As discussed in previous tutorials, there are no ADC channels provided internally in Raspberry Pi. So if we want to interface any analog sensors we need an ADC conversion unit. And in one of our tutorials we have Interfaced ADC0804 chip to Raspberry Pi to read an analog value. So go through it before building this Room Temperature Thermometer.
ADC0804 and Raspberry Pi:
ADC0804 is a chip designed to convert analog signal in to 8 bit digital data. This chip is one of the popular series of ADC. It’s an 8bit conversion unit, so we have values or 0 to 255 values. The resolution of this chip changes based on the reference voltage we choose, we will talk more about it later. Below is the Pinout of ADC0804:
Now another important thing here is, the ADC0804 operates at 5V and so it provides output in 5V logic signal. In 8 pin output (representing 8bits), every pin provides +5V output to represent logic’1’. So the problem is the PI logic is of +3.3v, so you cannot give +5V logic to the +3.3V GPIO pin of PI. If you give +5V to any GPIO pin of PI, the board gets damaged.
So to step-down logic level from +5V, we will be using voltage divider circuit. We have discussed Voltage Divider Circuit previously look into it for further clarification. What we will do is, we use two resistors to divide +5V logic into 2*2.5V logics. So after division we will give +2.5v logic to PI. So, whenever logic ‘1’ is presented by ADC0804 we will see +2.5V at the PI GPIO Pin, instead of +5V.
LM35 Temperature Sensor:
Now for Reading Temperature of Room, we need a sensor. Here we are going to use LM35 Temperature Sensor. Temperature is usually measured in “Centigrade” or “Fahrenheit”. “LM35” sensor provides output in degree Centigrade.
As shown in figure, LM35 is a three pin transistor like device. The pins are numbered as,
PIN1= Vcc – Power (Connected to +5V)
PIN2= Signal or Output (connected to ADC chip)
PIN3 = Ground (Connected to ground)
This sensor provides variable voltage at the output, based on temperature. For every +1 centigrade rise in temperature there will be +10mV higher voltage at the output pin. So if the temperature is 0◦ centigrade the output of sensor will be 0V, if the temperature is 10◦ centigrade the output of sensor will be +100mV, if the temperature is 25◦ centigrade the output of sensor will be +250mV.
Here we are using Raspberry Pi 2 Model B with Raspbian Jessie OS. All the basic Hardware and Software requirements are previously discussed, you can look it up in the Raspberry Pi Introduction, other than that we need:
- Connecting pins
- 1KΩresistor (17 pieces)
- 10K pot
- 0.1µF capacitor
- 100µF capacitor
- 1000µF capacitor
- ADC0804 IC
- LM35 Temperature Sensor
- Bread Board
Circuit and Working Explanation:
The connections which are done for Connecting Raspberry to ADC0804 and LM35, are shown in the circuit diagram below.
For more detail: Room Temperature Measurement with Raspberry Pi