X
Home > Blog > STEM for Arduino > HOW to Detect Ambient Temperature with Kidsuno

HOW to Detect Ambient Temperature with Kidsuno

By r November 5th, 2024 46 views
It is necessary to monitor the atmospheric temperature in the natural environment in real time. If the temperature is too high, disasters such as fire may occur. When the normal temperature is detected, the green LED lights up; the yellow LED is a reminder for raising temperature; if red LED is on, be very careful because it indicates a high temperature!
In this experiment, the XHT11 temperature and humidity sensor and the traffic light module to measure temperature range. Three colors of LED indicate three ranges of ambient temperature.

Flow

4501

Assembly

line1

Required Parts

45_00

line1

Step 1

45_01

line1

Step 2

45_02

line1

Step 3

45_03

line1

Step 4

45_04

line1

Step 5

45_05

line1

Step 6

45_06

line1

Completed

45_07

line1

Wiring Diagram

4502

Test Code

Open KidsBlock and connect the board to your computer. Click File –> Load from your computer.

3111

Choose D:\Code\1.Code_kidsuno to open 4.5Temperature detection.sb3 file.

4503

Click Unconnected to connect to port and then click 2210 to upload the code.

Explanations

5top

Conceive:

Set three thresholds to separate the temperature range: 24, 29, 35, which are adjustable according to needs.

  • preference temperature: 24°C ~ 29°C

  • warning temperature: 29°C ~ 35°C

  • high temperature: over 35°C

Corresponding LED will light up when the ambient temperature is within the related ranges.

  • Within preference temperature range: the green LED lights up

  • Within warning temperature range: the yellow LED lights up.

  • Within high temperature range: the red LED lights up.

line2

Code structure:

  1. Initialization. Set the pins of XHT11 temperature and humidity sensor and the traffic light module.

    4504

  2. Loop.

    XHT11 sensor reads and outputs the temperature values.

    Determine which section the temperature value is in, so then light up corresponding LED.

    • 24°C ≤ temperature < 29°C: the green LED lights up and other LEDs are off.

    • 29°C ≤ temperature < 35°C: the yellow LED lights up and other LEDs are off.

    • temperature > 35°C: the red LED lights up and other LEDs are off.

    4505

5bottom

Test Result
4top
After uploading the code, the XHT11 sensor detects the ambient temperature value.
When the value is in the preference temperature range, the green LED lights up;
When the value is within the warning temperature range, the yellow LED turns on;
When the value exceeds the high temperature threshold, the red LED lights up.
4506
4bottom
HOW to Simulate Thunder Detection with Kidsuno
Previous
HOW to Simulate Thunder Detection with Kidsuno
Read More
HOW to Make a Track Alarm with KidsIOT
Next
HOW to Make a Track Alarm with KidsIOT
Read More
Message Us