Raspberry Pi Learning Resources

# Sensing the Weather - Rainfall Lesson

In this lesson students will learn how the rain gauge works, then Python code will be written to interface with it, detect rainfall, and display the measurement value.

## Sensor guide

Here is some background information about the rain gauge.

## Learning objectives

• To understand how the rain gauge works by creating signal pulses
• To be able to collect and interpret data from an external sensor
• To be able to convert bucket tips into a measurement of rainfall in mm
• Understand and evaluate the difference between polling a sensor and using interrupts

## Cross-curricular applications

• Computer Science - loops, functions, variables
• Geography - rainfall data from local area
• Physics - pull up/pull down circuits, sensors
• Mathematics - surface area, volume, conversion to mm

## Lesson summary

• How does the rain gauge work?
• Counting signals using polling
• Counting signals using interrupts
• Plenary: Which is best?

## Starter

Examine the rain gauge sensor and discuss with pupils how it works and measures the rainfall over time. Read the rain gauge guide for more detailed information.

• Ask students what they think it does and how they think it works.
• Open it up and explore the sensor, reed switch, and magnet.
• More able students could research the link between mm of rainfall and a ml quantity.

Once you have explored how the sensor works, you should connect it up to the Raspberry Pi Weather Station in order to demonstrate it later in the lesson.

## Main development

1. Students boot their Raspberry Pi.
2. Students follow the worksheet to create a polling program to gather data from the sensor, and create an interrupt program to gather data from the sensor.
3. Discuss with students the difference between polling vs. using interrupts: polling monopolises the processor, but interrupts only occur when the sensor is triggered.

## Plenary

Ask the class the following questions:

1. Why is the unit of measurement for rainfall a length/depth as opposed to a volume?
2. What are the advantages of using interrupt handlers over continuous polling?