← ACARA Digital Technologies Years 7–8

Recording readings with datalogger.log()

Saves one row of named sensor readings, with a timestamp, in the micro:bit data log. Each call adds a new row, so use it in a loop to record readings over time.

Understanding Recording readings with datalogger.log() in ACARA Digital Technologies Years 7–8

What it does: Each call to datalogger.log() adds one row, so running it inside basic.forever() keeps adding rows as time passes. basic.pause(5000) waits 5000 milliseconds (5 seconds) before the loop logs the next row. datalogger.log() needs a named value made with createCV(), which pairs a column name with a reading. Just a string gives no reading to save. The first argument is the column heading. The second argument, input.temperature(), is the actual reading. The data logger adds a timestamp for each row automatically. You only supply your sensor readings. You can pass several createCV() values to one datalogger.log() call to make several columns in the same row.

Common mistakes: The object is called datalogger, not datalog. The line should start datalogger.log( so the row is saved in the micro:bit data log. The column name must be a string in quotes. It should be datalogger.createCV("tmp", so the log has a named column.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 204–236) and word search (Modules 189–236).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which line saves a temperature reading as a row in the micro:bit data log?
datalogger.log(datalogger.createCV("temperature", input.temperature()))datalogger.log("temperature")
Matches
datalogger.log("temperature", input.temperature())
↓
The reading is not wrapped in datalogger.createCV(), so the column name and value are not paired properly for the log.
Applying
Meanings
Term
datalogger.log()
Meaning
Saves one row of named sensor readings, with a timestamp, in the micro:bit data log. Each call adds a new row, so use it in a loop to record readings over time.
Practice
basic.forever(function () {
Testing
Gaps
datalogger.(
Check Answer
Spots
1datalog.log(
2 datalogger.createCV("temp",

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Fennec Fox' badge — Listener, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which line saves a temperature reading as a row in the micro:bit data log?
A. datalogger.log("temperature")
B. datalogger.log(datalogger.createCV("temperature", input.temperature())) ✓
datalogger.log() needs a named value made with createCV(), which pairs a column name with a reading. Just a string gives no reading to save.
2. What does each call to datalogger.log() do?
A. Replaces the whole data log with one row
B. Adds a new row to the data log ✓
Every call adds one new row, which is why the log builds up a record of readings over time.
3. In datalogger.createCV("temperature", input.temperature()), what is "temperature"?
A. The column name for the reading ✓
B. The temperature value in degrees
The first argument is the column heading. The second argument, input.temperature(), is the actual reading.
4. You want a reading saved every second for a minute. Where should datalogger.log() go?
A. Inside a loop, such as basic.forever() ✓
B. Once at the very start of the program
One call saves only one row. Putting it inside a loop saves a new row each time the loop repeats.
5. Do you need to write code to record the time of each row?
A. No, the micro:bit adds a timestamp to each row ✓
B. Yes, you must create a time column yourself
The data logger adds a timestamp for each row automatically. You only supply your sensor readings.

Match the Pairs

datalogger.log(datalogger.createCV("temperature", input.temperature())) → Saves one new row in the data log with a column called temperature holding the current temperature reading
datalogger.log(datalogger.createCV("temp", input.temperature()), datalogger.createCV("light", input.lightLevel())) → Saves one row with two columns, temp and light, so two readings are recorded together at the same moment
To record readings over time, put datalogger.log() inside a loop so each pass adds a new row to the log → basic.forever(function () { datalogger.log(datalogger.createCV("temperature", input.temperature())) })
Pausing between logs spaces the readings out, for example one row every 5 seconds → basic.forever(function () { datalogger.log(datalogger.createCV("temperature", input.temperature())) basic.pause(5000) })
datalogger.log("temperature", input.temperature()) → The reading is not wrapped in datalogger.createCV(), so the column name and value are not paired properly for the log.
datalogger.log(datalogger.createCV("temperature", input.temperature)) → input.temperature is missing its brackets (), so the function is never called and no reading is taken.

Key Term

datalogger.log()
Saves one row of named sensor readings, with a timestamp, in the micro:bit data log. Each call adds a new row, so use it in a loop to record readings over time.

Fill in the Blanks

1. datalogger.log( datalogger.createCV("temperature", input.temperature()))
Hint: Type the datalogger function that saves a new row in the data log.
2. datalogger.log( datalogger.createCV("temperature", input.temperature()))
Hint: Type the function that pairs a column name with a reading.
3. basic.forever(() => datalogger.log( datalogger.createCV("temperature", input.temperature())))
Hint: Type the block name that repeats the logging again and again, adding a new row each time.
4. datalogger.log( datalogger.createCV("l", input.lightLevel()), datalogger.createCV("s", input.soundLevel()))
Hint: Type the input function that reads how bright it is, for the first column of this two-column row.
5. datalogger.log( datalogger.createCV("temperature", input.temperature()))
Hint: Type the input function that reads the heat sensor value to store in the column.

Spot the Error

Question 1
A datalog.log(
B datalogger.createCV("temp",
C input.temperature()))
Line A — The object is called datalogger, not datalog. The line should start datalogger.log( so the row is saved in the micro:bit data log.
Question 2
A basic.forever(function () {
B datalogger.log(
C datalogger.createCV(tmp,
D input.temperature()))
E basic.pause(5000)
F })
Line C — The column name must be a string in quotes. It should be datalogger.createCV("tmp", so the log has a named column.
Question 3
A for (let i = 0; i < 10; i--) {
B datalogger.log(
C datalogger.createCV("tmp",
D input.temperature()))
E basic.pause(1000)
F }
Line A — i-- makes i count down, so i < 10 is always true and the loop never stops. It should be i++ so the loop logs exactly 10 rows.
Question 4
A datalogger.log(
B datalogger.createCv("temp",
C input.temperature()),
D datalogger.createCV("light",
E input.lightLevel()))
Line B — Function names are case sensitive. It must be createCV with a capital V, not createCv.
Question 5
A basic.forever(function () {
B datalogger.save(
C datalogger.createCV("tmp",
D input.temperature()))
E basic.pause(1000)
F })
Line B — There is no datalogger.save(). The command that adds a row to the data log is datalogger.log(.

Student with a class code? Join your class →