Using an Arduino Nano to power 12v relay?

Hi all,

Just wondering some general advice.

I'm looking to do a project for my car (2019 Toyota RAV4) - I want to fit some lights for which are only able to activate when the car is going under 5mph. I am already using a CANBUS reader but this only outputs the speed in Hz, with 4 Hz per 1 mph.

I've done some research and it seems I can use an Aruindo nano, with:

  • a voltage divider coming off the CANBUS reader into the Ardunio nano, taking it from 12v to 5v
  • Arduino nano wired up on the Hardware interupt (Pin D2 if I recall). Then coded to count the pulses.
  • Along as the counted pulses are below Hz (5 mph x 4 Hz = 20 Hz) then it should provide power to pin D8.

Here it where I would like advice - I need to power a 12v relay (which would have 1-2 amps passing through it), but I know the Arduino has neither the voltage nor the current to do so, and even using a buck converter would not have the current needed:

Could I use an octocoupler relay for this? or what would be the best rely method? - I've read about MOSFET's but don't fully understand how they work

Considering the D8 Pin is only able to output 40mA/5 volt at most, what would I need inbetween to power the 12v relay (which I think needs 200mA-ish to activate).

Many thanks,

There are relays and there are relay modules. Post some documentation telling exactly what You've got.

MOSFETS work as a switch in your case. Either on or off. By the way, you MUST know the current necessary to operate you relay. That current will pass through your mosfet and must be within it’s rating. Does your automobile have an electrical system? Use it.

You can buy relay modules with opto-isolated inputs that run on external power, only needs signal from a controller. I have seen 8 and 16 relay boards advertised.

Power FETs have gotten cheap in bulk, you did say 12V but how many Amps?

Not quite true. You won't get 5V if you draw 40mA, it will be less, and you should never try to draw anywhere close to that value. 20mA is recommended.

You can use one of these modules to operate the relay:

OR

Hi Railroader,

Thank you for the reply - I haven't actually brought anything/fully planned anything yet as I'm still trying to understand the best layout method.

It's mainly how can I get the D8 pin out put to power a 12v relay. I.e Do I need an optocoupler inbetween

Hi,

Lots of info. online. Ask: Arduino to drive 12 volt relay.

Good luck………..

Really, you CAN’T! An automotive relay takes way too much current.

One more time, you can get relay modules than use external power to switch the relay(s) on signal level HIGH from even 3V control.

You can switch 12V or more using 5V to trigger a transistor to run a relay or just to supply 12V. I’ve switched 12V through BJTs for less power and FETs for more… my IRLZ44N’s are good to 60V at about 15A with a lot of heatsink or for a very short time.

I would use a relay to switch AC as in house power. Solid State Relays cost enough that I’d go with the relay if repeated fast switching is not needed.. relays get hot when clik-clik-clikkety-clik.

Operating your load is not hard to do, an inexpensive module such as this which can be driven directly from the Arduino where the relay coil power comes from the 12V source: It is isolated with an opto coupler from the 12V system:

Also be aware the 12V automotive electrical system is extremely nasty for electronics, excluding the ambient conditions which make it worse. Here is some interesting reading that may help:

Valuable Resources for Automotive Electronics:

  1. STMicroelectronics Application Note AN2689:
    This application note provides guidelines on protecting automotive electronics from electrical hazards, focusing on design and component selection. Reading this will greatly enhance your understanding of automotive circuit protection.
    Read AN2689

  2. Analog Devices: Automotive Electronics Design:
    This article distills key insights into designing automotive electronics, offering practical advice for engineers.
    Read the article

  3. Diodes Incorporated: Transient Voltage Suppression in Automotive:
    Learn about techniques to protect automotive circuits from transient voltage, which is critical for ensuring reliable operation in harsh conditions.
    Read the article

  4. AEC-100 Standards Webinar:
    This webinar from Monolithic Power Systems provides a detailed overview of AEC standards, essential for understanding automotive electronics requirements.
    Watch the webinar

  5. Understanding Automotive Electronics, An Engineering Perspective by William B. Ribbens:
    This comprehensive book offers an in-depth look into automotive electronics from an engineering perspective, making it an invaluable resource.
    Access the book

  6. Check this for OBD ISO9141 Code Meaning & How To Fix OBD negotation initialization procedure https://cdn.standards.iteh.ai/samples/16738/20ff360c25c6462b811ebc0c9256eee0/ISO-9141-2-1994.pdf Then there is GitHub - muki01/OBD2_K-line_Reader: OBD2 K-line Reader (ISO9141 and ISO14230) with microcontrollers like ESP32, Arduino PID codes: OBD-II PIDs - Wikipedia

  7. Load Dump and Cranking Protection for Automotiv Backlight LED Power Suppl https://www.ti.com/lit/an/snva681a/snva681a.pd

  8. Quality requirements:

I wonder how clean the power adapters for the cig lighter plug I used in the past were? The last ones had USB charge ports.

I had short range FM transmitters with MP3 source that plugged into car “power adapter” holes. Hard bumps made it cycle power.

Maybe wire a power conditioner to eliminate spikes, boost low-V and buck high-V DC efficiently.

See post #5
Very simple to do
Say if you need help connecting the modules.

Connect a resistor to D8 and a BJT (old style cheap transistor) gate and switch 12V through the BJT if you need 12V to make the relay switch — there are little boards that do this.

What I wonder is, is the 12V what the relay switches ON/OFF or does it actually take 12V to switch this relay? I have relay modules that let an Arduino switch 10A 120VAC house power, 1200W.

A transistor lets you use small power to directly control bigger power. For 200 mA 12VDC, there are many BJT’s to choose from. If you use PWM to drive the pin, the bigger power gets pulsed.

Some relay modules have user selectable opto couplers, but I don't see one on the image of post#10.
Leo..

The ones I have are, and look like the one pictured. If or if not there is an opto coupler on it the OP would have to read the description.

Golden rule, again.
Arduino does the controlling, not the powering.
There are exceptions like low power LEDs.
A transistor between board and whatever is being driven costs a lot less than a blown Arduino.

Don't trust sellers. See for yourself.
An opto coupler is a black cube with four pins.
Not to be confused with the 3-pin transistor.
There is clearly no opto on the board you pictured.
This module has one, next to the yellow jumper cap.
Leo..

Thank for the update!

Is the relay carrying 2A 12V or does the relay need that just to switch?

4 pulses per second are 250 ms apart. If a pulse comes along 240 ms since last, 5.2 MPH right there.

But suppose that there was a capacitor with a pulldown that when fed regular odometer pulses, charged up to ripple around a certain V. An opamp could compare that to a reference V and trigger the relay when it should.