Skip to content

The sensors

Matthew Jadud edited this page Nov 4, 2022 · 4 revisions

We have built a "wifi sensor." Like all sensors, it's actually more complex and less useful than you'd think. We'll start by talking about what a sensor is, and then use that to help describe a wifi sensor or, as we like to say, wifi estimator.

What is a sensor?

Let's play with definitions for a moment. This will get a bit detailed for a moment, but we want you to see just how complex the problem of designing and building a sensor is. We'll use a thermometer---they're simple, right?---as our running example.

Definition 1: A sensor is a device that can measure something.

That sounds nice, but it doesn't get us very far. If I put some marks on a glass tube, and put some mercury in it, the mercury will definitely go up and down with temperature, but that doesn't actually tell me what the temperature is.

Definition 2: A sensor is a calibrated device that can measure something.

This is a bit better. If I put the mercury in the tube, put the tube in some ice-cold water, and draw a line, I can now see if the temperature is below or above freezing. Better, but not good enough.

Definition 3: A sensor is a calibrated device that can measure something and has a known response curve across the full range of its measurement.

This is starting to sound awfully technical. For my home-grown thermometer, it isn't enough to know that the temperature is above or below freezing; that's a binary classification. I need to also record a mark on my thermometer at the boiling point of water, and I need to know how the mercury in the tube behaves at every point in-between. Does it expand linearly? If so, that means that every degree of temperature rise will produce an equal amount of expansion in the mercury. Is it logarithmic? Then... the lines are going to be spaced closer together near freezing, and further apart near boiling, because the mercury will be expanding quickly as it approaches boiling.

This almost gets us there. However, up until now, my thermometer seems to work today. What about tomorrow?

Definition 4: A sensor is a calibrated device that can measure something, has known response curve across the full range of its measurement, and is both accurate and precise in a repeatable manner.

If I measure my freezing cold water today, and the thermometer reads 0... that seems great! Tomorrow, I make an ice bath, and it reads 3. The day after, another ice bath, and it reads -4. Over the course of a month, it reads... apparently random values between -5 and +5. It turns out my thermometer is accurate.

If I measure my freezing cold water today, and the thermometer reads 3... that's... close, but not what I expected. Tomorrow, I do the experiment again, and get a 3. In fact, every day, I get a 3. We would say that my thermometer is precise, but not accurate.

For my thermometer to be useful, I need to be able to put it in the freezing water bath, and every day I need to get a 0. That would mean it was accurate and precise.

Is it a "temperature sensor" or a "temperature estimator"?

Let's say I stick my highly accurate, precise thermometer to the wall in my living room. It tells me it is 72 degrees.

Is it... 72 degrees in the bathroom?

Is it... 72 degrees in my bedroom upstairs?

Is it... 72 degrees in the basement?

The answer to all of those questions is "I don't know." The problem with temperature is that it is essentially a point measurement; the thermometer is telling me the temperature in just one place. I would need many thermometers in each room, and measurements from multiple rooms, to have a comprehensive picture of what the temperature was everywhere in my house.

This is important to note, because we're accustomed to thinking about sensing the environment in an absolute way. "The thermometer says it is 72 degrees" is a fact. For every-day purposes, it is enough to know whether or not we should put on a sweater. But, if we're interested in understanding the thermal environment of the home... a single temperature sensor is not enough. The single sensor is an estimator in terms of the overall temperature in the house.

We highlight this, because estimating the number of wifi devices in a library is a similar problem.

What is radio?

Get in your car and turn on National Public Radio. That's radio.

Radio is more complex than thermometers, and it turns out that thermometers were pretty complex. The point we want to make about radio is that it is something broadcast, invisibly, through the air. Somewhere, there's a radio transmitter (the radio station), and you have a radio receiver in your car ("the radio").

Sometimes, the signal is strong. Sometimes it is scratchy, or "weak." The important thing to remember is that "radio" is a physical phenomenon, and if it is stormy, or if you drive your car into a parking garage, you can impact your ability of your radio receiver ("the radio") to receive the transmissions from the station clearly.

And, remember: you can drive around, and you still can listen to NPR, because NPR is broadcasting it's signal far and wide. Note the word "broadcast..."

What is wifi?

Wifi is NPR for computers. A phone that is browsing the web on wifi is both transmitting (when it asks for a web page, or a funny cat video) and receiving (when the funny cat picture appears on the screen).

Those wifi signals are not straight lines. Your phone, when it asks for a funny cat picture, is broadcasting that request. When the video is sent back, the wifi access point is broadcasting the data for that video. The only reason everyone around you does not get the same cat video is because there's a lot of very complex encryption and routing happening that we're not going to talk about.

What we are going to talk about is the fact that every wifi device is, generally speaking, constantly broadcasting a "hello" to the world around it. This is because your phone is trying to find a way to connect to the internet... probably because your phone thinks the cat videos are funny, too. (Your phone doesn't think. That was just humor.)

The fact that wifi devices are constantly saying "hello" to the world around them is important if you're building a wifi sensor.

What is a wifi sensor?

We've built a device that listens for the "hello" messages that wifi devices are constantly sending into the world around them.

When we see a "hello" from a given device, we make note of it.

If we see that "hello" again a few minutes later, we say "oh, they're saying hello again." We note the time.

Eventually, the day ends. We have a whole bunch of "salutations" (the first time a device says hello) and "farewells" (which, really, are when we stop seeing hellos... there's no explicit goodbye). Our sensor then packages those up and ships them off. It doesn't report anything about who said "hello" or "goodbye." It just says "I saw someone around here from 12:30 to 12:45."

What is a wifi estimator?

Remember, wifi is radio. Therefore, if we're "sensing" wifi signals... someone might put their phone in their pocket, and wander into the bathroom. The bathroom might be far away from the sensor, and there might be multiple, thick, concrete walls between the sensor and the bathroom. As a result, we might stop seeing the phone for a bit.

Or, some devices might not say "hello." People sometimes turn that feature off.

Or, some devices might change how they identify themselves when they say "hello." Some devices do this.

All of these things are why we cannot say that we've designed anything more than an estimator. Our sensor isn't perfect.

How good is a wifi estimator?

We know from our initial experiments that our wifi estimator is telling a meaningful story.

Our current experiments will help us determine how accurate and precise the estimator is. We will do this by comparing the data from one sensor against another (within a single library and between libraries) as well as compare the estimator's data against other sensors in the library (for example, against a door counter, or an intentional manual counting process).

We would not be doing the experiment if we did not think it had value. Our next phase will tell us a great deal about the sensors, help shape updates to the hardware and code, and tell us if there is value in scaling and conducting further experiments, or if we should call the experiment a bust.