Engineers Garage

  • Electronic Projects & 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

Measure Temperature using LM35 Interfacing with Beaglebone black (Part 15/15)

By Ashish Vara August 24, 2016

Prototype of Beaglebone Black and LM35 Sensor based Temperature Monitor

Fig. 1: Prototype of Beaglebone Black and LM35 Sensor based Temperature Monitor

This tutorial explains how to interface LM35 Temperature sensor with Beaglebone black to work with sensor interfacing. LM35 is an analog sensor which measures the temperature and linear output given in voltage form. ADC is required to convert analog output of temperature sensor to digital output.  Since BBB has an on chip ADC, you can directly interface these two. Program is written in python script with adafruit GPIO library.

Required Tools:

  • Beaglebone Black
  • LM35Breadboard
  • Female to Female connectors

Setup of Software environment:

Install the latest python version in BBB as explained in tutorial How to make first python program with Beaglebone Black. Install the adafruit python-GPIO library named adafruit_BBIO.

Working:

It is a simple learning tutorial that makes use of ADC with Beaglebone black. I have interfaced temperature sensor LM35 with 12 bit ADC of BBB. Output of LM 35 is analog form which is input of ADC. Output of ADC is digital value and it is converted in Celsius and Fahrenheit by formula. Reference voltage of ADC is 1.8 V. So you can give maximum 1.8 V on ADC pin.

Stepsize of LM 35 is 10 mV means when 1 degree temperature changes, output voltage of sensor increases by 10 mV.

Find the Stepsize of ADC by following formula:

Stepsize = Vref / 212…………………………………………………….. (1)

Where, Vref is reference voltage of ADC (1.8 V = 1800 mV)

Stepsize = 0.44 mv

Digital output is:

Dout = Vin / Stepsize…………………………………………………….. (2)

Where, Vin is input voltage of ADC (Output of LM 35 sensor)

By combination formula (1) and (2),

Dout = (Vin * 4096) / 1800………………………………………………. (3)

Here, Digital output is 22.75 times more than real output because Stepsize of LM 35 is 10 mV and Stepsize of ADC is 0.44 mV that’s why we need to divide it by 22.75 to get the correct temperature in Celsius.

Factor value = 10 mV / 0.44 mV = 22.75 mV

Temperature in Celsius:

Celsius = (Dout)/22.75

Temperature in Fahrenheit:

Fahrenheit = (Celsius * 9/5) + 32

When script is being executed, it enters in a continuous loop and displays the temperature in Celsius and Fahrenheit on terminal. Press ctrl+C from stopping the execution of program form SSH command terminal.

Screenshot of Linux Console showing Temperature Reading

Fig. 2: Screenshot of Linux Console showing Temperature Reading

Description:

Let’s first prepare the circuit connection. Take a breadboard and provide VCC and ground from BBB to breadboard line. Connect Supply 3.3 V from pin number 3rd of header P9 and ground from pin number 2nd of header P8.

LM35 has three terminals:

  • Vcc
  • Output
  • Ground

Pin Diagram of LM35 Temperature Sensor

Fig. 3: Pin Diagram of LM35 Temperature Sensor

Vcc terminal is connected with 3.3 V supply, Ground is connected with ADC ground of BBB (pin number 34th of header P9). Output terminal of LM 35 is connected  to the input of AIN1 (pin number 40th of header P9).

Image of Beaglebone Black used as Temeperature Monitor

Fig. 4: Image of Beaglebone Black used as Temeperature Monitor

Open the command terminal and take an access of Beaglebone black through SSH as explained in getting started with Beaglebone black. Create a new file using touch command with .py extension (i.e. LM_35.py). Open the file with any text editor (i.e. nano, vim etc.) and write a code in python language.

Project Source Code

###


import Adafruit_BBIO.ADC as ADC
 
import time
 
Sensor = "P9_40"
 
ADC.setup(Sensor)
 
while True:
 
        Temperature = (float(ADC.read_raw(Sensor))*4096)/1800
 
        Celsius = (Temperature)/22.75
 
        Fahrenheit = (Celsius * 9/5) + 32
        print('Temp in C: %dnTemp in F: %dn'%(Celsius , Fahrenheit))
 
        time.sleep(1)
 

###

 


Circuit Diagrams

Circuit-Diagram-Beaglebone-Black-LM35-Sensor-Temperature-Monitor

Project Video


Filed Under: BeagleBone, Electronic Projects
Tagged With: beaglebone black
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.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

  • Reducing "shoot-through" in offline Full Bridge SMPS?
  • High Side current sensing
  • How to simulate power electronics converter in PSpice?
  • Voltage mode pushpull is a nonsense SMPS?
  • Layout IRN reduction in Comparator

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

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

  • Electronic Projects & 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