blog · 18 August 2026
Sunlight and weather as circuit inputs: the LDR, the thermistor, and the Environment panel
Two sliders control the simulated world's light and temperature. Build a divider with an LDR and a thermistor, watch resistance follow the environment, and build a night light that decides for itself.
Most circuits ignore the room they are in. Sensors are the exception, and the simulator gives you the room as two sliders: with nothing selected, the Inspector shows the Environment card, temperature in °C and light in lux. Every part that physically cares reads them. Today we make two humble parts care visibly, then wire one of them up to make a decision.
The LDR: light in, resistance out
Place an LDR (it lives under Passive and is cross-listed under Inputs, and search finds it by "light sensor" too). Select it: its Inspector card shows a sun gauge, a lux slider, and a live resistance readout. Drag the slider and watch the number move: around 100 lux of indoor light it reads a few kilohms, and dropping toward darkness sends it climbing by orders of magnitude. Since the July physics work this follows a measured GL5528-class curve, so the numbers transfer to the part your kit box probably contains.
Now make it do something. On a breadboard with the Bench PSU at 5 V, build a divider: 10 kΩ fixed resistor from 5 V to a middle column, LDR from that column to ground, scope on the middle node. Bright room: the LDR is a few kilohms, the node sits low-ish. Slide toward dark: the LDR grows huge and the node climbs toward 5 V. The environment slider has become a voltage, which is the whole job description of a sensor.
The thermistor: same trick, different physics
Swap the LDR for a Thermistor (NTC) and repeat with the temperature slider. At 25 °C the catalog part reads 10 kΩ; warm the world to 50 °C and the live readout falls to about 3.6 kΩ, following the part's Beta equation. Cool it below zero and resistance triples. The divider voltage tracks accordingly.
One honest subtlety the simulator now models: a thermistor carrying current heats itself a little, so its temperature is not exactly the ambient you set. In this divider the effect is small (fractions of a degree), and the Inspector's live readout reflects the real, slightly warmed value. On the bench this same effect is why precision thermometry drives thermistors gently; your simulated one behaves the same way, which makes for a lovely extension question with the multimeter.
A night light that decides
Add a decision-maker: the LM393 comparator (Analog ICs group). Wire the LDR divider's output to IN1+ and a reference from your potentiometer's wiper (a divider with a knob, as covered earlier this week) to IN1-. The output, OUT1, drives an LED through a 330 Ω resistor. Power the chip from the 5 V rail; the LM393's output is open-collector, so give it a 10 kΩ pull-up to 5 V, this week's third appearance of the pull-up resistor and by now an old friend.
Now play. Set the reference knob mid-travel, then drag the light slider down: as the room darkens past your threshold, the LED snaps on. Slide it bright: off. Adjust the knob and the switching point moves. You have built a street-light controller, and every part of it is inspectable: probe both comparator inputs and watch the crossing happen at exactly the moment the LED changes state.
Why simulate the weather at all
Because the alternative in a classroom is a torch, a hand over the sensor, and a lot of ambient variability. The sliders make sensor lessons repeatable: everyone's room is 100 lux, everyone's threshold crossing is observable, and the write-up can quote numbers. When the class moves to physical kits, the circuit is identical and the torch becomes the fun part rather than the confounding one.
The micro:bit reads this same environment (its light and temperature APIs see your slider values), so a MicroPython night light is a natural follow-on with the code from earlier this week. Part references: docs.devoltapp.com/parts/passives for the LDR and thermistor curves, docs.devoltapp.com/parts/comparators-and-references for the LM393. Tomorrow: de:volt on a tablet, and what changes when the pointer is a finger.