CyberPi: Sensor Meter
In this lesson, students will discover how the on-board sensors on the CyberPi represent loudness and light intensity of the surrounding environment. Students will learn about data representation and graphing of sensors values.

Lesson
Overview
Description
In this lesson, students will discover how the on-board sensors on the CyberPi represent loudness and light intensity of the surrounding environment. Students will learn about data representation and graphing of sensors values.
Objectives
Describe how CyberPi sensors detect the surrounding environment.
Debug errors in programs in mBlock.
Document a program using comments in mBlock.
Before the Lesson
Preparation
For the teacher and students:
Computer with mBlock 5 installed from here: https://www.mblock.cc/en/download/ or mBlock Web version
CyberPi with USB-C cable
Pocket shield (optional)
Example program(s):
CyberPi – Lesson 6 – Sensor Meter Volume Chart
CyberPi – Lesson 6 – Sensor Meter Sound & Light
Review
Warm Up
Data and Society
1. Find a current smart home devices to present to the class. Discuss how these solutions use sensors to provide security, convenience and automation for consumers.
Direct Instruction
Tour of mBlock 5
1. Open the mBlock software or mBlock 5 Web version.
2. Introduce students to the following key areas of the software interface:


Connect the CyberPi
3. Plug the CyberPi into the computer using the included cable. The CyberPi should boot up and the screen will display either the last program uploaded or the Home menu.
4. On the "Devices" tab in mBlock, click the "Add" button. Select CyberPi and click "Ok".
5. Click the "Connect" button. Then, select the USB port and click "Connect".

6. If connected successfully, the button will change to "Disconnect".

Guided Practice
Hands On
Exploring Sensor Data
1. Open the mBlock 5 software or mBlock 5 Web version. Add the CyberPi in the Devices tab and connect in Live mode.
2. Open the Lesson 6 – Sensor Meter example project. Click the Green Flag to run the program. Observe the values for the CyberPiVolume and CyberPiLightIntensity.
3. Have students run the program and observe the sensor values and graphing in different scenarios, such as:
CyberPi sitting on the desk
Covering up the CyberPi (light intensity should decrease)
Shining a flashlight on the CyberPi (light intensity should increase)
Trying to be as quiet as possible (volume should decrease)
Clapping or talking near the CyberPi (volume should increase)
4. Challenge students to determine the minimum and maximum values the sensors report to the computer. Note, the Light sensor and Sound sensor have a range of 0 to 100.
5. Introduce students to the blocks that are used for the sensors on the CyberPi:

Charting the Sound Sensor
6. Introduce students to the blocks that are for creating a line chart on the CyberPi:

7. Open the mBlock 5 software or mBlock 5 Web version. Add the CyberPi in the Devices tab and connect in Live mode.
8. Instruct students to build the following script and test the program:

Indenpendent Practice
Try It
Charting the Light Sensor
1. Challenge students to modify the code to include a red line chart for the light intensity. The CyberPi should show both charts at the same time.
2. Some solutions may, at first, appear to be correct. But encourage students to think critically and fully test their solution. For example, the following code does not properly graph the data. When testing this code, you should observe that speaking loudly by the CyberPi makes both the red and blue lines increase.

3. Encourage students to persevere through fixing or debugging their code until they get the correct solution. The following is a correct solution:

