# How do sensors work in terms of analog/digital signals?

I've been learning more about electronics (specifically, analog and digital signals.) From what I understand, the "real-world" is analog and analog signals are continuous. Conversely, digital signals are discrete and take on a finite set of values (usually 2.)

What I'm having trouble understanding is how a temperature sensor can be either analog or digital. Given the nature of temperature values (can be almost any value), wouldn't these sensors have to be analog?

I looked at an explanation here. Based on the top-commenter's answer at a high-level overview, I'm thinking that a digital temperature sensor captures analog temperature data, converts it to digital (based on the sampling theorem,) and then outputs that value.

Is my intuition here correct? If not, how do these sensors work in terms of analog/digital signals?

• The sensor itself is analog. Its readings can be digitized. That is the analog value will be converted into a binary number and sent out as a sequence of zeros and ones. So yes, your undertanding seem to be correct. Jun 24, 2021 at 17:22

digital signals are discrete and take on a finite set of values (usually 2.)

There's two different meanings of "digital signal." One is a logic signal on a wire connecting the output of one logic gate to the input of another. Those signals, in reality, are analog; but we hope that they will stay pretty close most of the time to either of two values that we call "high/low," "1/0," "true/false," etc. The other kind of digital signal comes from the realm of digital signal processing. It's a sequence of numbers representing so-called samples of the value of some analog signal at different points in time.

Given the nature of temperature values..., wouldn't these sensors have to be analog?

Your "digital" temperature sensor probably is more than just a sensor. It probably contains a sensor that outputs an analog signal, and then it probably also contains an analog to digital converter that turns the analog temperature signal into a stream of numbers.

The stream of numbers is only meaningful if it can somehow be delivered to a computer, so your "digital" temperature sensor probably also contains some tiny bit of computing hardware that helps to implement a communication protocol of some kind that a computer system or a microcontroller can talk to.

• There's two ways to convert analog to digital, though, and a '555 timer for a joystick port does the conversion... but not to a 'stream of numbers'. Jun 24, 2021 at 22:13
• @Whit3rd, Funny you should mention 555 and joystick, because way back when I was in school, I designed and built a circuit to interface an analog joystick to my little brother's TRS-80 computer. The thing is, even though the hardware that I built did nothing more than output a waveform to the computer's "cassette" port with timings that reflected the position of the joystick, that still was part of a process that ultimately converted the joystick input to a stream of numbers--a "digital signal" in the second sense that I described in the answer, above. Jun 25, 2021 at 12:04
• The waveform meant nothing to my little brother. He wanted the stream of numbers for the "game" that he wrote. It's a fairly common trope in electronics design to use a combination of hardware and software to do a job more economically than could be done by using only dedicated hardware. Jun 25, 2021 at 12:07

What I'm having trouble understanding is how a temperature sensor can be either analog or digital. Given the nature of temperature values (can be almost any value), wouldn't these sensors have to be analog?

They are mostly all analog in the beginning depending on the sensor (you can turn just about anything into a temperature sensor, including digital clocks and oscillators). But in general the commercial digital sensors have an ADC (analog to digital converter) that converts the voltage or current from a sensor (thermistor or RTD) to a digital value. The digital value usually represents a voltage and will also need to be convted to it's physical value (in the case of a digital temperature sensor, a voltage to temperature conversion). All of this can be packaged in one small tiny chip.

On the flip side if you can't get a commercially available chip/IC with the specs you need, then you'll have to wire up your own sensor to an ADC (which usually measures voltage) and then convert the digital value of the ADC (digital representation of volts) to a physical value with an equation.

At some point almost every sensor ends up outputting a voltage which gets measured then converted to a meaningful physical value.

Here is an example of an accelerator (simmilar designs are found in almost every smartwatch and smartphone). It shows the sensors, the ADC and other digital functions that can help get the data to a computer/microcontroller.

An a simmilar thing with a digital temperature sensor:

As shown near the end of this 5 minute video when Galileo rolled balls down a ramp he noticed that the increase of speed was continuous, however, he had to measure the discrete position of the ball at discrete points of time:

https://youtu.be/ZBr8Q2ROX9s

Galileo knew that position, time, and speed have properties that we now refer to as "continuous variables" however he could only take discrete measurements and he could only apply the math of finite differences. Today we might say that Galileo normalized values by defining time = 1 and position = 1 for a particular experiment and then he took more samples or discrete measurements of time when the position = 4, position = 9, position = 16, etc.

Today we automate sensor measurements using sample and hold circuits and other methods to convert continuous variables into discrete time representations.

Discrete models are considered to be approximate representations of continuous systems. The Calculus was invented to develop exact representations of some continuous systems. We can easily convert Galileo's discrete model for a ball rolling down a ramp into a continuous model with an exact solution using the methods developed that we call the Calculus. However we cannot measure the time or speed of a ball rolling down a ramp without assigning a discrete number value and unit of measure. Therefore our measurements have limitations as discrete events with limits of accuracy and precision.

Digital values are representations of discrete number values in terms of a data scheme such as integer format or floating point arithmetic. When taken from sensors these measurements are called "samples". Ironically the models applied in modern digital computers are only more sophisticated approximations using the math of finite differences known to Galileo.

If the output of the sensor is a voltage or a current, then it is analog. If the output of the sensor is digital (for example sent over SPI or I2C bus) then it is digital. This is what the terms mean in practice.

Conceptually, the key difference between digital and analog is that digital is discrete, and analog is continuously variable. "Discrete" means that there are a finite number of possible values.

If an analog sensor puts out a signal from 0 to 5 volts, there are an infinite number of possibilities between 0 and 5 V.

But if an I2C temp sensor sends a 16 bit digital representation of the temperature to a microprocessor, then that is discrete, meaning that there are a finite number (65536 to be exact) number of possible values.

The two sensors may have the same range (say 0C to 100C) but one is digital (finite number of possible outputs) and the other is analog (infinite number of outputs).