Skip to main content

Weather Pal

Story Introduction

As the ship sailed away from the port, the outline of the coastline gradually became hazy, and the lighthouse on the breakwater shrank into a tiny spot on the horizon. The Hope was navigating through the vast ocean, and the noonday sun made the deck burning hot. Ian squatted down and stared at his shadow in the sunlight. He thought to himself, how nice it would be to know the current temperature and humidity. Could his friends help make this wish come true?


Teaching Preparation

NameIllustration
Nezha Pro Ocean Kit

Teaching Objectives

  1. Understand OLED display.

  2. Understand DHT11 temperature and humidity sensor.

  3. Master the use of OLED and DHT11 building blocks.


Learning and Exploration

Discuss with friends where temperature and humidity sensors are used in daily life and why people need to know temperature and humidity?

Construction Steps


Hardware Connection

The OLED display is connected to the "IIC" port of the Nezha expansion board;

The DHT11 temperature and humidity sensor is connected to the "J1" port of the Nezha expansion board.


Code Programming

Go to "makecode.microbit.org" and click New Project.

Enter the project name in the pop-up window and click Create.

Click Extensions in the code drawer.

In the pop-up interface, enter nezha pro and click the search icon. After the nezha pro software library is displayed, click it. Load the PlanetX software library in the same way.


Example Program

Program link https://makecode.microbit.org/_9feP8JeVcKE6

You can also download the program directly through the following webpage.


Download Program

Use a USB cable to connect the PC and micro:bit V2.

After successful connection, a drive named MICROBIT will be recognized on the computer.

Click in the lower left corner and select Connect Device.

Click.

Click.

In the pop-up window, select BBC micro:bit CMSIS-DAP, then select Connect. So far, our micro:bit has been successfully connected.

Click Download Program


Case Demonstration

The OLED displays the current temperature and humidity. When the temperature is higher than 30°C, the micro:bit shows a "crying face"; otherwise, it shows a "smiling face".


Extended Knowledge

The DHT11 temperature and humidity sensor is a commonly used digital temperature and humidity composite sensor, featuring simple structure, low cost, and ease of use. It is widely applied in scenarios such as smart homes, meteorological monitoring, and agricultural greenhouses. Here is a detailed introduction:

1. Basic Overview

Function: It can measure ambient temperature and humidity simultaneously and convert the data into digital signals for output.

Type: It is a composite sensor combining a resistive humidity sensor and an NTC (Negative Temperature Coefficient) thermistor.

Output form: Single-bus digital signal, which is convenient for direct communication with main control devices such as microcontrollers (e.g., Arduino, STM32).

2. Working Principle

1. Humidity Measurement:

It uses a resistive humidity sensing element (polymer film), whose resistance value changes with ambient humidity. The higher the humidity, the lower the resistance value. The resistance change is converted into an electrical signal through a circuit.

2. Temperature Measurement:

Temperature is detected by an NTC thermistor. When the temperature rises, the resistance value decreases, and vice versa. It is converted into an electrical signal through a circuit.

3. Signal Processing:

The microcontroller inside the sensor converts the analog temperature and humidity signals into digital signals, which are output through the DATA pin using the single-bus protocol.

3. Typical Application Scenarios

Smart home: Temperature and humidity monitoring modules, automatic control of air conditioners/humidifiers.

Agriculture and breeding: Greenhouse temperature and humidity monitoring, environmental regulation of livestock and poultry houses.

Meteorological stations: Construction of simple environmental monitoring equipment and small meteorological stations.

Industrial control: Warehouse temperature and humidity monitoring, equipment operating environment monitoring.