Extension
Have students program the LEDs or speaker to react to the loudness or light intensity.
Have students add a title and game instructions to the project.
Have students program a sprite or background to change costumes based on the loudness or light intensity. (Note, a variable is required to store each sensor value.)
Warp Up
Wrap-Up & Quick Check
Documentation/ Commenting
When programming, it can be helpful to comment programs to make them easier for someone to follow, test and debug. Instruct students to use a comment(s) to explain how the code works. Emphasize the importance of commenting and how it helps developers working together. Ask students to make it a common practice.
Downloadable Material
Example Program
Educational Standards
CSTA
CSTA
2-AP-19: Document programs in order to make them easier to follow, test, and debug.
2-CS-03: Systematically identify and fix problems with computing devices and their components.
ISTE
ISTE
5b: Students collect data or identify relevant data sets, use digital tools to analyze them, and represent data in various ways to facilitate problem-solving and decision-making.
Alberta - Grade 6-8 - CTF
Grade 6-8
CTF
- Planning, creating, appraising and communicating in response to challenges.
- Working independently and with others while exploring careers and technology.
British Columbia - Grade 6-8 - ADST
Grade 6-7
ADST
• Generate potential ideas and add to others’ ideas
• Identify and evaluate the skills and skill levels needed, individually or as a group, in relation to a specific task, and develop them as needed
• Select, and as needed learn about, appropriate tools and technologies to extend their capability to complete a task
Grade 8
ADST
• Generate potential ideas and add to others’ ideas
• Make a plan for production that includes key stages, and carry it out, making changes as needed
• Identify and evaluate the skills and skill levels needed, individually or as a group, in relation to a specific task, and develop them as needed
• Select, and as needed learn about, appropriate tools and technologies to extend their capability to complete a task
Manitoba - Grade 6-8 - Science
Grade 6
Science (Overall Skills and Attitudes)
6-0-4a: Carry out procedures that comprise a fair test. Include: controlling variables; repeating measurements to increase accuracy and reliability.
6-0-4c: Work cooperatively with group members to carry out a plan, and troubleshoot problems as they arise.
Grade 7
Science (Overall Skills and Attitudes)
7-0-4a: Carry out procedures that comprise a fair test. Include: controlling variables, repeating experiments to increase accuracy and reliability
7-0-4c: Work cooperatively with team members to carry out a plan, and troubleshoot problems as they arise.
Grade 8
Science (Overall Skills and Attitudes)
8-0-4a: Carry out procedures that comprise a fair test. Include: controlling variables, repeating experiments to increase accuracy and reliability
8-0-4c: Work cooperatively with team members to carry out a plan, and troubleshoot problems as they arise.
New Brunswick - Grade 6-8 - Science
Grade 6-8
Science (Attitude Outcome)
425: show a continuing curiosity and interest in a broad scope of science-related fields and issues
430: persist in seeking answers to difficult questions and solutions to difficult problems
431: work collaboratively in carrying out investigations, as well as in generating and evaluating ideas
Newfoundland & Labrador - Grade 6-8 - Science
Grade 6-8
Science
GCO: Skills - Students will develop the skills required for scientific and technological inquiry, for solving problems, for communicating scientific ideas and results, for working collaboratively, and for making informed decisions.
Nova Scotia - Grade 6-8 - Mathematics & ICT/Technology
Grade 6
Mathematics
N09 Students will be expected to explain and apply the order of operations, excluding exponents, with and without technology (limited to whole numbers).
Performance Indicators:
N09.01 Demonstrate and explain, with examples, why there is a need to have a standardized order of operations.
N09.02 Apply the order of operations to solve multi-step problems with or without technology (e.g., computer, calculator).
PR02 Students will be expected to represent and describe patterns and relationships, using graphs and tables.
Performance Indicators:
PR02.01 Translate a pattern to a table of values, and graph the table of values (limited to linear graphs with discrete elements).
PR02.02 Create a table of values from a given pattern or a given graph.
PR02.03 Describe, using everyday language, orally or in writing, the relationship shown on a graph.
PR03 Students will be expected to represent generalizations arising from number relationships using equations with letter variables.
Performance Indicators:
SCO PR03 Students will be expected to represent generalizations arising from number relationships using equations with letter variables. [C, CN, PS, R, V]
PR03.01 Write and explain the formula for finding the perimeter of any regular polygon.
PR03.02 Write and explain the formula for finding the area of any given rectangle.
PR03.03 Develop and justify equations using letter variables that illustrate the commutative property of addition and multiplication (e.g., a + b = b + a or a × b = b × a).
PR03.04 Describe the relationship in a given table using a mathematical expression.
PR03.05 Represent a pattern rule using a simple mathematical expression, such as 4d or 2n + 1.
SP01 Students will be expected to create, label, and interpret line graphs to draw conclusions.
Performance Indicators:
SP01.01 Determine the common attributes (title, axes, and intervals) of line graphs by comparing a given set of line graphs.
SP01.02 Determine whether a given set of data can be represented by a line graph (continuous data) or a series of points (discrete data) and explain why.
SP01.03 Create a line graph from a given table of values or a set of data.
SP01.04 Interpret a given line graph to draw conclusions.
SP02 Students will be expected to select, justify, and use appropriate methods of collecting data, including questionnaires, experiments, databases, and electronic media.
Performance Indicators:
SP02.01 Select a method for collecting data to answer a given question, and justify the choice.
SP02.02 Design and administer a questionnaire for collecting data to answer a given question, and record the results.
SP02.03 Answer a given question by performing an experiment, recording the results, and drawing a conclusion.
SP02.04 Explain when it is appropriate to use a database as a source data.
SP02.05 Gather data for a given question by using electronic media, including selecting data from databases.
ICT
P2: Students will be expected to use digital tools to develop ideas and original works in innovative ways.
TOC1: Students will be expected to
* safely use many forms of current technology for learning with growing competence
* demonstrate conceptual understanding of how information and communication technology, digital tools, and authorized networks support their learning
* use terminology related to information and communication technology
Grade 7
Mathematics
PR05 Students will be expected to evaluate an expression given the value of the variable(s).
Performance Indicator:
PR05.01 Substitute a value for an unknown in a given expression and evaluate the expression.
PR02 Students will be expected to create a table of values from a linear relation, graph the table of values, and analyze the graph to draw conclusions and solve problems.
Performance Indicators:
PR02.01 Create a table of values for a given linear relation by substituting values for the variable.
PR02.02 Create a table of values, using a linear relation, and graph the table of values (limited to discrete elements).
PR02.03 Sketch the graph from a table of values created for a given linear relation, and describe the patterns found in the graph to draw conclusions (e.g., graph the relationship between n and 2n + 3).
PR02.04 Describe, using everyday language, in spoken or written form, the relationship shown on a graph to solve problems.
PR02.05 Match a given set of linear relations to a set of graphs.
PR02.06 Match a given set of graphs to a given set of linear relations.
Technology
GCO1: Students will be expected to design, develop, evaluate, and articulate technological solutions
GCO2: Students will be expected to operate and manage technological systems
Grade 8
Mathematics
PR01 Students will be expected to graph and analyze two-variable linear relations.
Performance Indicators:
PR01.01 Determine the missing value in an ordered pair for a given equation.
PR01.02 Create a table of values by substituting values for a variable in the equation of a given linear relation.
PR01.03 Construct a graph from the equation of a given linear relation (limited to discrete data).
PR01.04 Describe the relationship between the variables of a given graph.
SP01 Students will be expected to critique ways in which data is presented.
Performance Indicators:
SP01.01 Compare information provided for the same data set by a given set of graphs, including circle graphs, line graphs, bar graphs, and pictographs, to determine the strengths and limitations of each graph.
SP01.02 Identify the advantages and disadvantages of different graphs, including circle graphs, line graphs, bar graphs, and pictographs, in representing a given set of data.
SP01.03 Justify the choice of a graphical representation for a given situation and its corresponding data set.
SP01.04 Explain how the format of a given graph, such as the size of the intervals, the width of the bars, and the visual representation, may lead to misinterpretation of the data.
SP01.05 Explain how a given formatting choice could misrepresent the data.
SP01.06 Identify conclusions that are inconsistent with a given data set or graph, and explain the misinterpretation.
Technology
GCO1: Students will be expected to design, develop, evaluate, and articulate technological solutions
GCO2: Students will be expected to operate and manage technological systems
Ontario - Grade 6-8 - Mathematics
Grade 6
Mathematics
Algebra
C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves conditional statements and other control structures
Grade 7
Mathematics
Algebra
C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves events influenced by a defined count and/or sub-program and other control structures
Grade 8
Mathematics
Algebra
C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves the analysis of data in order to inform and communicate decisions
Prince Edward Island - Grade 6-8 - Science
Grade 6-8
Science
GCO: Skills - Students will develop the skills required for scientific and technological inquiry, for solving problems, for communicating scientific ideas and results, for working collaboratively, and for making informed decisions.
Quebec - Grade 6-8 - Science
Grade 6-8
Science (Strategies)
Exploring various ways of solving the problem
Exchanging information
Comparing different possible explanations for or solutions to a problem in order to assess them (e.g. full-group discussion)
Saskatchewan - Grade 6-8 - Science
Grade 6-8
Science (Goals)
Develop Scientific and Technological Skills – Students will develop the skills required for scientific and technological inquiry, problem solving, and communicating; for working collaboratively; and for making informed decisions.
