SlideShare a Scribd company logo
1 of 34
Working with
Temperature Sensor
and Raspberry pi
-Santosh Kumar Kar
skkar.2k2@gmail.com
In this, I will cover a small raspberry project to read the room temperature using
Raspberry Pi 3 and DS18BB20 temperature sensor. This is the very basic
application for Raspberry and easy.
Just follow the instructions to build this project.
Have Fun !
What you need?
Connect the PIR Sensor
module to the Raspberry Pi
3 cables in the DS18B20 Digital Temperature
Sensor
• The black color is for ground
It will be connected to ground in raspberry
• The yellow color is the data input supply
it will be connected to GPIO4 in raspberry
• The red color is +5v signal
it will be connected to 3V3 in raspberry
4.7k resistor
• 4.7k resistor, which is required as a pullup
from the DATA to VCC line when using the
sensor.
• Connect the 4.7K resistor between the
digital input pin and +5 volts (yellow and
red)
Raspberry pi 3 & Sensor
4.7k resistor
Red jumper wire
Red jumper wire
Connected to 3v3 pin in raspberry.
Connected to 4.7k resistor pin
Connected to 3 – 5.5v red color wire in DS18B20 temperature sensor.
Yellow jumper wire
Yellow jumper wire
Connected to GPIO4 pin in raspberry.
Connected to 4.7k resistor pin
Connected to data input yellow color wire in DS18B20 temperature sensor.
Black jumper wire
Yellow jumper wire
Connected to GND (Ground) pin in raspberry.
Connected to ground black color wire in DS18B20 temperature sensor.
Set up pi configuration to read sensor
This is the important step where you need to add configuration in the
raspberry pi so it will start reading your sensor after booting raspberry.
Follow the steps:
1. Login to your pi with user id and password.
2. Connect to terminal if you are not using putty to connect raspberry
console window.
3. Type the command – sudo nano /boot/config.txt
4. Go to end of the file, add the entry as:
dtoverlay = w1-gpio
1 2
3
Reboot your raspberry pi
Use your favourite option to reboot your raspberry pi.
• You can do it through the command: sudo reboot
• Or you can click on application menu > click on Shutdown > choose
the option reboot.
Find sensor in raspberry
Now this is the time you need to check your raspberry pi. To check,
Login to raspberry, go to terminal window, use below commands to
load the correct module:
sudo modprobe w1-gpio
sudo modprobe w1-therm
Change the directory using command: cd /sys/bus/w1/devices
See the files/directories under devices directory using command ls
Now you should be able to see a directory starting with 28- for example,
28-80000003c64d for my sensor.
Folder displayed for your sensor
Directory for the sensor
File, which captures the sensor.
use cat w1_slave and see the output
You don’t see the folder for your sensor?
Don’t panic. Mostly this is due to your incorrect wiring. Make sure you
follow the instructions of wiring correctly. If still not working, just
remove all wires, transistors from the breadboard and reconnect. Then
reboot.
Also make sure you have entered the configuration as shown before in
the configuration.txt file.
Write python code to print temperature
Now we are able to detect the sensor in raspberry. This is time to write
a program in python which will keep printing the room temperature in
every second.
Just follow the steps shown in subsequent slides.
Login to raspberry, open the Python 3 editor.
Create new file
Write the program
import time
try:
while True:
tempfile = open("/sys/bus/w1/devices/28-80000003c64d/w1_slave")
thetext = tempfile.read()
tempfile.close()
tempdata = thetext.split("n")[1].split(" ")[9]
temperature = float(tempdata[2:])
temperature = temperature / 1000
print (temperature)
time.sleep(1)
except KeyboardInterrupt:
pass
Run program
Sensor capturing the temperature and
printing
Code in java
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* Created by Santosh Kumar Kar on 30-05-2017.
*/
public class ReadTemperature {
public static void main(String[] args) throws IOException,InterruptedException {
while(true){
String line_2 = Files.readAllLines(Paths.get(
"/sys/bus/w1/devices/28-80000003c64d/w1_slave")).get(1);
String temperaturedata = line_2.split(" ")[9];
String data = temperaturedata.split("=")[1];
System.out.println(Float.valueOf(data)/1000);
Thread.sleep(1000);
}
}
}
Write to
skkar.2k2@gmail.com
Temperature sensor with raspberry pi

