THER-MOOD-STAT

PIPER MAKE EDUCATOR RESOURCES SERIES

To do this project, you will need a Piper Make Extended Starter Kit. Get yours here:

You're getting warmer... with this

To get started, head to Piper Make and hit this icon:

Time: 60 minutes

Age Range: 8+

Difficulty: Intermediate

In this project, students use the temperature sensor to measure temperature in real time. The project itself teaches students fundamentals about if/then statements, allowing students to code their ideal temperature range and then defining consequences “if” the measured temperature falls outside that range. We also add to the repertoire of blocks available in the Piper Make interface with this project, allowing students to code emojis to display contingent on the temperatures measured by their sensors.

Note: There are step by step instructions for the students to follow in the tutorials included in each project on Piper Make. These provide directions both for writing code and for building the electronic circuits. The tutorials are well-defined and most students will be able to follow them with little assistance required.

LEARNING OBJECTIVES

Students will:

 

  • Practice coding loops
  • Demonstrate how computer hardware and software work together as a system to accomplish tasks.
  • Review key electronics and programming understandings:
    • wire and pin positions for specific inputs and outputs
    • loops: running the same sequence multiple times
    • events: while a pin’s condition is on or off, another action happens
  • Create programs that use variables to store and modify data.
  • Create programs that include events, loops, and conditionals.
  • Decompose problems into smaller, manageable tasks which may themselves be decomposed.
  • Create programs by incorporating smaller portions of existing programs, to develop something new or add more advanced features.
  • Test and debug a program or algorithm to ensure it accomplishes the intended task.

STANDARDS ALIGNMENT

CA Computer Science Standards

3-5.CS.2: Demonstrate how computer hardware and software work together as a system to accomplish tasks.

3-5.CS.3: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies.

3-5.AP.11: Create programs that use variables to store and modify data.

3-5.AP.12: Create programs that include events, loops, and conditionals.

3-5.AP.13: Decompose problems into smaller, manageable tasks which may themselves be decomposed.

3-5.AP.14: Create programs by incorporating smaller portions of existing programs, to develop something new or add more advanced features.

3-5.AP.17: Test and debug a program or algorithm to ensure it accomplishes the intended task.

 

Science Standards Alignment

MS-PS3-4: Plan an investigation to determine the relationships among the energy transferred, the type of matter, the mass, and the change in the average kinetic energy of the particles as measured by the temperature of the sample.

MS-PS3-5: Construct, use, and present arguments to support the claim that when the kinetic energy of an object changes, energy is transferred to or from the object.

MS-PS1-4: Develop a model that predicts and describes changes in particle motion, temperature, and state of a pure substance when thermal energy is added or removed.

LANGUAGE OBJECTIVES

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

CA ELD.3.C.11: Supporting own opinions and evaluating others’ opinions in speaking and writing

CA ELD.3.C.12: Selecting and applying varied and precise vocabulary and language structures to effectively convey ideas

MICHIGAN INTEGRATED TECHNOLOGY COMPETENCIES FOR STUDENTS (MITECS)

1B-CS-02 Model how computer hardware and software work together as a system to accomplish tasks. Subconcept: Hardware & Software; Practice 4.4

1B-CS-03 Determine potential solutions to solve simple hardware and software problems using

common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2

1B-AP-09 Create programs that use variables to store and modify data. Subconcept: Variables; Practice 5.2

1B-AP-10 Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2

1B-AP-11 Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

1B-AP-12 Modify, remix, or incorporate portions of an existing program into one’s own work, to develop something new or add more advanced features. Subconcept: Modularity; Practice 5.3

1B-AP-15 Test and debug (identify and fix errors) a program or algorithm to ensure it runs as intended. Subconcept: Program Development; Practice 6.1, 6.2

 

Core Content Standards

 

Michigan Science Standards

MS-PS3-4: Plan an investigation to determine the relationships among the energy transferred, the type of matter, the mass, and the change in the average kinetic energy of the particles as measured by the temperature of the sample.

MS-PS3-5: Construct, use, and present arguments to support the claim that when the kinetic energy of an object changes, energy is transferred to or from the object.

