Lesson 5 - Data Visualization
Students learn how to record light, temperature and water-level data over time, view it as a line graph, and use AI to turn the data into a decision.
I can explain what data logging is
I can plan what data to collect and how often to collect it
I can program the micro:bit to log data automatically based on my plan
1. Engage: Which Hydroponic Data Matters?
In the last lesson, we built a system that can pump water all by itself. But how do we know the plant is happy? How do we know the sunlight is bright enough, the temperature is right, and when the water will run out? We cannot tell from a single number. We have to watch how things change over time.

Key Question
In a hydroponic setup, which data is key and useful?
Guide students to brainstorm, then sort their ideas into the three most important kinds of data for our water-grown plant:
Light - Plants need light for photosynthesis, and its strength changes with the weather and the time of day.
Temperature - If it gets too hot or too cold, the plant stops growing well.
Water level - It drops a little every day, and we need to know when to refill.
A single reading is only a snapshot. To really understand what is happening, we need to record the data again and again over time. Today we will turn our micro:bit into a data logger.
2. Explore: What Is Data Logging?
Data logging is the recording of data over time. It is used in science experiments to record environmental or physical data. It might capture a quick event, like a falling object, or run for a long time, such as recording temperature or light levels over a day or a whole week.
Key Question
Why is data logging so useful for our hydroponic project?
1. Detect problems & find causes – long-term records reveal sudden anomalies (a failing light/pump/sensor) and let you look back to explain past issues, not just guess.
2. Turn data into evidence & smart decisions – trends + comparisons let you set reliable thresholds, automate control, and give AI the data it needs for evidence-based analysis.
Teacher Note:
Data logging works on micro:bit V2 only.
3. Engineer: Log Light Levels Manually
The teacher demonstrates the whole "program → record → read → view" loop while students watch, then try the steps themselves.
Step 1: Add the Data Logger extension
![]()

Step 2: Set the column names

Use the set columns block to name the column, for example, "light level." Naming the columns first tells us what the numbers mean.

Step 3: Record data with a button
Use on button A pressed block to record the current light level, and show a heart icon on the LED display so we can see that data was recorded.

Click the here to open this project in the micro:bit MakeCode editor
Press Button A under different light levels to record multiple sets of data.
Step 4: Read the data
Reconnect to your micro:bit and find the USB drive called MICROBIT.
![]()
Open the MY_DATA file in a web browser - you will see a table with the readings you recorded.


4. Experience & Challenge: Plan and Build an Automatic Data Logger
Key Question
What must we decide BEFORE we write any code?
Activity 1
• Have students work in pairs to discuss the questions below, agree on their logging plan, and record their decisions in the table. Encourage them to explain the reason behind each choice.
Here is a sample table:
| Decision | Our Plan |
| What data will we log? | Light, Temperature, Water level |
| How often will we log it? | Every 5 seconds |
| LED indicator while logging? | Show a heart icon |
| How to clear the data? | Button A + B = clear logging |
Experience: Program an automatic data logger (every 5 seconds)
Activity 2
• Ask students to make the hardware connection.

• Students turn their plan into code. Recommended blocks:


• Download the program to the micro:bit. Let it run for 1-2 minutes, then unplug your micro:bit and plug it back in. And open MY_DATA to check the table is filling with a new row every 5 seconds.
Here is a sample code:

Click the here to open this project in the micro:bit MakeCode editor
Challenge: View the line chart, download the CSV
Activity 3
• Challenge students to decide which chart type best tells the story of their data. Guide them to compare the options in MY_DATA (e.g. line graph vs. bar chart) and explain why the line graph suits time-series data. Then have them press Download to save the data as a CSV file.

5. Elaborate: Let AI Read Our Data
Now we let the story that the data tells help us decide. Working in groups, send the CSV file to a large-language model (for example, ChatGPT) and ask it to help analyse the data.
Activity 4
• Guide students to send the CSV content to the AI, for example: "Here is my hydroponic data. Check the light and temperature. Are they within a range my plant can grow well in?"
• Let the AI answer the questions, then discuss together: What can we do to make a better environment for our plants?
Key Question
How long until the water needs to be topped up?
Prompt: Look at the water-level column and work out how fast the water is dropping. When will it hit the level that turns my pump on, and when should I add water?
Teacher Note:
Before asking AI about the water-level trend, make sure you have collected data for a long enough period — a few minutes of logging is not enough to show a clear downward trend.









