Measuring and Experimenting
Summary
Whether a real setup behaves the way you expect can only be decided by measuring it. An experiment that tells you something changes conditions on purpose, repeats readings, and records what was done and what came out. This concept is the craft of the module: it applies to every claim about your setup, not only to light. What those measurements then say about the limits of your link, how many colours you can safely tell apart, is the subject of Signal und Rauschen.
In this chapter, we address the following questions:
- Why is thinking not enough to know how my setup behaves?
- What does the colour sensor actually deliver, and why does it not match what was sent?
- What belongs to a measurement series that really shows something?
- What is a control reading for?
- What do integration time and gain do, and where is the trade-off?
- How often do I have to repeat before a lucky hit stands out?
- How do I record what I measured?
You need this concept by Challenge 1 at the latest, and you use it in every challenge after that.
Explanation
You can know almost nothing about your setup without measuring it. Whether a change actually helped is not answered by thinking, by a gut feeling, or by an AI assistant, but by a trial. For two thousand years people believed Aristotle, that heavy bodies fall faster than light ones. As the story goes, two balls dropped from the leaning tower of Pisa were enough to end the error. Your setup is your tower. The assistant knows sensors of this kind, but only a measurement knows yours.
What the sensor actually delivers
The colour sensor does not return three values, it returns four: the filtered shares of red, green and blue, plus clear, measured without a colour filter. Clear sees all the incoming light and is therefore more sensitive than the colour channels. When you separate bright from dark, it is your most useful value.
And none of these values matches the numbers the sender gives its LED. Send (255, 0, 0) and the sensor measures something like r=203, g=41, b=57. The colour filters overlap, the distance swallows light, and the room light is always measured too. That is not a defect, it is the normal case. The consequence: you do not calculate backwards to what was sent, because a formula that fits today will not fit tomorrow. You measure how each transmitted colour arrives at your end, and you assign every new reading to the closest pattern you learned. Calibrate, then classify: that is the core of Challenge 1.
One reading is a draw
Measure the same red LED five times and you get five different values, say 198, 205, 201, 195, 206. None of them is “the true one”. Every real measurement scatters; noise is the normal case. A single reading jumps around, an average sits still. If you need a stable value, read several times and take the mean.
You can try that yourself in the noisy sensor. A sender there transmits one of two symbols, led off or led on, and the receiver decides at a threshold which one arrived. The same readings decide three times side by side: alone, averaged over five, averaged over ten. Send twenty-five symbols and the single readings put a few dots on the wrong side of the threshold, while the averaged ones no longer reach it. The price stands next to it: the same number of decisions costs five or ten times as many readings, and the symbol rate drops from twenty per second to four or two. Which of those you need is not a matter of taste, it depends on your own setup: with little noise a single reading already decides correctly every time, with much noise even the average of five slips occasionally.
the noisy sensorSend a symbol over a noisy link and let the same readings decide it three times: alone, averaged over five, averaged over ten. Fewer wrong decisions, less speed.LiFi Project · concept demos
There is a second reason to measure more than once. The sensor never reads zero, because room light is always there. So every measurement series starts with a control reading, with your own LED switched off. That is the zero point you read every colour measurement against, and it tells you when the surroundings change, through afternoon sun or the LED of the team next to you.
The trade-off: integration time
The integration time is the sensor’s reading window: it decides over how much light a single value is averaged. Long windows give calm values but few readings per second. Short windows give many readings but shaky values, until single readings slide into the wrong range and a red is read as a blue. (Gain is the second knob; it scales the values and carries a related trade-off.)
Longer is calmer, shorter is faster. That is the central trade-off of the whole project, because the symbol rate of your transmission hangs on it. Where the limit of your setup lies is answered by no table and no assistant, only by your own measurement series. Here you meet the knob; what its setting means for your alphabet and your throughput is worked out in Signal und Rauschen after the first challenge.
Measuring on purpose
A measurement series is several readings under equal, recorded conditions, in which at most one quantity is changed on purpose. Every word carries weight. Whoever changes two things at once, say distance and integration time, and gets a better result, knows only that it got better, not what did it. Whoever does not write the expectation down beforehand can read almost any result as a success afterwards. And the record needs the conditions, the changed quantity, the number of repetitions and all the values, including the uncomfortable ones: outliers are often the most interesting information.
Repetitions are not decoration, they are your protection against a lucky hit. With two colours, pure guessing gets every second one right; five in a row succeed by chance about once in 32 attempts. Fifty out of fifty essentially never happens by luck. That is exactly why the hand-overs in the challenges are cut to long series.
And when a clean measurement series contradicts a suggestion from the assistant, the series wins. Check briefly whether it really was clean, one variable, enough repetitions, a control reading, and then the case belongs in your error log: suggestion, measurement, outcome. Put shortly: what you did not measure, you do not know.
Slides
The slides for this concept, right here. Page through them with the buttons in the top right corner, or click into the slides and use the arrow keys. The other buttons give you full screen, the slides in a new tab, and the deck as a PDF.
Practice questions
Try questions in the exam format here, with the answer and its reasoning shown right away.
Further reading
- Richard Feynman: Cargo Cult Science. Caltech commencement address, 1974, freely available online. Six pages on the one habit that makes an experiment worth anything: reporting everything that could make your own result wrong. “The first principle is that you must not fool yourself, and you are the easiest person to fool.”
- David J. Hand: Measurement. A Very Short Introduction. Oxford University Press, 2016. What a measurement actually is, why every value carries a scale and an error, and how measurements get compared. Short, readable, and useful far beyond sensors.