We will look at how I designed a fully analog circuit whose job is to switch a fan on when the humidity in a room rises above a certain level, and to switch it off when it drops below that level. We will use a resistive humidity sensor.
⚠️ Important note about powering the sensor:
We will power the circuit from 12V DC. One important thing is that the sensor we will use, the HR202L, must not be powered with direct current. If a DC voltage is applied to it, it will be destroyed in a short time. To work correctly, it needs an AC 1.5Vpp signal.
In broad terms, we need one circuit that transforms the DC signal into an AC one for the sensor, and a circuit that switches a fan on or off depending on the sensor’s impedance. We can therefore split the project into two parts.

1. Configuring an NE555 as a pulse generator (oscillator)
The NE555 can be configured in 3 modes: Monostable (timer), Bistable (a memory of type 1 or 0, also known as a flip-flop) or Oscillator, which is the one we chose. Since the HR202L’s impedance curve is given in the datasheet at 1KHz, we will try to get as close as possible to this frequency at the oscillator output. The circuit and the output waveform look like this.

2. Protecting the sensor
I used resistors R9 and R8 to obtain a 6 V reference point from the 12 V supply. This intermediate level allows me to adapt the signal coming from the NE555 before applying it to the resistive HR202L sensor.
R5 and R13 form a voltage divider so that I have a good enough voltage across R_Var to avoid burning the sensor. R_Var will actually be a potentiometer used to adjust the sensor’s sensitivity.

3. The operational amplifier
The operational amplifier U2 (OP07) is used to process the signal obtained from the HR202L sensor. It is configured with negative feedback through resistors R10 and R11, which set the gain of the signal around the reference voltage of approximately 6 V. In this way, the voltage variations produced by changes in the sensor’s resistance are highlighted at the amplifier’s output.
The signal is then passed through C5, whose role is to block the DC component. D1 rectifies the pulses, while C4 and R4 help hold the control voltage temporarily. This avoids switching too quickly.
4. The transistor switch
Transistors Q1 and M1 work as a switch. When Q1 starts to conduct, it ties the MOSFET’s gate to ground, turning it off. When Q1 is off, M1 turns on and powers the load (that is, our fan). The voltage on Q1 is determined by the voltage divider that our sensor forms.
Thus, at a low sensor resistance (humid environment, for example 10K) the fan turns on, while at a higher resistance (drier environment, for example 30K) the fan turns off.
In the end, the routed circuit soldered on a PCB could look like this:


I used KiCAD to design the PCB.