More Related Content

What's hot

Ultimate list of 50 Best IoT platforms of 2019
Ultimate list of 50 Best  IoT platforms of 2019Ultimate list of 50 Best  IoT platforms of 2019
Ultimate list of 50 Best IoT platforms of 2019ThingsCloud
 
Interfacing the Raspberry Pi to the World
Interfacing the Raspberry Pi to the WorldInterfacing the Raspberry Pi to the World
Interfacing the Raspberry Pi to the WorldOmer Kilic
 
Smart agriculture system using IOT
Smart agriculture system using IOTSmart agriculture system using IOT
Smart agriculture system using IOTchetana chaudhary
 
Iot architecture
Iot architectureIot architecture
Iot architectureAnam Iqbal
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocksJothi Lakshmi
 
Associative memory 14208
Associative memory 14208Associative memory 14208
Associative memory 14208Ameer Mehmood
 
Datapath Design of Computer Architecture
Datapath Design of Computer ArchitectureDatapath Design of Computer Architecture
Datapath Design of Computer ArchitectureAbu Zaman
 
IoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdfIoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdfGVNSK Sravya
 
Introduction to IETF and Standardisation Process
Introduction to IETF and Standardisation ProcessIntroduction to IETF and Standardisation Process
Introduction to IETF and Standardisation ProcessVinayak Hegde
 
Introduction to Raspberrypi
Introduction to  RaspberrypiIntroduction to  Raspberrypi
Introduction to RaspberrypiIheb Ben Salem
 
IoT Tutorial for Beginners | Internet of Things (IoT) | IoT Training | IoT Te...
IoT Tutorial for Beginners | Internet of Things (IoT) | IoT Training | IoT Te...IoT Tutorial for Beginners | Internet of Things (IoT) | IoT Training | IoT Te...
IoT Tutorial for Beginners | Internet of Things (IoT) | IoT Training | IoT Te...Edureka!
 

What's hot (20)

Arduino Projects
Arduino ProjectsArduino Projects
Arduino Projects
 
Ultimate list of 50 Best IoT platforms of 2019
Ultimate list of 50 Best  IoT platforms of 2019Ultimate list of 50 Best  IoT platforms of 2019
Ultimate list of 50 Best IoT platforms of 2019
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
 
Interfacing the Raspberry Pi to the World
Interfacing the Raspberry Pi to the WorldInterfacing the Raspberry Pi to the World
Interfacing the Raspberry Pi to the World
 
Smart agriculture system using IOT
Smart agriculture system using IOTSmart agriculture system using IOT
Smart agriculture system using IOT
 
Iot architecture
Iot architectureIot architecture
Iot architecture
 
Java vs python
Java vs pythonJava vs python
Java vs python
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocks
 
IoT with Python
IoT with PythonIoT with Python
IoT with Python
 
security and privacy-Internet of things
security and privacy-Internet of thingssecurity and privacy-Internet of things
security and privacy-Internet of things
 
Associative memory 14208
Associative memory 14208Associative memory 14208
Associative memory 14208
 
Datapath Design of Computer Architecture
Datapath Design of Computer ArchitectureDatapath Design of Computer Architecture
Datapath Design of Computer Architecture
 
IoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdfIoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdf
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
 
Emulator vs Simulator
Emulator vs SimulatorEmulator vs Simulator
Emulator vs Simulator
 
IoTivity: From Devices to the Cloud
IoTivity: From Devices to the CloudIoTivity: From Devices to the Cloud
IoTivity: From Devices to the Cloud
 
Introduction to IETF and Standardisation Process
Introduction to IETF and Standardisation ProcessIntroduction to IETF and Standardisation Process
Introduction to IETF and Standardisation Process
 
Sensors in IOT
Sensors in IOTSensors in IOT
Sensors in IOT
 
Introduction to Raspberrypi
Introduction to  RaspberrypiIntroduction to  Raspberrypi
Introduction to Raspberrypi
 
