I recently bought an old car with a major setback - the headlights do not start automatically.
I am used from the previous one to simply leave the light switch on and as soon as I start the ignition, the lights went on and shine.
So I was searching the internet for some hints. As usual - I found a Czech company that came with a device to do exactly as I needed - unfortunately, the company no longer operates on the market and the device is no longer in stock.
However, they had a short description - it's actually a relay, controlled by micro-controller. The micro-controller senses the voltage of the car mains and as soon as it jumps over 13V, the relay is switched and the headlights are on.
This gave me an idea - I know, that when engine is running, the voltage of the so-called "12V" is somewhere around 13.5V.
And, when the engine is off, the voltage is less than 12V, depending on the battery.
So I have an idea for a simple circuit - voltage regulator such as LP2950ACZ (5V, 100mA, 100uA iddle current), ATtiny45, voltage divider connected to pin 3, relay connected to pin 5 using 1kOhm resistor and simple NPN transistor). Of course, some diode to ensure correct polarity, fuse for the device, capacitors to survive the engine start and filtering, and so on.
I already tried the voltage measurement using the divider - I used quite high resistor values to minimize current usage - total of 1.47MOhm (1Mohm to 470kOhm).
I tested the measurements using TinyDebugSerial and I was surprised. Even when powering using 5.05V USB bus, the measurements are pretty solid and reliable. I went and tested the internal reference voltage to test auto-sensing of VCC, but that turned to be not so exact and from my perspective useless - the voltage regulator does pretty good job making 5V.
Now I am looking into additional thing - I am running the device on 8MHz because of the TinyDebugSerial.
But, I'd like to utilize some powersaving - it's enough to measure the current twice per second.
I also think about scaling down the frequency using clock divider, but I heard it's not a good idea as the programming is disabled that way.
This is just a heads-up for anyone trying to achieve the same. I'll be posting the final code and schematics, including test video