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).
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:
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:
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
Analog Devices: Automotive Electronics Design:
This article distills key insights into designing automotive electronics, offering practical advice for engineers. Read the article
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
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
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
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.
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..
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.