Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Measuring Temperature using LM74 temperature sensor by Texas Instruments and Pic18f452 Microcontroller

By EG Projects August 14, 2019

In this post i am going to interface LM74 temperature sensor with Pic18f452 microcontroller. LM74 is a temperature sensor by Texas Instruments. It comes with an SPI (Serial Peripheral Interface) interface. You can operate it in SPI (Serial Peripheral Interface) mode. A processor/microcontroller can read temperature reading from LM74 at any time. LM74 provides resolution of up to 0.0625 degree Centigrade. It can operate between -55 degree to +150 degree centigrade. It works only as slave in a system. When interfaced with processor / microcontroller in SPI mode it can only be a slave to a host.

I assume that you are already familiar with the SPI interface. If not then first took some tutorials on SPI (Serial Peripheral Interface) interface before going through this project.

LM74 Pinout and Pin Description

LM74 Pinout and Pin Description

LM74 Temperature Sensor Pin Out

LM74 pinoutLM74 pinout

The only important pins are SI/O (Slave Input/Output) and SC (Slave Clock). CS is Chip select and its active low,  the sensor will not work if you don’t make CS Low(0). So make sure to make CS low before using the sensor.
​

SI/O is Slave input/output. All the commands, control signals and data, travels in and out of the sensor from this pin.Data is clocked out from the sensor on the falling edge of the serial clock (SC), while data is clocked in on the rising edge of SC. A complete transmit/receive communication will consist of 32 serial clocks. The first 16 clocks comprise the transmit phase of communication, while the second 16 clocks are the receive phase. SC is Slave clock. In SPI mode clock is essential to carry out the task. 

LM74 Temperature Sensor Registers

LM74 temperature sensor has three registers. All three registers are 16-bit wide.

LM74 Temperature Sensor Configuration Register

Configuration register sets the LM74 in shutdown or continuous conversion mode. Continuous conversion means continuously convert the temperature. Its a 16-bit wide register. To enable shutdown mode or continuous conversion mode see the data bits configuration in the pic from datasheet below.
LM74 temperature Sensor Configuration Register

LM74 temperature Sensor Configuration Register

LM74 Temperature Register

LM74 measures temperature and places the equivalent digital value in the Temperature register. Now host can read  the temperature from temperature register. Its a 16-bit wide register. First 2 bits are void. Third bit is always high. Bits from 4 to 16 (DB3 to DB15) are data bits. Temperature digital values are stored in these DB3 to DB15 bits. 

Note: On first power up LM74 will output arbitrary data don’t worry its for the first time power up. Then its start working perfectly.

LM74 Temperature Register

LM74 Temperature Register

LM74 Manufacturer’s Device ID Register

This register works only when LM74 is in shutdown mode. It outputs manufacture device ID. You don’t need to care about this register.
LM74 temperature sensor Manufacturer's Device ID Register

LM74 temperature sensor Manufacturer’s Device ID Register

SPI communication with Pic8f452 Microcontroller

Four pins of Pic18f452 are dadicated for SPI communication. It is assumed that you are already familiar with the  SPI communication protocol and their is no need to explain these pins and their functions.

  • Serial Data Out (SDO) – RC5/SDO
  • Serial Data In (SDI) – RC4/SDI
  • Serial Clock (SCK) – RC3/SCK
  • Slave Select (SS) – RA5/SS

Three registers are associated with SPI communication. To carry out successful SPI communication we have to configure them correctly.

SSPSTAT SPI status register

Individual bits of register with their fuctions are below. I uploaded SSPSTAT=0x00 which means SPI in Master Mode, Data transmitted on falling clock.
SSPSTAT Register of PIC18f452 Microcontroller

SSPSTAT Register of PIC18f452 Microcontroller

SSPCON1 SPI Control Register

Individual bits of register with their functions are below. I uploaded SSPCON1=0x20 which means Serial port not enabled and Clock=Fosc/4.
Pic18f452 SSPCON1 Register with individual Bits

Pic18f452 SSPCON1 Register with individual Bits

SSPBUF (Serial Receive and Transmit Register)

This register is not directly accessible. The data which goes out and comes in is dropped in this register and user can pick data from this register.

Project Circuit Diagram

Project Circuit Diagram

LM74 temperature sensor by Texas instruments interfacing with Pic18f452 Microcontroller

Project Code

Project code is written in c language and is compiled in MP-Lab using high tech C compiler. Simulation is made in proteaus 8.0.
Download the Project files, folder includes the project code(Hex, C++) and simulation in Proteaus 8.0. If you have any questions regarding the post please leave your queries below in the comments section.

LM74 with Pic18f452 Microcontroller


Filed Under: Microcontroller Projects, PIC Microcontroller

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • 12VAC to 12VDC 5A on 250ft 12AWG
  • Engineer's own PCB layout software guide?
  • Zeropole...
  • Does mobility carrier ratio changes with Wn? (0.18um) inverter design
  • I think i have devised a new type of "super_transformer" for the Electricity grid?

RSS Electro-Tech-Online.com Discussions

  • Lightbox circuit
  • I want to make a CRT with some modifications But i have no Idea where to start
  • Kawai KDP 80 Electronic Piano Dead
  • LT3511 Isolated Flyback Converter
  • Funny Images Thread!

Featured – Designing of Audio Amplifiers part 9 series

  • Basics of Audio Amplifier – 1/9
  • Designing 250 Milli Watt Audio Power Amplifier – 2/9
  • Designing 1 Watt Audio Power Amplifier – 3/9
  • Designing a Bass Boost Amplifier – 4/9
  • Designing a 6 Watt Car Audio Amplifier – 5/9
  • Design a low power amplifier for headphones- 6/9

Recent Articles

  • ITG Electronics releases gate drive transformers with 200 – 450 V DC capability
  • Stackpole introduces HCJ jumpers with 70.7 amp continuous current capability
  • Infineon releases MCU with 128K flash and multi-sense capabilities
  • ST introduces 600V GaN gate drivers with 300 ns start-up time
  • ABLIC releases S-19116 automotive voltage detector with 6.8ÎĽs response time

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe