Nothing Special   »   [go: up one dir, main page]

A Skill-Oriented Course-1 Report Submitted in Partial Fulfillment of The Requirements For The Award of The Degree of

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

RASPBERRY PI WEATHER STATION

A skill-oriented course-1 report submitted in partial fulfillment of the


requirements for the award of the degree of
BACHELOR OF TECHNOLOGY

in

COMPUTER SCIENCE AND ENGINEERING

(Internet of Things)
Submitted by

M.DURGA NAGARJUNA REDDY 22BQ1A4932

[Program: Computer Science and Engineering (Internet of Things) – CSO]

VASIREDDY VENKATADRI INSTITUTE OF TECHNOLOGY

(Autonomous)

Approved by AICTE, Permanently Affiliated to JNTUK, NAAC


Accredited with ‘A’ Grade, ISO 9001:2015 Certified
Nambur (V), Pedakakani (M), Guntur (Dt.), Andhra Pradesh – 522 508

2024

Department of Computer Science & Technology(IOT) Page i


[Program: Computer Science and Engineering (Internet of Things) – CSO]

VASIREDDY VENKATADRI INSTITUTE OF TECHNOLOGY

(Autonomous)

Approved by AICTE, Permanently Affiliated to JNTUK, NAAC Accredited with ‘A’


Grade, ISO 9001:2015 Certified

Nambur (V), Pedakakani (M), Guntur (Dt.), Andhra Pradesh – 522 508

