1. Introduction
The LM35 is an analog temperature sensor that provides output voltage proportional to temperature. Since Raspberry Pi does not have an inbuilt analog input, an ADC like MCP3008 is used to read the sensor values.
2. Components
-
Raspberry Pi
-
LM35 Temperature Sensor
-
MCP3008 ADC
-
Breadboard
-
Jumper Wires
3. Circuit and connections
 |
Raspberry Pi Pinout Diagram
|
 |
| LM35 Pinout Diagram |
 |
| Pinout Diagram MCP3008 ADC Module |
Connections:
LM35 to MCP3008:
-
VCC → 3.3V
-
GND → GND
-
OUT → CH0 (MCP3008)
MCP3008 to Raspberry Pi:
-
VDD → 3.3V
-
VREF → 3.3V
-
AGND → GND
-
DGND → GND
-
CLK → GPIO11 (Pin 23)
-
DOUT → GPIO9 (Pin 21)
-
DIN → GPIO10 (Pin 19)
-
CS → GPIO8 (Pin 24)
4. Detailed Step By Step Circuit working
-
LM35 senses temperature and outputs analog voltage
-
Voltage increases with temperature (10mV per °C)
-
MCP3008 converts analog signal to digital
-
Raspberry Pi reads digital data using SPI
-
Temperature is calculated from voltage
-
Value is displayed on screen
5. Libraries to be included
6. Code
7. Detailed Step By Step Code working
-
Import SPI and time libraries
-
Initialize SPI communication
-
Define function to read ADC channel
-
Read analog value from MCP3008
-
Convert ADC value to voltage
-
Convert voltage to temperature (×100)
-
Print temperature
-
Add delay for continuous reading
8. Tips
-
Use proper SPI configuration
-
Ensure correct MCP3008 wiring
-
Keep sensor away from heat sources
-
Use stable 3.3V supply
9. Uses
-
Temperature monitoring systems
-
Weather stations
-
Industrial automation
-
Home automation
10. Conclusion
The LM35 sensor provides accurate temperature measurement. Using an ADC like MCP3008 allows Raspberry Pi to read analog values efficiently.