MS-PS1-4: Develop a model that predicts and describes changes in particle motion, temperature, and state of a pure substance when thermal energy is added or removed.

 

Language Objectives

 

Michigan ELA, Grade 3-8, Research, 8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

Michigan ELA, Grade 3-8, Range of Writing, 10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

 

WIDA ELD Standards

 

ELD-SI.K-3.Argue:

  • Ask questions about others’ opinions
  • Support own opinions with reasons
  • Clarify and elaborate ideas based on feedback
  • Defend change in one’s own thinking
  • Revise one’s own opinions based on new information

 

ELD-SC.2-3.Argue.Interpretive:

Interpret scientific arguments by

  • Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
  • Analyzing whether evidence is relevant or not
  • Distinguishing between evidence and opinions

CONCEPTS

Students will deepen their understanding of temperature, forms of energy, and quantitative/qualitative data while continuing their use of sensors and PiperCode.

PARTS

Raspberry Pi Pico, breadboard, charging cable, the Temperature Sensor

GPIO SETUP

Red - VCC - 3.3V Power, Black - GND - Ground, Yellow - SCL (Serial Clock Line) - GP21, Green - SDA (Serial Data Line) - GP20

OVERVIEW OF STEPS

Step 1: Temperature Sensor

You’re going to need a Temperature Sensor for this project—which you might have on hand if you’re one of our earliest Monthly Makers Club members OR if you have an Extended Starter Pack. If not, don’t worry -- head over to playpiper.com and search for the Sensor Explorer to get three snazzy sensors.

If you’ve got your Temperature Sensor, click NEXT to get started!

Step 2: Temperature emoji

Brrrrr! Have you ever been somewhere cold and the hairs on your arms stand up? But wait, doesn’t the same thing happen when you’re watching a scary movie and you get really scared?

Yep, it turns out that your skin has really tiny sensors kind of like the one in front of you—with little muscles to pull up your strands of hair when you’re cold or scared! If you were really hairy, the extra fur length would make you warmer in the cold and make you look much bigger to whatever you were scared of!

We’re going to code up your Temperature Sensor to measure the temperature outside and use it to print how you feel inside!

That makes me feel pretty 🔥

Click NEXT.

Step 3: Build your sensor

Let’s start by connecting up our Temperature Sensor. Remember, the DIGITAL VIEW is a handy dandy way to see the GPIO pin mapping.

Here’s what each of those wires on the sensor connect to:

Red - VCC - 3.3V Power
Black - GND - Ground
Yellow - SCL (Serial Clock Line) - GP21
Green - SDA (Serial Data Line) - GP20

Once you've connected your Temperature Sensor, click NEXT.

Step 4: Create the function

Now that our Temperature Sensor is wired up, let’s think about what we want it to do. Since we want our code to measure the temperature and then return how we feel (in emoji form), we’re going to write a Function. In computer science, this is basically a piece of code that does a specific task and can then output a value. Drag a do something return block from the Function menu out to our workspace. Since the thing we want this block to do is return an emoji, let’s rename it from "do something" to "emoji"

Step 5: Emoji conditional

Remember that functions do a task, and can send back a value, right? In our case, we want the function to read the Temperature Sensor block and return an emoji depending on the temperature.

So if the sensor measures a nice comfortable room temperature between 70-73 degrees Fahrenheit (21-23 Celsius), we want to return a smiley face. How do we code that?

Let’s start by dragging an if _ return block from the Function menu into our emoji function block:

Click NEXT.

Step 6: It's just logical

Awesome, but let’s think about what temperatures make us ☹ — it’s not just when it’s super hot right? Super cold is pretty bad too.

To be able to code for both of those cases, we want to have an OR Logic statement so we can test two things at once—like is it too hot OR is it too cold?

Drag the _ and _ block from the Logic menu to the if return block and change it from an and to an or:

Click NEXT.

Step 7: Add inequalities

But how do we tell the code which temperatures are in the right range? Let’s tell the code to test whether a statement (like "the temperature is above 73 degrees") is TRUE or FALSE.

