Lab Overview

In this lab we’re going to build a simple and practical circuit to read a resistive sensor. Our sensor will be a photoresistor which will measure the amount of light available, but the steps and process are the same no matter what kind of resistive sensor is used.


To do this lab, you’ll need the following new items:

Item Approximate Cost (USD)
Photoresistor <$1
Netduino $25 - $70

Additionally, you’ll reuse the following tools and components from earlier labs:

  • Multimeter
  • Half size breadboard
  • Resistor Kit
  • Breadboard jumper wires
  • Wire cutter (optional, for trimming resistors)

Component Sourcing

To build a photoresistor sensor circuit, we need to start with a photoresistor. Photoresistors usually look something like the following, and can usually be sourced for less than USD$1:

There are several major component supply websites that serve the majority of the world. The most common ones we use are:


Components usually have a datasheet that describes their characteristics and they will often give sample circuits that describe how to wire them up. When building circuits, a lot of time is actually spent looking at datasheets to understand the behavior of various components and how to connect them together. Manufacturers want people to use their components, so it’s in their best interest to provide good documentation and schematics to make them easier to use. Datasheets are usually easy to find; simply searching on Google for the part number + “datasheet” will often turn up a PDF datasheet.

In the case of my photoresistor, I found it in a pile of components, so I’m not sure if it conforms to the values in the above datasheet, since I’m not sure it’s the same component. That’s not a problem, however, with a simple resistive sensor like this because I can just measure the resistance with a multimeter under varying conditions to determine its characteristics.

Resistive Sensors

There is a class of sensors, called resistive sensors, that have a variable resistance based on various input such as light or heat. Photoresistors, for instance, provide less resistance the more light that they receive. Similarly, thermistors change their resistance (either more resistance or less resistance, depending on the type), as their temperature changes.

Resistance can’t be measured directly with a Netduino, but voltage can be measured by the Analog to Digital Converter (ADC) via the analog input pins. By placing a resistive sensor in a voltage divider with another resistor of known value, we can measure the voltage output and use Ohm’s law to calculate the resistance of the resistive sensor.

The following circuit schematic is the exact same as our voltage divider from before, except now, R2 is a resistive sensor, in this case, it’s a photoresistor:

Exercise 1 - Reading a Resistive Sensor

Step 1: Measure the photoresistor resistance in various light conditions.

To measure the resistance of a photoresistor, set the multimeter to its resistance measurement setting, which is usually denoted by the ohm (Ω) symbol, and put the multimeter leads on each of the photoresistor leads. It might be helpful to put the photoresistor in a breadboard to keep it still:

If using a breadboard, make sure each leg of the photoresistor is on opposite sides of the center well (or on different rows), so the legs aren’t connected.

I measured the resistance of my photoresistor in varying light conditions and came up with the following ranges:

Luminance Resistance Range
Bright Light <= ~1kΩ
Room Light ~1kΩ - ~75kΩ
Darkness >= 75kΩ (up to 350kΩ+)

This photoresistor is very good at detecting very little light, in fact, from the table above, most of its range is in the relative darkness. However, for my purposes, “mostly” dark is good enough, so I can ignore anything above 75kΩ.

I live in the Pacific Northwest and on a November day, sunlight is a commodity that is hard to find, so to simulate sunlight, I shone the LED from my phone on the sensor from a few inches away.

The datasheet for the Adafruit photoresistor gave a range of 200kΩ - 10kΩ, so I’m glad I measured mine.

Lab Process & Questions:

Using a multimeter in resistance measuring mode, measure your photoresistor under varying conditions. What resistance does it supply in the following conditions? Write them down:

  • Bright sunlight
  • A moderately lit room
  • When the sensor’s light collector is covered by something dark (a dark condition)

Step 2: Calculate the fixed resistor (R1) value.

Netduino has an onboard Analog to Digital Converter (ADC) that reads voltage values from 0V - 3.3V in 1,024 steps, which means it will give a value from 0 to 1023 that represents the voltage. For the best resolution therefore, we want the total resistance when it’s very bright to be near the ADC max of 3.3V. And when it’s low, it should be near 0V. This ensures that we are using the biggest range possible.

Calculating the High and Low Resistance Values of the Bottom Half of the Voltage Divider

The easiest way to select an R1 resistor is to choose a value that splits the difference between the high and low resistance threshold values of the bottom half of the voltage divider (resistive sensor and ADC). Recall that the parallel resistance of the resistive sensor and the ADC is calculated using conductance (G):

ADC Conductance = 1 / 11kΩ = 0.000091S ~= 0.0001S
Photoresistor low R/bright threshold < 1kΩ
Photoresistor high R/dark threshold > 75kΩ

Photoresistor low G = 1 / 1,000Ω = 0.001S
Photoresistor high G = 1 / 75,000Ω = 0.000013S

Total voltage divider bottom half (ADC + Photoresistor) resistance:
Low (bright) = 0.000091S + 0.001S = 0.001091S = 916Ω ~= 0.9kΩ
High (dark) = 0.00091S + 0.000013S = 0.00010391S = 9,624Ω ~= 9.6kΩ

Since these are approximations, I’ve rounded them a little to make the calculations simpler.

Choosing an R1 that Splits the Difference

Therefore, I would need an R1 that has a value halfway between 9.6kΩ and 0.9kΩ. You might be able to guess at a midpoint in your head that’s close enough, but we can also use a formula that calculates the difference between the two resistors, divides it in half, and then subtracts that from the bigger resistor:

Halfway = R2High - ((R2High - R2Low) / 2)

Halfway = 9.6kΩ - ((9.6kΩ - 0.9kΩ) / 2) = 5.3kΩ

5.3kΩ isn’t a very common resistor value, but 4.7kΩ is the closest common resistor, so I’ll start with that and calculate my expected Vout based on that in order to validate that resistor choice.

In practice, there’s no real need to do this next step; you can simply grab a resistor that is somewhere near the halfway point, put the voltage divider together and then test the resulting output under various conditions to find the threshold values that you’re happy with. However, for the purposes of understanding, I think it’s important to go through these steps.

Calculating Expected Vout

Using the voltage divider equation from before (Vout = Vs * (R2 / (R1 + R2))), and using the total parallel resistance of R2 & ADC as the new value for R2, we can calculate the expected spread of values. For example, the following calculation is for very bright resistance:

Example calculation:
Vout = Vs * ((R2 & ADC) / (R1 + R2 & ADC)) )
Bright Threshold = 3.3V * (0.9kΩ / (4.7kΩ + 0.9kΩ)) = 0.53V

Using that formula, I created the following table of values:

Light Level Threshold R1 Value Sensor Resistance (R2) R2 & ADC Resistance Total R Vin Vout
Bright 4.7k          


These docs are open source. If you find an issue, please file a bug, or send us a pull request. And if you want to contribute, we'd love that too!