IoT Tutorial for Beginners | Internet of Things (IoT) | IoT Training | IoT Te...
IoT Tutorial for Beginners | Internet of Things (IoT) | IoT Training | IoT Te...IoT Tutorial for Beginners | Internet of Things (IoT) | IoT Training | IoT Te...
IoT Tutorial for Beginners | Internet of Things (IoT) | IoT Training | IoT Te...
 

Similar to Temperature sensor with raspberry pi

Indoor Comfort Index Monitoring System using KNN algorithm
Indoor Comfort Index Monitoring System using KNN algorithmIndoor Comfort Index Monitoring System using KNN algorithm
Indoor Comfort Index Monitoring System using KNN algorithmFaisal Mehmood
 
Using raspberry pi to sense temperature and relative humidity
Using raspberry pi to sense temperature and relative humidityUsing raspberry pi to sense temperature and relative humidity
Using raspberry pi to sense temperature and relative humidityIRJET Journal
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218CAVEDU Education
 
Raspberry Pi Using Python
Raspberry Pi Using PythonRaspberry Pi Using Python
Raspberry Pi Using PythonSeggy Segaran
 
Fire Detection Using MATLAB
Fire Detection Using MATLABFire Detection Using MATLAB
Fire Detection Using MATLABAmey Mithsagar
 
manual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfmanual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfssuserc5ee4c
 
Kpsi User Guide Model 500
Kpsi User Guide Model 500Kpsi User Guide Model 500
Kpsi User Guide Model 500TAMUK
 
Itsp documentation quadcopter flight controller based on kalman filters
Itsp documentation   quadcopter flight controller based on kalman filtersItsp documentation   quadcopter flight controller based on kalman filters
Itsp documentation quadcopter flight controller based on kalman filtersJyotirmaya Mahanta
 
Raspberry pi Part 19
Raspberry pi Part 19Raspberry pi Part 19
Raspberry pi Part 19Techvilla
 
Cpu224 xp eth-ethernet_interface
Cpu224 xp eth-ethernet_interfaceCpu224 xp eth-ethernet_interface
Cpu224 xp eth-ethernet_interfacearco zhang
 
Linux Format - Get Into Linux Today
Linux Format - Get Into Linux TodayLinux Format - Get Into Linux Today
Linux Format - Get Into Linux TodayHeart Disk
 
Cse318,lab report on basis
Cse318,lab report on basisCse318,lab report on basis
Cse318,lab report on basisFarhadHimel
 
Raspberry Pi Introductory Lecture
Raspberry Pi Introductory LectureRaspberry Pi Introductory Lecture
Raspberry Pi Introductory LectureSyed Umaid Ahmed
 
Esp8266 wi fi_module_quick_start_guide_v_1.0.4
Esp8266 wi fi_module_quick_start_guide_v_1.0.4Esp8266 wi fi_module_quick_start_guide_v_1.0.4
Esp8266 wi fi_module_quick_start_guide_v_1.0.4Melvin Gutiérrez Rivero
 

Similar to Temperature sensor with raspberry pi (20)

Indoor Comfort Index Monitoring System using KNN algorithm
Indoor Comfort Index Monitoring System using KNN algorithmIndoor Comfort Index Monitoring System using KNN algorithm
Indoor Comfort Index Monitoring System using KNN algorithm
 
Raspberry pi led blink
Raspberry pi led blinkRaspberry pi led blink
Raspberry pi led blink
 
Using raspberry pi to sense temperature and relative humidity
Using raspberry pi to sense temperature and relative humidityUsing raspberry pi to sense temperature and relative humidity
Using raspberry pi to sense temperature and relative humidity
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218
 
Raspberry Pi Using Python
Raspberry Pi Using PythonRaspberry Pi Using Python
Raspberry Pi Using Python
 
Fire Detection Using MATLAB
Fire Detection Using MATLABFire Detection Using MATLAB
Fire Detection Using MATLAB
 
Fun with arduino
Fun with arduinoFun with arduino
Fun with arduino
 
