Go Down

Topic: Switching Relay with 12 Volts (Read 231 times) previous topic - next topic


Jun 19, 2018, 09:06 am Last Edit: Jun 19, 2018, 09:09 am by Mk1_Oz
I am looking to put together a baffle/damper that sits in a duct that is connected to an oil cooler on a car.  At slow speeds the baffle/damper is shut to stop airflow (oil temp too low) but at race speeds it opens to allow airflow (to cool hot oil).

I will have a temperature switch in the oil line connected to the cars 12v that will operate the cooler's fan when the oil reaches a preset temperature.  I want the arduino to open the flap when the temperature switch closes (oil is too hot).

How can an arduino do something based on the actions of a 12v switch?

My first thought was that the 12v switch can feed one side (coil) of a standard automotive relay then the arduino and its 5v can be connected to the output side - 5v from arduino is fed to a digital input pin.  Is 12v one side and 5v the other possible even?

Are there smaller and more appropriate relays to use?  I have a HK4100F-DC5V-SHG relay but cannot really understand the datasheet but I think the coil side for this one is only 5V so therefore is not suitable? https://img.ozdisan.com/ETicaret_Dosya/445413_4369639.pdf

I think this is all simple stuff.....hopefully


I'm not clear if you want your Arduino to detect the presence of a 12v signal or to control something that requires 12v to activate it.

In the first case just use a couple of resistors to make a voltage divider - say 10k and 4.7k. That should drop the 12v to 3.8v and even if the car's voltage was up at 15v the Arduino would still only see 4.8v. 3.8v will be sufficient for the Arduino to detect it as HIGH.

In the second case you can use an Arduino I/O pin to control a transistor which in turn switches the 12v circuit.

Two or three hours spent thinking and reading documentation solves most programming problems.


You can use a voltage divider to reduce the 12V signal down to 5V.  This is simply a pair of resistors. However, 12V in car circuits can be 14V+ when the engine is running, plus it is a highly noisy environment with the potential for voltage spikes that could damage the Arduino. So some extra protection for the Arduino's input pin is needed. One technique is to use a zenner diode to conduct away any excess voltage or spikes. Another technique is to use an opto-isolator. Either component will be much smaller than most relays.


Sorry for not being clear.  The car has a 12v fan installed.  When this fan operates (totally separately from the arduino) I want the arduino to open a flap.  The arduino will activate a 5v servo motor upon seeing the 12v circuit operating.

I had thought about a voltage divider but as Paul has pointed out, the voltage spikes may be of concern.  That is why I was thinking about the use of a relay to isolate the cars 12v from the arduino.  I thought that would be easier than trying to clean up the 12v signal and/or protect the arduino.


Since you are only concerned with detecting whether or not the 12V is driving the fan I would use an opto-isolator. The output of the isolator can be directly connected to an Arduino input that has an input pullup (internal or external) .


Your relay idea would work, by the way. But it's one more mechanical component to wear out. On the other hand, in the harsh environment of a race car, any components are more likely to fail.


I have just looked up info about what an opto-isolator is.  I am a little confused.  Does the 'output' side of the opto-isolator generate the current/voltage or does it act like a relay or transistor and allows a connected current to flow through it (more like a relay)?

Sounds like either a relay or opto-isolator will achieve what I need without the need to be concerned about the dirty 12v.


Jun 19, 2018, 11:38 am Last Edit: Jun 19, 2018, 11:49 am by PaulRB
You are correct about the opto-isolator. The output side is a transistor. But instead of being switched on by a current flowing into its base pin, it is switched on by exposure to infra-red light produce by the led on the input side. So there is no electrical connection between the two sides, only light.

A voltage divider with a zenner diode, for overvoltage protection, should also work


You are correct about the opto-isolator.
Thanks Paul.  However I had a bet each way regarding how the opto-isolator outputs so still not sure which is correct lol


Jun 19, 2018, 03:00 pm Last Edit: Jun 19, 2018, 03:08 pm by Mk1_Oz
OK same project but a different issue....

I want to install a temperature sender to measure the temperature of the engine oil so that I can open my oil cooler baffle/damper more as the oil temp rises.  The sender is just a resister that would change the voltage that I read on an analoge pin.  I have tried to find a suitable insulated (ie 2 wire) sender so that the arduino can run totally separately from the car power/ground.  I plan to use a buck converter to take the 12+v down to 9v (remove noise and spikes) into the arduino hence trying to keep it separate.

It appears that no suitable sender exists that is insulated AND fits into an available oil line fitting so I will most likely need to use a single wire (grounded body) sender.

Is that likely to work?  Would I just connect the ground of the arduino to the same ground as the sender?  Is it that easy?  Would doing so allow the nasty noisey car 12v electrical noise to get to the arduino?  (I of course have assumed here that when using a buck converter that the higher voltage input side will be connected to the vehicle ground but that the lower voltage side would not need to be....I might have that wrong from the start....).

Last bit, could I use a 5v feed from the arduino to power the sender?  The senders are around 18 to 323 ohm so I am not sure how much current that would draw.  280mA max? (5/18)



Most Arduino run at 5V (some at 3.3V) so if you get a buck convertor, get 12V to 5V.  No point going to 9V only to have the Arduino's regulator then have to regulate 9V down to 5V!

You will need to put a fixed resistor in series with the temp sensor/sender, so that will limit the current to a lot less than 280mA, I would hope. What temp range does the sender cover, and what level of precision do you need to measure the temp with? 1C, 0.5C, 0.1C?


Jun 20, 2018, 04:49 am Last Edit: Jun 20, 2018, 04:56 am by Mk1_Oz
I was using a 12v to 9v buck converter as I have some hall sensors (NPN) that need to run above 5v so it seemed the easiest approach to let the arduino regulator take from 9 to 5.  The arduino is only running an LCD touch screen so probably (?) not drawing too much current so the regulator should not get too hot.

I did not think about the resister to limit the current.  I will need to measure and adjust accordingly.  Need to limit to less than 20mA on a digital input pin?  If max is 20mA that implies 250 ohm (5/0.02) so if my senders lowest resistance is 18 I would need a resister of 232 ohms?  (I think I am applying ohms law correctly here...)

Temp range of the sender is 50 to 150 degrees C although the actual oil temp should not ever be above 130.  Precision is not all that important so +/- 2-4 degrees should be fine.

Go Up