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

linux software architecture
linux software architecture linux software architecture
linux software architecture Sneha Ramesh
 
Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt onu9
 
Install and configure linux
Install and configure linuxInstall and configure linux
Install and configure linuxVicent Selfa
 
Open source technology
Open source technologyOpen source technology
Open source technologyRohit Kumar
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device driversAlexandre Moreno
 
Accessing Hardware on Android
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on AndroidGary Bisson
 
Native, Hybrid, or Cross-platform Development? What Type of Mobile App is Bes...
Native, Hybrid, or Cross-platform Development? What Type of Mobile App is Bes...Native, Hybrid, or Cross-platform Development? What Type of Mobile App is Bes...
Native, Hybrid, or Cross-platform Development? What Type of Mobile App is Bes...ReformedTech
 
Ninja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for BeginnersNinja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for BeginnersChang W. Doh
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Ahsanul Karim
 
Automating Hybrid Applications with Appium
Automating Hybrid Applications with AppiumAutomating Hybrid Applications with Appium
Automating Hybrid Applications with AppiumSauce Labs
 

What's hot (20)

linux software architecture
linux software architecture linux software architecture
linux software architecture
 
Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt
 
Linux
Linux Linux
Linux
 
Install and configure linux
Install and configure linuxInstall and configure linux
Install and configure linux
 
Open source technology
Open source technologyOpen source technology
Open source technology
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
 
HCI
HCIHCI
HCI
 
Open Source Technology
Open Source TechnologyOpen Source Technology
Open Source Technology
 
Device Drivers
Device DriversDevice Drivers
Device Drivers
 
Accessing Hardware on Android
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on Android
 
Native, Hybrid, or Cross-platform Development? What Type of Mobile App is Bes...
Native, Hybrid, or Cross-platform Development? What Type of Mobile App is Bes...Native, Hybrid, or Cross-platform Development? What Type of Mobile App is Bes...
Native, Hybrid, or Cross-platform Development? What Type of Mobile App is Bes...
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Ninja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for BeginnersNinja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for Beginners
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)
 
Iot lab manual new
Iot lab manual newIot lab manual new
Iot lab manual new
 
Automating Hybrid Applications with Appium
Automating Hybrid Applications with AppiumAutomating Hybrid Applications with Appium
Automating Hybrid Applications with Appium
 
Os lab manual
Os lab manualOs lab manual
Os lab manual
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Windows 10
Windows 10Windows 10
Windows 10
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
 

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 (11)

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
 
Raspberry pi complete setup
Raspberry pi complete setupRaspberry pi complete setup
Raspberry pi complete setup
 
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

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 

Recently uploaded (20)

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 

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); } } }