Arduino: Arduino starter kit
Arduino: Arduino starter kitArduino: Arduino starter kit
Arduino: Arduino starter kit
 
manual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfmanual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdf
 
Kpsi User Guide Model 500
Kpsi User Guide Model 500Kpsi User Guide Model 500
Kpsi User Guide Model 500
 
Itsp documentation quadcopter flight controller based on kalman filters
Itsp documentation   quadcopter flight controller based on kalman filtersItsp documentation   quadcopter flight controller based on kalman filters
Itsp documentation quadcopter flight controller based on kalman filters
 
Raspberry pi Part 19
Raspberry pi Part 19Raspberry pi Part 19
Raspberry pi Part 19
 
Cpu224 xp eth-ethernet_interface
Cpu224 xp eth-ethernet_interfaceCpu224 xp eth-ethernet_interface
Cpu224 xp eth-ethernet_interface
 
Linux Format - Get Into Linux Today
Linux Format - Get Into Linux TodayLinux Format - Get Into Linux Today
Linux Format - Get Into Linux Today
 
Cse318,lab report on basis
Cse318,lab report on basisCse318,lab report on basis
Cse318,lab report on basis
 
Raspberry Pi Introductory Lecture
Raspberry Pi Introductory LectureRaspberry Pi Introductory Lecture
Raspberry Pi Introductory Lecture
 
2013 arduino pid lab 0
2013 arduino pid lab 02013 arduino pid lab 0
2013 arduino pid lab 0
 
Esp8266 wi fi_module_quick_start_guide_v_1.0.4
Esp8266 wi fi_module_quick_start_guide_v_1.0.4Esp8266 wi fi_module_quick_start_guide_v_1.0.4
Esp8266 wi fi_module_quick_start_guide_v_1.0.4
 
publish manual
publish manualpublish manual
publish manual
 
SMTAS04USB mini – Evaluation board for SMT172
SMTAS04USB mini – Evaluation board for SMT172SMTAS04USB mini – Evaluation board for SMT172
SMTAS04USB mini – Evaluation board for SMT172
 

More from Santosh Kumar Kar

Operating electrical devices with PIR sensor. No coding, No controller
Operating electrical devices with PIR sensor. No coding, No controllerOperating electrical devices with PIR sensor. No coding, No controller
Operating electrical devices with PIR sensor. No coding, No controllerSantosh Kumar Kar
 
Pir motion sensor with raspberry pi
Pir motion sensor with raspberry piPir motion sensor with raspberry pi
Pir motion sensor with raspberry piSantosh Kumar Kar
 
Writing simple web services in java using eclipse editor
Writing simple web services in java using eclipse editorWriting simple web services in java using eclipse editor
Writing simple web services in java using eclipse editorSantosh Kumar Kar
 

More from Santosh Kumar Kar (10)

Smart home arduino
Smart home   arduinoSmart home   arduino
Smart home arduino
 
Operating electrical devices with PIR sensor. No coding, No controller
Operating electrical devices with PIR sensor. No coding, No controllerOperating electrical devices with PIR sensor. No coding, No controller
Operating electrical devices with PIR sensor. No coding, No controller
 
Pir motion sensor with raspberry pi
Pir motion sensor with raspberry piPir motion sensor with raspberry pi
Pir motion sensor with raspberry pi
 
Angular js for Beginnners
Angular js for BeginnnersAngular js for Beginnners
Angular js for Beginnners
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Spring transaction part4
Spring transaction   part4Spring transaction   part4
Spring transaction part4
 
Spring & hibernate
Spring & hibernateSpring & hibernate
Spring & hibernate
 
Spring database - part2
Spring database -  part2Spring database -  part2
Spring database - part2
 
Springs
SpringsSprings
Springs
 
Writing simple web services in java using eclipse editor
Writing simple web services in java using eclipse editorWriting simple web services in java using eclipse editor
Writing simple web services in java using eclipse editor
 

Recently uploaded

Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 

Recently uploaded (20)

Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 