CERTIFICATE
This is to certify that the research project report entitled “RASPBERRY PI
WEATHER STATION” is being submitted by M.DURGA NAGARJUNA REDDY
(Regd.No: 22BQ1A4932 in partial fulfillment of the requirement for the award of the degree
of the Bachelor of Technology in Computer Science and Engineering (Internet of
Things) to the Vasireddy Venkatadri Institute of Technology is a record of bonafide work
carried out by him/her under our supervision.

The results embodied in this project have not been submitted to any other university
or institute for the award of any degree or diploma.

Signature of the Guide Signature of the Coordinator Head of the Department


Dr. Chintalapudi V Suresh Mr. S. Saida Rao Dr. Chintalapudi V Suresh
Professor & HoD, Assistant Professor, Professor & HoD,
Department of CSO, VVIT. Department of CSO, VVIT. Department of CSO, VVIT.

Department of Computer Science & Technology(IOT) Page ii


DECLARATION

I hereby declare that the work embodied in this research project entitled
“RASPBERRY PI WEATHER STATION”, which is being submitted by me in
requirement for the B. Tech Degree in Computer Science and Engineering (Internet of
Things) from Vasireddy Venkatadri Institute of Technology, is the result of investigations
carried out by me.
The work is original and the results in this thesis have not been submitted elsewhere
for the award of any degree or diploma.

Signature of the Candidates

M.DURGA NAGARJUNA REDDY

(Regd.No: 22BQ1A4932)

Department of Computer Science & Technology(IOT) Page iii


Department Vision

To accomplish the aspirations of emerging engineers to attain global intelligence by


obtaining computing and design abilities through communication that elevate them to meet
the needs of industry, economy, society, environmental and global.
Department Mission

➢ To mould the fresh minds into highly competent IoT application developers by
enhancing their knowledge and skills in diverse hardware and software design aspects
for covering technologies and multi-disciplinary engineering practices.
➢ To provide the sate- of- the art facilities to forge the students in industry-ready in IoT
system development.
➢ To nurture the sense of creativity and innovation to adopt the socio-economic related
activities.
➢ To promote collaboration with the institutes of national and international repute with a
view to have best careers.
➢ To enable graduates to emerge as independent entrepreneurs and future leaders.

Program Educational Objectives (PEOs)

PEO-1: To formulate the engineering practitioners to solve industry’s technological problems


PEO-2: To engage the engineering professionals in technology development, deployment
and engineering system implementation
PEO-3: To instil professional ethics, values, social awareness and responsibility to emerging
technology leaders
PEO-4: To facilitate interaction between students and peers in other disciplines of industry and
society that contribute to the economic growth.
PEO-5: To provide the technocrats the amicable environment for the successful pursuing
of engineering and management.
PEO-6: To create right path to pursue their careers in teaching, research and
innovation.

Department of Computer Science & Technology(IOT) Page iv


Program Outcomes (POs)

PO1: Engineering knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex engineering
problems.
PO2: Problem analysis: Identify, formulate, review research literature, and analyze
complex engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
PO3: Design/development of solutions: Design solutions for complex engineering
problems and design system components or processes that meet the specified needs with
appropriate consideration for the public health and safety, and the cultural, societal, and
environmental considerations.
PO4: Conduct investigations of complex problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data, and
synthesis of the information to provide valid conclusions.
PO5: Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex engineering
activities with an understanding of the limitations.
PO6: The engineer and society: Apply reasoning informed by the contextual knowledge
to assess societal, health, safety, legal and cultural issues and the consequent responsibilities
relevant to the professional engineering practice.
PO7: Environment and sustainability: Understand the impact of the professional
engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.
PO8: Ethics: Apply ethical principles and commit to professional ethics and responsibilities
and norms of the engineering practice.
PO9: Individual and team work: Function effectively as an individual, and as a member
or leader in diverse teams, and in multidisciplinary settings.
PO10: Communication: Communicate effectively on complex engineering activities with
the engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give
and receive clear instructions.

Department of Computer Science & Technology(IOT) Page v


PO11: Project management and finance: Demonstrate knowledge and understanding of
the engineering and management principles and apply these to one’s own work, as a member
and leader in a team, to manage projects and in multidisciplinary environments.
PO12: Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological change.
Program Specific Outcomes (PSOs)

PSO-1: Proficient and innovative with a strong cognizance in the arenas of sensors, IoT,
data science, controllers and signal processing through the application of acquired
knowledge and skills.
PSO-2: Apply cutting-edge techniques and tools of sensing and computation to solve multi-
disciplinary challenges in industry and society.
PSO-3: Exhibit independent and collaborative research with strategic planning while
demonstrating professional and ethical responsibilities of the engineering profession.

Department of Computer Science & Technology(IOT) Page vi


RASPBERRY PI WEATHER STATION

CONTENTS
Page No
LIST OF TABLES viii
LIST OF FIGURES viii
CHAPTER-1 INTRODUCTION 01
1.1 OVERVIEW 01
1.2 LITERATURE REVIEW 01
1.3 OBJECTIVES 02
1.4 APPLICATIONS 02
CHAPTER-2 PROJECT DESCRIPTION 04
INTRODUCTION ABOUT DHT-11,BM - 180
2.1 04
SENSORS
2.2 SPECIFICATIONS IN DHT-11 SENSOR 04
2.3 SPECIFICATIONS IN BM-180 SENSOR 05
2.4 COMPONENTS USED 05
2.5 CIRCUIT DIAGRAM 08
2.6 CONNECTIONS 09
2.7 WORKING AND THINGSPEAK SETUP 09
CHAPTER-3 RASPBERRY PI PROGRAMMING 11

INSTALLING LIBRARY FUNCTIONS


3.1 FOR DHT-11,BM-180 SENSORS 11

PYTHON PROGRAM FOR RASPBERRY PI


3.2 WEATHER STATION 12

CHAPTER-4 RESULT AND DEMONSTRATION 20


4.1 OUTPUT 20
4.2 COMPARITIVE ANALYSIS 21
4.3 SUMMARY OF THE PRJECT 21
REFERENCES 22

Department of Computer Science & Technology(IOT) Page vii


RASPBERRY PI WEATHER STATION

LIST OF TABLES
Table.No Description Page No
1.1 COMPONENTS REQUIRED 03

LIST OF FIGURES
Fig. No Description Page No
2.4.1 DHT-11 SENSOR 05
2.4.2 BM-180 SENSOR 06
2.4.3 RASPBERRY PI MODEL 4B 06
2.4.4 JUMPER WIRES 07
2.4.5 LDR MODULE 07
2.4.6 LCD 08
2.5.1 CIRCUIT DIAGRAM 08
2.7.1 WORKING AND THINGSPEAK 10
4.1.1 MONITORING OVER THINGSPEAK 20
4.1.2 RESULTANT OUTPUT 20

Department of Computer Science & Technology(IOT) Page viii


RASPBERRY PI WEATHER STATION

CHAPTER-1

INTRODUCTION

1.1 OVERVIEW

Humidity, Temperature and Pressure are three basic parameters to build any Weather
Station and to measure environmental conditions. This IOT Project aims to show
the current Humidity, Temperature and Pressure parameters on the LCD as well on
the Internet server using Raspberry Pi, which makes it a Raspberry Pi Weather
Station. You can install this setup anywhere and can monitor the weather conditions of
that place from anywhere in the world over the internet, it will not only show the current
data but can also show the past values in the form of Graphs.
We have used DHT11 Humidity & temperature sensor for sensing the temperature
and BM180 Pressure sensor module for measuring barometric pressure. This Celsius scale
Thermometer and percentage scale Humidity meter displays the ambient temperature and
humidity through a LCD display and barometric pressure is displayed in millibar or hPa
(hectopascal). All this data is sent to THINGSPEAK server for live monitoring from
anywhere in the world over internet.
This IoT based project has four sections. Firstly DHT11 sensor senses the Humidity &
Temperature Data and BM180 sensor measures the atmospheric pressure. Secondly
Raspberry Pi reads the DHT11 sensor module’s output by using single wire protocol and
BM180 pressure sensor’s output by using I2C protocol and extracts both sensors values into
a suitable number in percentage (humidity), Celsius scale (temperature), hectoPascal or
millibar (pressure). Thirdly, these values are sent to ThingSpeak server by using inbuilt Wi-
Fi of Raspberry Pi 3. And finally Thingspeak analyses the data and shows it in a Graph
form. A LCD is also used to display these values locally.

1.2 LITERATURE REVIEW

A literature review of Raspberry Pi weather stations using DHT11 and BMP180 sensors
reveals that this combination offers an accessible and affordable approach to monitoring
local weather conditions. The DHT11 sensor is widely used for measuring temperature and
humidity due to its simplicity and low cost, while the BMP180 sensor provides precise
measurements of atmospheric pressure and temperature. Literature highlights the ease of
1
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

integrating these sensors with the Raspberry Pi using libraries like Adafruit_DHT
andAdafruit_BMP, enabling data collection and processing in Python. Despite challenges
such as moderate accuracy and calibration issues, as well as the need for protective housing,
these projects serve as practical, foundational tools for personal weather monitoring,
educational purposes, and small-scale research. Future work may focus on enhancing data
accuracy and leveraging advanced analytics techniques for deeper insights.

1.3 OBJECTIVES

Accurate Measurement: Achieve accurate and reliable measurement of key weather


parameters, including temperature, humidity, and atmospheric pressure, using the
DHT11 and BMP180 sensors.
Data Collection and Storage: Collect data from the sensors at regular intervals and
store the data efficiently, either locally on the Raspberry Pi or remotely on a cloud
platform.
Data Visualization: Develop a user-friendly interface or dashboard to visualize the
collected weather data for easy interpretation and analysis.
Analysis and Insights: Analyze the collected data to identify trends, patterns, and any
correlations between different weather parameters.
Integration with Other Systems: Explore potential integrations with other systems or
applications, such as home automation, to enhance the utility and impact of the weather
station.
Energy Efficiency: Optimize the energy usage of the Raspberry Pi and sensors to
ensure the weather station operates efficiently over time.

1.4 APPLICATIONS

Personal Weather Monitoring: Individuals can use a Raspberry Pi weather station to


monitor local weather conditions at home, providing insights into temperature,
humidity, and barometric pressure trends in their immediate environment.
Educational Projects: The project is an excellent educational tool for students and
hobbyists learning about electronics, programming, and weather monitoring. It
provides hands-on experience with sensor integration and data analysis.
Agricultural Monitoring: Farmers can use a Raspberry Pi weather station to track
2
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

local weather conditions, helping them make informed decisions about irrigation,
planting, and harvesting.

Home Automation: A Raspberry Pi weather station can be integrated with a smart


home system to adjust heating, ventilation, and air conditioning (HVAC) systems
based on real-time weather data.
Environmental Research: Researchers can use the weather station to collect data for
environmental studies, monitoring trends in local weather patterns and their potential
impact on ecosystems.

The components required for developing this system are tabulated in Table.1.1

Table.1.1 Components required

S. Name of the component Specifications Number of


NO Units
required
1. RASPBERRY PI Model 4B 1
2. DHT-11 SENSOR Good for 0-50 °C 1
temperature readings
+-2 °C accuracy
3. BM-180 SENSOR Pressure range: 300 to 1
1100hPa
4. LCD 16x2 length 1

5. LDR MODULE LM393 based design 1

6. JUMPER WIRES Diameter:0.6mm, As required


Tolerance:0.001mm

3
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

CHAPTER – 2

PROJECT DESCRIPTION

2.1 INTRODUCTION ABOUT DHT-11,BM-180 SENSORS:

The DHT11 and BMP180 sensors are essential components in weather station projects
due to their ability to measure key weather parameters. The DHT11 sensor is a low-
cost, digital sensor that measures both temperature and humidity, providing data in a
digital format for easy integration with the Raspberry Pi. Although it offers moderate
accuracy and slower response times compared to more advanced sensors, its simplicity
and affordability make it a popular choice for hobbyist projects and educational
purposes. The BMP180 sensor, on the other hand, is known for its precision in
measuring atmospheric pressure and temperature. It uses the I2C protocol for
communication, making it straightforward to connect to the Raspberry Pi. The
BMP180's high accuracy, small size, and low power consumption make it suitable for
a range of applications, including altimeters and wearables. Both sensors enable
effective weather monitoring and data analysis when combined with the Raspberry Pi.

2.2 SPECIFICATIONS IN DHT-11 SENSOR:

Temperature Measurement:

Range: 0°C to 50°C (32°F to 122°F)

Accuracy: ±2°C
Resolution: 1°C
Humidity Measurement:
Range: 20% to 90% relative humidity (RH)

Accuracy: ±5% RH

Resolution: 1% RH

Output Data:

Type: Digital

Communication: One-Wire Protocol

Sampling Rate: Approximately 1 Hz (once per second)


4
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

Power Supply:

Voltage: 3.3V to 5V

Current Consumption: Approx. 2.5 mA during data acquisition and up to 1 mA when


idle

2.3 SPECIFICATIONS IN BM-180 SENSOR PRESSURE MEASUREMENT:

Range: 300 to 1100 hPa (hectopascals)

Accuracy: ±0.12 hPa (typical) at sea level and room temperature

Resolution: Up to 0.03 hPa, depending on the mode

Operating Modes:

The BMP180 has multiple operating modes, providing different trade-offs between power
consumption, speed, and accuracy:
Ultra-Low Power Mode: Lowest power consumption with less accuracy and speed

Standard Mode: Balanced power consumption and performance

High Resolution Mode: Higher resolution with moderate power consumption

Ultra-High Resolution Mode: Highest accuracy and resolution at the cost of more power
consumption and slower spee
2.4 COMPONENTS USED:

The DHT11 sensor is a digital sensor widely used for measuring temperature and humidity
in weather monitoring projects. It offers a cost-effective and straightforward solution,
making it a popular choice among hobbyists and educators.

Fig.2.4.1: DHT-11 SENSOR

5
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

BM-180 SENSOR:

The BM 180180 sensor is a high-precision barometric pressure and temperature sensor


widely used in weather monitoring projects due to its reliability and versatility.

Fig 2.4.2 BM-180 SENSOR

RASPBERRY PI :

The Raspberry Pi 4 is a versatile and powerful single-board computer that serves as a


foundational platform for various projects, including weather stations, home automation,
and educational tools. It features a quad-core ARM Cortex- A72 processor running at 1.5
GHz, providing significant performance improvements over previous Raspberry Pimodels.
The Raspberry Pi 4 offers multiple options for RAM, with variants available in 2GB, 4GB,
and 8GB capacities, allowing users to select the model that best requirements. In terms of
connectivity, the Raspberry Pi 4 includes dual micro HDMI ports that support 4K video
output, USB 3.0 ports for fast data transfer, and a Gigabit Ethernet port for high-speed
network connectivity. Additionally, it offers built-in wireless connectivity with dual-band
Wi-Fi and Bluetooth 5.0.

Fig 2.4.3 RASPBERRY PI MODEL 4B


6
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

JUMPER WIRES:-

A jump wire (also known as jumper, jumper wire, DuPont wire) is an electrical
wire, or group of them in a cable, with a connector or pin at each end (or sometimes
without themsimply "tinned"), which is normally used to interconnect the components
of a breadboardor other prototype or test circuit, internally or with other equipment or
components, without soldering.[1] Individual jump wires are fitted by inserting their
"end connectors" into theslots provided in a breadboard, the header connector of a
circuit board, or a piece of test equipment.

FIG 2.4.4 :JUMPER WIRES

LDR:

LDR (Light Dependent Resistor) as the name states is a special type of resistor
that works on the photoconductivity principle means that resistance changes according to
the intensity of light. Its resistance decreases with an increase in the intensity of light.

It is often used as a light sensor, light meter, Automatic street light, and in areas
where we need to have light sensitivity. LDR is also known as a Light Sensor. LDR are
usually available in 5mm, 8mm, 12mm, and 25mm dimensions.

Fig 2.4.5 LDR Module

7
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

LCD:-

Liquid Crystal Displays (LCDs) are a popular type of display technology that uses liquid
crystal materials to produce images or text.They are widely used in various applications,
including digital clocks, televisions, computer monitors, smartphones, and other electronic
devices.

FIG 2.4.6 LCD

2.5 CIRCUIT DIAGRAM:

FIG 2.5.1 CIRCUIT DIAGRAM

8
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

2.6 CONNECTIONS:

For a Raspberry Pi weather station project using a DHT11 sensor, a BMP180 sensor, an
LCD display, and a 10k potentiometer, follow these brief connection points:
DHT11 Sensor:

Connect the VCC pin to a 3.3V or 5V pin on the Raspberry Pi.

Connect the data out pin to a GPIO pin on the Raspberry Pi (e.g., GPIO4).
Connect the GND pin to a GND pin on the Raspberry Pi.
BMP180 Sensor:

Connect the VCC pin to a 3.3V pin on the Raspberry Pi.

Connect the SDA pin to the SDA (GPIO2) pin on the Raspberry Pi. Connect
the SCL pin to the SCL (GPIO3) pin on the Raspberry Pi. Connect the GND
pin to a GND pin on the Raspberry Pi.
LCD Display:

Connect the VCC pin to a 5V pin on the Raspberry Pi. Connect


the GND pin to a GND pin on the Raspberry Pi.
Connect the RS, E, D4, D5, D6, and D7 pins to available GPIO pins on the Raspberry Pi.

10k Potentiometer:

Connect the wiper (middle pin) to the contrast control pin on the LCD.

Connect one outer pin to 5V and the other outer pin to GND for voltage control.

2.7 WORKING AND THINGSPEAK SETUP:

This IoT based project has four sections. Firstly DHT11 sensor senses the Humidity &
Temperature Data and BM180 sensor measures the atmospheric pressure. Secondly
Raspberry Pi reads the DHT11 sensor module’s output by using single wire protocol and
BM180 pressure sensor’s output by using I2C protocol and extracts both sensors values into
a suitable number in percentage (humidity), Celsius scale (temperature), hectoPascal or
millibar (pressure). Thirdly, these values are sent to ThingSpeak server by using inbuilt Wi-
Fi of Raspberry Pi 3. And finally ThingSpeak analyses the data and shows it in a Graph
form. A LCD is also used to display these values locally.

9
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

FIG 2.7.1 WORKING AND THINGSPEAK

10
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

CHAPTER-3

RASPBERRY PI PROGRAMMING

3.1 INSTALLING LIBRAIRY FUNCTIONS FOR DHT-11,BM-180 SENSORS:-

To work with the DHT11 and BMP180 sensors in a Raspberry Pi weather station project,
you need to install specific Python libraries to interface with the sensors. Here are the
libraries you should install:

For DHT11 Sensor:


Adafruit_DHT: This library allows you to interact with the DHT11 sensor and read data
such as temperature and humidity.

To install the library, run the following command in your terminal:


pip3 install Adafruit_DHT
For BM180 Sensor:
Adafruit_BMP: This library allows you to interact with the BMP180 sensor and read data such
as temperature and barometric pressure.

To install the library, run the following command in your terminal:


pip3 install adafruit-circuitpython-bmp280
STEPS TO INSTALL LIBRARIES:-
Step 1: Update Your Raspberry Pi
First, make sure your Raspberry Pi's package repository is up to date. Open a terminal and
run the following commands.
sudo apt update sudo apt upgrade
Step 2: Install Python Package Manager (if necessary)
Ensure you have pip3, the Python 3 package manager, installed. If not, you can install it
with:
sudo apt install python3-pip

Step 3: Install the Library for DHT11 Sensor


The Adafruit_DHT library allows you to interact with the DHT11 sensor. Install it using
the following command.
pip3 install Adafruit_DHT

11
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

Step 4: Install the Library for BMP180 Sensor


The library adafruit-circuitpython-bmp280 works for both BMP180 and BMP280 sensors.
Install it using the following command.
pip3 install adafruit-circuitpython-bmp280
Step 5: Verify the Installation
After installing the libraries, you can verify the installation and access them in Python scripts.
Open a Python interpreter by typing python3 in your terminal and try importing the libraries.

import Adafruit_DHT
import adafruit_bmp280

3.2 PYTHON PROGRAM FOR RASPBERRY PI WEATHER STATION:-

import sys

Import RPi.GPIO as GPIO

import os

import Adafruit_DHT

import urllib2

import smbus

import time

from ctypes import c_short

#Register Address

regCall = 0xAA

regMean = 0xF4

regMSB = 0xF6

regLSB = 0xF7

regPres = 0x34

DEBUG = 1
12
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

sample = 2

deviceAdd =0x77

humi=""

temp=""

#bus = smbus.SMBus(0) #for Pi1 uses 0

I2cbus = smbus.SMBus(1) # for Pi2 uses 1

DHTpin = 17

key="30BCDSRQ52AOI3UA" # Enter your Write API key from ThingSpeak

GPIO.setmode(GPIO.BCM)

# Define GPIO to LCD mapping

LCD_RS = 18

LCD_EN = 23

LCD_D4 = 24

LCD_D5 = 16

LCD_D6 = 20

LCD_D7 = 21

GPIO.setwarnings(False)

GPIO.setmode(GPIO.BCM)

GPIO.setup(LCD_E, GPIO.OUT)

GPIO.setup(LCD_RS, GPIO.OUT)

GPIO.setup(LCD_D4, GPIO.OUT)

GPIO.setup(LCD_D5, GPIO.OUT)

GPIO.setup(LCD_D6, GPIO.OUT)

GPIO.setup(LCD_D7, GPIO.OUT)

def convert1(data, i): # signed 16-bit value

return c_short((data[i]<< 8) + data[i + 1]).value

13
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

def convert2(data, i): # unsigned 16-bit value

return (data[i]<< 8) + data[i+1]

def readBmp180(addr=deviceAdd):

value = bus.read_i2c_block_data(addr, regCall, 22) # Read calibration data

# Convert byte data to word values

AC1 = convert1(value, 0)

AC2 = convert1(value, 2)

AC3 = convert1(value, 4)

AC4 = convert2(value, 6)

AC5 = convert2(value, 8)

AC6 = convert2(value, 10

B1 = convert1(value, 12)

B2 = convert1(value, 14)

MB = convert1(value, 16)

MC = convert1(value, 18)

MD = convert1(value, 20)

# Read temperature bus.write_byte_data(addr, regMean, regTemp) time.sleep(0.005)

(msb, lsb) = bus.read_i2c_block_data(addr, regMSB, 2)

P2 = (msb << 8) + lsb

# Read pressure

bus.write_byte_data(addr, regMean, regPres + (sample << 6)) time.sleep(0.05)

(msb, lsb, xsb) = bus.read_i2c_block_data(addr, regMSB, 3) P1 = ((msb << 16) + (lsb << 8) +
xsb) >> (8 - sample)

# Refine temperature

X1 = ((P2 - AC6) * AC5) >> 15 X2 = (MC << 11) / (X1 + MD)

B5 = X1 + X2

14
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

temperature = (B5 + 8) >> 4

# Refine pressure B6 = B5 - 4000

B62 = B6 * B6 >> 12

X1 = (B2 * B62) >> 11

X2 = AC2 * B6 >> 11

X3 = X1 + X2

B3 = (((AC1 * 4 + X3) << sample) + 2) >> 2

X1 = AC3 * B6 >> 13

X2 = (B1 * B62) >> 16

X3 = ((X1 + X2) + 2) >> 2

B4 = (AC4 * (X3 + 32768)) >> 15

B7 = (P1 - B3) * (50000 >> sample)

P = (B7 * 2) / B4

X1 = (P >> 8) * (P >> 8)

X1 = (X1 * 3038) >> 16

X2 = (-7357 * P) >> 16

pressure = P + ((X1 + X2 + 3791) >> 4)

return (str(pressure/100.0))

def readDHT():

humi, temp = Adafruit_DHT.read_retry(Adafruit_DHT.DHT11, DHTpin)

return (str(int(humi)), str(int(temp)))

def lcd_init():

lcdcmd(0x33)

lcdcmd(0x32)

lcdcmd(0x06)

lcdcmd(0x0C)

15
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

lcdcmd(0x28)

lcdcmd(0x01)

time.sleep(0.0005)

def lcdcmd(ch):

GPIO.output(RS, 0)

GPIO.output(D4, 0)

GPIO.output(D5, 0)

GPIO.output(D6, 0)

GPIO.output(D7, 0)

if ch&0x10==0x10:

GPIO.output(D4, 1)

if ch&0x20==0x20:

GPIO.output(D5, 1)

if ch&0x40==0x40:

GPIO.output(D6, 1)

if ch&0x80==0x80:

GPIO.output(D7, 1)

GPIO.output(EN, 1)

time.sleep(0.0005)

GPIO.output(EN, 0)

# Low bits

GPIO.output(D4, 0)

GPIO.output(D5, 0)

GPIO.output(D6, 0)

GPIO.output(D7, 0)

if ch&0x01==0x01:

16
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

GPIO.output(LCD_D4, 1)

if ch&0x02==0x02:

GPIO.output(LCD_D5, 1)

if ch&0x04==0x04:

GPIO.output(LCD_D6, 1)

if ch&0x08==0x08:

GPIO.output(LCD_D7, 1)

GPIO.output(EN, 1)

time.sleep(0.0005)

GPIO.output(EN, 0)

def lcddata(ch):

GPIO.output(RS, 1)

GPIO.output(D4, 0)

GPIO.output(D5, 0)

GPIO.output(D6, 0)

GPIO.output(D7, 0)

if ch&0x10==0x10:

GPIO.output(D4, 1)

if ch&0x20==0x20:

GPIO.output(D5, 1)

if ch&0x40==0x40:

GPIO.output(D6, 1)

if ch&0x80==0x80:

GPIO.output(D7, 1)

GPIO.output(EN, 1)

time.sleep(0.0005)

17
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

GPIO.output(EN, 0)

# Low bits

GPIO.output(D4, 0)

GPIO.output(D5, 0)

GPIO.output(D6, 0)

GPIO.output(D7, 0)

if ch&0x01==0x01:

GPIO.output(LCD_D4, 1)

if ch&0x02==0x02:

GPIO.output(LCD_D5, 1)

if ch&0x04==0x04:

GPIO.output(LCD_D6, 1)

if ch&0x08==0x08:

GPIO.output(LCD_D7, 1)

GPIO.output(EN, 1)

time.sleep(0.0005)

GPIO.output(EN, 0)

def lcdstring(Str):

l=0;

l=len(Str)

for i in range(l):

lcddata(ord(message[i]))

lcd_init()

lcdcmd(0x01)

("Circuit Digest")

lcdcmd(0xc0)

18
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

lcdstring("Welcomes you")

time.sleep(3) # 3 second delay

# main() function

def main():

print 'System Ready...'

URL = 'https://api.thingspeak.com/update?api_key=%s' % key

print "Wait "

while True:

(humi, temp)= readDHT()

(pressure) =readBmp180()

19
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

CHAPTER-4

RESULT AND DEMONSTRATION

4.1 OUTPUT:-
The output of the developed prototype model can be verified on the Thingspeak server. The
fig shown in Fig.4.1, displays the temperature,humidity,pressure measured by the sensors
DHT-11,BM-180.

Fig 4.1.1 MONITORING OVER THINGSPEAK


PROTOTYPE:

FIG 4.1.2 RESULTANT OUTPUT

20
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

4.2 COMPARITIVE ANALYSIS:-

In a Raspberry Pi weather station project using DHT11 and BMP180 sensors, along with an
LCD display and a 10k potentiometer, a comparative analysis highlights the different
capabilities of the sensors and their impact on the overall system. The DHT11 sensor offers
a cost-effective and straightforward solution for measuring temperature and humidity,
though it provides moderate accuracy and slower response times compared to advanced
sensors. On the other hand, the BMP180 sensor excels in measuring barometric pressure and
temperature with high precision and versatile operating modes. While the DHT11 is budget-
friendly, the BMP180's slightly higher cost is justified by its superior performance and data
quality. The combination of these sensors allows for comprehensive environmental
monitoring, and the Raspberry Pi's compatibility with the required libraries facilitates easy
data processing and display on the LCD. Overall, the project is versatile and suitable for
various applications such as weather monitoring and educational projects, with potential for
future enhancements in sensor accuracy and additional functionality.

4.3 SUMMARY OF THE PROJECT:-

In this Raspberry Pi weather station project, the aim is to build a system capable of
monitoring environmental conditions using various sensors and displaying the data on an
LCD. The project uses a DHT11 sensor for measuring temperature and humidity and a
BMP180 sensor for barometric pressure and temperature readings. These sensors offer
different levels of precision, with the BMP180 providing higher accuracy and faster
response times compared to the DHT11. The LCD display, controlled by a 10k
potentiometer for contrast, allows for real-time visualization of the collected data.

The project is built around a Raspberry Pi, which serves as the main control unit for data
collection, processing, and display. The Raspberry Pi's compatibility with the necessary
libraries (Adafruit_DHT and adafruit-circuitpython-bmp280) simplifies the integration of
the sensors. The overall setup provides a comprehensive analysis of environmental factors
such as temperature, humidity, and atmospheric pressure, making it suitable for various
applications, including weather monitoring, data logging, and educational purposes

21
Department of Computer Science & Technology(IOT)
RASPBERRY PI WEATHER STATION

REFERENCES

Online resources followed:-

https://chat.openai.com/c/664697b8-27d0-4c70-9dfb-febd59c32b30

https://circuitdigest.com/microcontroller-projects/raspberry-pi-iot-weather-station-to-
monitor-temperature-humidity-pressure

https://www.researchgate.net/publication/332676356_Iot_Based_Weather_Station_Usin
g_Raspberry_Pi_3

References

Aguado E & Burt J, Understanding Weather and Climate, 6th ed.

Boston [Mass.]: Pearson Education, Inc., (2013).

Kodali R & Mandal S, “IoT based weather station”, 2016 Interna- tional
Conference on Control, Instrumentation, Communication and
Computational Technologies (ICCICCT), Kumaracoil, India, pp.
680-683, (2016).

22
Department of Computer Science & Technology(IOT)

You might also like