Atmospheric pressure is an indicator of weather. When a low-pressure system moves into an area, it usually leads to cloudiness, wind, and precipitation. High-pressure systems usually lead to fair, calm weather. Temperature plays an important role and it is important to know what temperature is, how it is measured, and what implications it may have for society as a whole.

In this tutorial we will monitor the temperature and the atmospheric pressure in Blynk mobile app using Raspberry Pi Zero W.

Here’s the sample output from the Blynk app:

Hardware Components

Software Components

Application Discussion

DS18B20 Digital Temperature Sensor

The DS18B20 is a 1-wire programmable Temperature sensor from Maxim integrated. It is widely used to measure temperature in hard environments like in chemical solutions, mines or soil etc. The construction of the sensor is rugged and also can be purchased with a waterproof option making the mounting process easy. It can measure a wide range of temperature from -55°C to +125° with a decent accuracy of ±5°C. Each sensor has a unique address and requires only one pin of the MCU to transfer data so it is a very good choice for measuring temperature at multiple points without compromising much of your digital pins on the microcontroller.

How does it work:

The sensor works with the method of 1-Wire communication. It requires only the data pin connected to the microcontroller with a pull up resistor and the other two pins are used for power. The pull-up resistor is used to keep the line in high state when the bus is not in use. The temperature value measured by the sensor will be stored in a 2-byte register inside the sensor. This data can be read by using the 1- wire communication protocol.

BMP280 Barometric Pressure Altitude Sensor

BMP280 is an environmental sensor which reads temperature and barometric pressure that is the next generation upgrade to the BMP085/BMP180/BMP183. This sensor is great for all sorts of weather sensing and can even be used in both I2C and SPI modes. This sensor has high accuracy and low cost making it an ideal solution for precision pressure measurements of up to ± 1 hPa and a temperature of up to ± 1.0 ° C. Because the pressure changes with altitude and pressure measurements are very accurate, you can use this sensor and the altimeter ± 1 meter accuracy.

VNC Viewer

Virtual network computing (VNC) is a type of remote-control software that makes it possible to control another computer over a network connection. Keystrokes and mouse clicks are transmitted from one computer to another, allowing technical support staff to manage a desktop, server, or other networked device without being in the same physical location. We will use this software to access our Raspberry Pi Zero W via Wi-fi network. This tutorial is based on using VNC Viewer to be able to work on the Raspberry Pi Zero W desktop.

Software Setup

Install the Blynk app from Playstore or App Store in your phone.

Open the app and select New Project.

Enter the Project Name, then press Choose Device and select Raspberry Pi 3 B and then press Connection Type and select WiFi. Then press Create Project.

Press Ok, your Auth Token was sent to your email but you can also find it in the Project Settings.

Go to widgets menu and select Value display, then press the Value Display widget and press the pin and select V2 and also enter the title.

Go to widgets menu again and select Value Display, then press the Value Display widget and press the pin and select V4 and enter the title.

Select the Value Display in widgets menu again, then press the Value Display and press the pin and select V3 and enter the title.

If you’re already connected to the Blynk app, just press the Play icon on the top left corner.

NOTE: you can make your own design and format in your Blynk app.

Hardware Setup

DS18B20 Setup

Connect the GND to the GND of the Raspberry Pi Zero W and the VCC to 3V3 pin. Connect the DQ to the GPIO 4. And also place a pull up 4.7k ohms resistor in the DQ of the DS18B20.

BMP280 Setup

Connect the SCK to GPIO 3 of the Raspberry Pi Zero, next is connect the SDI to GPIO 2, then connect the VCC to 3v3 and the GND to the GND of Raspberry Pi Zero W.


Libraries Included

Raspberry Pi Code

Code Breakdown

This code initializes the Blynk and also the GPIO pins, by turning the GPIO module and the temperature module. And then enters the correct device file that holds the temperature data.

This is the read_temp_raw() function. This is the code that reads the temperature data, it opens the temperature device file and then returns the text.

This is the read_temp() function. This code converts the value or data of the sensor into temperature in celsius and farenheit. And sends the data or value of the temperature in celsius and farenheit in the Blynk app.

This code prints the temperature value in celsius and farenheit and the atmospheric pressure value, then sends the atmospheric pressure value to the blynk app.


With the recent rise of technology, it allows us to to create new ideas that can help us in our daily life. Like this project, it helps us in monitoring the weather since the atmospheric pressure and temperature are one of the parameter in weather and it helps us in making decisions and save us time throughout the day.





Tags : Atmospheric pressureblynkBMP280DS18B20Raspberry piRaspberry Pi ZeroRPiTemperature and Atmospheric pressure monitoringtemperature sensor

Leave a Response