Temperature sensor with raspberry pi

  • 1. Working with Temperature Sensor and Raspberry pi -Santosh Kumar Kar skkar.2k2@gmail.com
  • 2. In this, I will cover a small raspberry project to read the room temperature using Raspberry Pi 3 and DS18BB20 temperature sensor. This is the very basic application for Raspberry and easy. Just follow the instructions to build this project. Have Fun !
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. Connect the PIR Sensor module to the Raspberry Pi
  • 12. 3 cables in the DS18B20 Digital Temperature Sensor • The black color is for ground It will be connected to ground in raspberry • The yellow color is the data input supply it will be connected to GPIO4 in raspberry • The red color is +5v signal it will be connected to 3V3 in raspberry
  • 13. 4.7k resistor • 4.7k resistor, which is required as a pullup from the DATA to VCC line when using the sensor. • Connect the 4.7K resistor between the digital input pin and +5 volts (yellow and red)
  • 14. Raspberry pi 3 & Sensor 4.7k resistor
  • 15. Red jumper wire Red jumper wire Connected to 3v3 pin in raspberry. Connected to 4.7k resistor pin Connected to 3 – 5.5v red color wire in DS18B20 temperature sensor.
  • 16. Yellow jumper wire Yellow jumper wire Connected to GPIO4 pin in raspberry. Connected to 4.7k resistor pin Connected to data input yellow color wire in DS18B20 temperature sensor.
  • 17. Black jumper wire Yellow jumper wire Connected to GND (Ground) pin in raspberry. Connected to ground black color wire in DS18B20 temperature sensor.
  • 18.
  • 19.
  • 20. Set up pi configuration to read sensor This is the important step where you need to add configuration in the raspberry pi so it will start reading your sensor after booting raspberry. Follow the steps: 1. Login to your pi with user id and password. 2. Connect to terminal if you are not using putty to connect raspberry console window. 3. Type the command – sudo nano /boot/config.txt 4. Go to end of the file, add the entry as: dtoverlay = w1-gpio
  • 21. 1 2 3
  • 22. Reboot your raspberry pi Use your favourite option to reboot your raspberry pi. • You can do it through the command: sudo reboot • Or you can click on application menu > click on Shutdown > choose the option reboot.
  • 23. Find sensor in raspberry Now this is the time you need to check your raspberry pi. To check, Login to raspberry, go to terminal window, use below commands to load the correct module: sudo modprobe w1-gpio sudo modprobe w1-therm Change the directory using command: cd /sys/bus/w1/devices See the files/directories under devices directory using command ls Now you should be able to see a directory starting with 28- for example, 28-80000003c64d for my sensor.
  • 24. Folder displayed for your sensor Directory for the sensor File, which captures the sensor. use cat w1_slave and see the output
  • 25. You don’t see the folder for your sensor? Don’t panic. Mostly this is due to your incorrect wiring. Make sure you follow the instructions of wiring correctly. If still not working, just remove all wires, transistors from the breadboard and reconnect. Then reboot. Also make sure you have entered the configuration as shown before in the configuration.txt file.
  • 26. Write python code to print temperature Now we are able to detect the sensor in raspberry. This is time to write a program in python which will keep printing the room temperature in every second. Just follow the steps shown in subsequent slides.
  • 27. Login to raspberry, open the Python 3 editor.
  • 29. Write the program import time try: while True: tempfile = open("/sys/bus/w1/devices/28-80000003c64d/w1_slave") thetext = tempfile.read() tempfile.close() tempdata = thetext.split("n")[1].split(" ")[9] temperature = float(tempdata[2:]) temperature = temperature / 1000 print (temperature) time.sleep(1) except KeyboardInterrupt: pass
  • 31. Sensor capturing the temperature and printing
  • 32. Code in java import java.io.FileInputStream; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; /** * Created by Santosh Kumar Kar on 30-05-2017. */ public class ReadTemperature { public static void main(String[] args) throws IOException,InterruptedException { while(true){ String line_2 = Files.readAllLines(Paths.get( "/sys/bus/w1/devices/28-80000003c64d/w1_slave")).get(1); String temperaturedata = line_2.split(" ")[9]; String data = temperaturedata.split("=")[1]; System.out.println(Float.valueOf(data)/1000); Thread.sleep(1000); } } }