Find the _ = _ blocks in the Logic menu and place one before and one after the or Logic block as shown. Change the first = to a ≥ and change the second = to a <.

What do these symbols represent? Why are we using these inequalities in this case?

Step 8: Save that temperature!

But wait, we have our Temperature Sensor connected, shouldn’t we use that measurement somewhere? Why yes, this is where we need to get the measurement from it to test it out!

We need to read the temperature and store it into a variable so we can use it in our function. In the Variables menu, click the Create variable button and name our new variable "the temp".

Then, drag out a set the temp to block and place it at the beginning of the emoji function. Finally, drag a temperature sensor block from the Sensing menu into the set the temp to block:

Click NEXT.

Step 9: Bring in the sensor

We’re really close now, we just need to put the the temp blocks in the right places in the OR logic statement next to the inequalities. Find the the temp block in the Variables menu and drag one to the left of the first inequality and a second to the left of the second inequality:

Click NEXT.

Step 10: Add integer variables

Now let’s set those numbers! What temperature do we want to test? Let’s say that we’re the happiest between 70-73 degrees Fahrenheit, we would want to test whether the temperature is below 70 or above 73, correct?

Under the Values menu, find the number value block with a 0. Add one number value block to the right side of each inequality.

Now, let's set our temperature range by changing the number values to 70 and 73 respectively.

When your values are set, click NEXT.

Step 11: Select an emoji

Let’s assume you’re super picky, and anything outside the range of 70-73 degrees makes you sad.

Drag an emoji block from the Values menu and add it to the return statement in the if return block.

Change the emoji block to the sad face, and our program will know to return that emoji if the temperature reading is above 73 degrees OR below 70 degrees, like we coded!

Click NEXT.

Step 12: Set a return phrase

But hey, if it’s not too cold and it’s not too hot, it must be just right! So go ahead and drag another emoji block to the return slot of the emoji function and set it to the happy face.

This will make the program return a sad face if the measured temperature is in the ranges we coded and a happy face if it’s not!

Step 13: Shout the emoji

Now the fun part, let’s display our emoji to the world! To have your emoji show on the screen and keep it on the screen, you will need to run a program to shout the emoji (which just means to have it pop up on the screen).

The emoji that is being shouted needs to be the one we generated from the function.

First grab a start block and add a shout block in the Chip menu. We want to have the program constantly running so add a repeat forever block under Loops.

The shout block will show the returned emoji on your workspace. To show the emoji we generated, add the emoji block found under Function menu to the value of the shout block:

Click NEXT.

Step 14: Test your code

Looks like you’re in the hot seat, let’s try it out!!

Be careful! Don't try to measure things that are dangerously hot or cold, and don't put your sensor in anything liquid or wet!

Click START in the top left corner of the screen to start your code. Let’s see what the room temperature is and see if it falls in the range of 70-73 degrees. How about when we rub our hands together and hold the sensor? Do the emojis pop up like you expected?

Curious about what temperature you’re measuring? Drag a print block into your loop and tell the program to print the Temperature Sensor measurement. When you hit START, click on the CONSOLE tab and you'll see the temperature reading as well!

When you're happy with your program, click STOP, then click NEXT.

Step 15: Customize it!

But everyone’s ther-mood-stat is a bit different right? Maybe you really love when it’s colder but your friend is happier basking in the heat.

Well not to worry, this is your moment to personalize your ther-mood-stat! Go ahead and add more ranges by clicking on the if, return block you’ve already coded. Once highlighted, right click and select duplicate. Drag the duplicate blocks back into the to emoji function.

With each if return block, you can set different temperature ranges and emojis depending on what you like and don’t like. Start your program again and measure items with different temperatures and see your emojis show up!!

Be careful though! Don't try to measure things that are dangerously hot or cold, and don't put your sensor in anything liquid or wet!

Click NEXT.

Step 16: Congratulations!

You now know how the air conditioning system in your home or school measures the temperature to "know" when to turn on or off. Can you think of other uses for a Temperature Sensor that you might run into?

Click EXIT to go back to the start screen and try out other projects or tutorials!