Just testing out what I have learned. If I got it wrong let me know.
This circuit is has one very large difference, and that changes things.
For the ULN2004 circuit, I pointed out that the calculations were based on an approximation, that the transition level of the gate was approximately equal to 0.63 x capacitor's maximum voltage when fully charged. this made the time period equal to approximately 1 time constant. That is not the case here.
For this circuit, the "transition level" of the 2N7000 transistor (the gate voltage at which the drain starts to go low) is the transistor's threshold voltage Vth. For this transistor it is approx. 2 V, while for the ULN2004 it is approx. 5 V.
The charging curve for an R-C circuit is exponential - the greater the charge, the more slowly it increases. In this circuit the max capacitor voltage is 12 V, but the Vth is only 2 V, so all of the action happens way down on the charging curve, where the graph is exponentially linear rather than exponential. This is good for me because I'm lazy.
Enter another approximation. As the voltage across the capacitor changes, so does the voltage across the resistor. As the cap voltage increases, the resistor voltage decreases. The two voltages are in series, so they always add up to Vcc; as one goes up, the other goes down. Because the voltage change across the cap is such a small percentage of Vcc, the voltage change across the resistor also changes very little. An almost constant voltage across a resistor produces an almost constant current. AND (the good part) the equation for a capacitor being charged by a constant current is *not* exponential; it is linear.
EC=it > E x C = i x t
E - voltage change across the capacitor
C - capacitor value in farads
i - charging current
t - time
In the region of interest, the voltage changes from 0 V to 2 V. The average is 1 V. This leaves 11 V (average) across the resistor. Using Ohm's Law, the current through a 330 K resistor is 33 uA. The max turn-on delay time is 5 seconds, so we have everything needed to calculate the capacitor value.
EC = it
C = ( i x t ) / E = ( 0.000033 x 5 ) / 1 = 0.0001667 F = 167 uF
The actual drain current needed for the SSR is around 5 mA, which acts to decrease the capacitor size need for the delay, so my first estimate was that 100 uF would be closer than 220 uF as a starting value.
The sensor switches the R1-R2 node directly to Vcc, so R2 has no effect on the ON delay time. For the off delay time, R1 and R2 are in series, discharging the capacitor from 12 V down to 2 V, at which point the transistor and the relay turn off. Now we are back to the exponential equation. We are discharging from 12 v to 2 V, or from 100% to 16.7% (2 / 12). this is a change of 83.3%. Now, the good news. If you crank that exponential equation, you'll find that while the voltage change across a cap is 63% in one time constant, it is 86% in two time constants. In ak land that is close enough for a first approximation.
R1 + R3 = 1.33 M = 1,330,000 ohms
C = 100 uF = 0.0001 F
2 x R x C = a huge mistake.
In post #45, I completely missed that the cap keeps charging up after the transistor has turned on, and that the discharge time is way longer than the charge time. Even if R2 were 0 ohms, meaning the sensor somehow connected the left side of R1 directly to GND for the turn-off timer, the turn off delay would be 1 minute.
oopsy
OK, I can fix this. The solution is to add a 5.1 V zener diode across the cap to keep it from charging all the way up to 12 V, and change both R1 and R2 to 47 K. I'll revise the schematic later today. Decent weather - leaves and lights.
ak