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.
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
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).
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 ADCimport timeSensor = "P9_40"ADC.setup(Sensor)while True:Temperature = (float(ADC.read_raw(Sensor))*4096)/1800Celsius = (Temperature)/22.75Fahrenheit = (Celsius * 9/5) + 32print('Temp in C: %dnTemp in F: %dn'%(Celsius , Fahrenheit))time.sleep(1)###
Circuit Diagrams
Project Video
Filed Under: BeagleBone, Electronic Projects
Filed Under: BeagleBone, Electronic Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.