How to make a weather monitoring system with Raspberry Pi board

How to make a weather monitoring system with Raspberry Pi board

Hello and welcome back. In this project, we will learn how to make a weather monitoring system with a Raspberry Pi board. For that, I used the DHT11 sensor, LDR sensor, and Rain sensor. Therefore, we can get the temperature, humidity, lighting values, and rainfall values. I think this project is most suitable for getting the basic knowledge of weather monitoring systems. Also, we can use these systems for any place where weather data activities take place. If you want to do this project with Nodemcu ESP8266, please use the links below. But, you can learn how to do this project with the python language in this project.

If you need more information about these sensors, please use the links below.

  • If you want to visit our tutorials using an android smartphone, please use the SriTu Hobby app in the play store – click me

OK, let’s do this project step by step. The required components are given below.

Step 1

Firstly, identify these components.

Step 2

Secondly, place the GPIO Extension board on the breadboard (If you are using an extension board). You can also do this project without an extension board and ribbon cable.

Step 3

Thirdly, place the ADS7830 (Analog to Digital converter) on the breadboard and connect it to the extension board. If you are not using an extension board, please connect it directly to the Raspberry pi board.

How to make a weather monitoring system with Raspberry Pi board

Step 4

And then, connect the sensors one by one to the extension board. As DHT11 sensor, LDR sensor, and rain sensor. For that, you can use the circuit diagram above.

Step 5

Now, connect the LCD screen to the extension board.

Step 6

Next, connect the mouse, keyboard, monitor, ethernet cable, and SD card(OS installed) to the Raspberry Pi board.

Step 7

Finally, connect the GPIO ribbon cable to the Raspberry Pi and provide a power supply to the Raspberry Pi board.

Step 8

Ok, now let’s install the DHT11 library into the OS (operating system). For that, open the terminal and run the following commands one by one. In this case, keep the internet connection enabled.

  • sudo apt-get update

  • sudo apt-get install build-essential python-dev python-openssl git

  • sudo pip3 install adafruit-circuitpython-dht

  • sudo apt-get install libgpiod2

Now, you can use the DHT11 library.

Step 9

And then, enable I2C communication. If you want to know whether it is enabled or not, please run the following command on the terminal. Then, you can see the I2C module address.

Step 10

OK, now copy and paste the following python script on the Thonny IDE.

  • Full details of this project — Download
  • No need to install I2C library. It’s included in the file above. But keep these scripts in one folder.
# Include the library files
import I2C_LCD_driver
from time import sleep
import board
import adafruit_dht
from smbus import SMBus
import RPi.GPIO as GPIO

LDR = 27
bus = SMBus(1)


# Set the sensor pin as Input pin

# Create a object for the LCD
lcd = I2C_LCD_driver.lcd()
# Create a object for the DHT11 sensor
DHT11 = adafruit_dht.DHT11(board.D17, use_pulseio=False)

# Starting text
lcd.lcd_display_string("System Loading",1,1)
for a in range (0,16):

def TempHumi():
        # Get the Temperature and Humidity values
        temperature_c = DHT11.temperature
        temperature_f = temperature_c * (9 / 5) + 32
        humidity = DHT11.humidity
        # Print the values on the LCD display
        lcd.lcd_display_string(str(temperature_c) + ".0C",1,2)
        lcd.lcd_display_string(str(humidity) + "%",2,2)
        # Print the values to the serial port
            "Temp: {:.1f} F / {:.1f} C    Humidity: {}% ".format(
                temperature_f, temperature_c, humidity
    except RuntimeError as error:
        # Errors happen fairly often, DHT's are hard to read, just keep going
    except Exception as error:
        raise error
def light():
    value = GPIO.input(LDR)
    if value == 0:
        lcd.lcd_display_string("L:" + "High",1,8)
        lcd.lcd_display_string("L:" + "LOW ",1,8)
#Get the analog input values
def rain():
    bus.write_byte(0x4b,0x84)# A0
    value = bus.read_byte(0x4b)
    value = (value/255) * 100
    value = (value - 100) * -1
    value = int(value)
    lcd.lcd_display_string("R:" + str(value) + "% " ,2,8)
while True:

Step 11

Now, save this script and click the run button.

OK, now you can get the values using this project. The full video guide is below. So, see you in the next project or tutorial.

How to make a weather monitoring system with Raspberry Pi board

Similar Posts

Leave a Reply

Your email address will not be published.