I want to use ESP32 in my truck to control RGB LED lights making sequences. I am going to use the STOP and TURN signals (12V) to send them to ESP32. The question is if I can use a voltage regulator 12v to 3v and connect it to the ESP32 module in an INPUT pin to start the sequence because the voltage in my truck goes from 14.7v to 12v. Thanks for your help.
Use a voltage divider, it's cheaper And if you want to separate the 3.3V and 12V completely, use an optocoupler.
Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project See About the Installation & Troubleshooting category.
You're using a voltage divider for the STOP signal; why not use one for the turn signal?
Thank you for your answer. like a zener is better?
I just showed in that squematic the options.
Excellent advice.
Forget about voltage regulators and zener diodes.
Leo..
The problem is the PCB must be very small and the optocoupler is big. Also the voltage difference is from 14.7 volts to 12 volts and the LED inside the optocoupler will receive that difference
Thank you so much for your help.
An smd PC817 is 4.5mm x 6.5mm. I can't change that.
It seems you don't understand opto couplers (yet).
The opto transistor connects to I/O pin and processor ground (emitter to ground).
Enable the internal pull up on the pin.
pinMode(signalPin, INPUT_PULLUP);
The opto LED, with 1k current limiting resistor, connects to turn/stop and car ground.
Watch LED polarity.
The LED is just a (1.2volt) LED.
The resistor in series with the LED takes care of the voltage difference.
With the right resistor, you can light a LED at any supply voltage.
Leo..
You are right I have never worked with optocouplers yet. I tought the resistor give exact voltage to the led to light and if the voltage goes up maybe the led can get damaged.
Automotive signals are notoriously electrically noisy with voltage spikes and RF noise. The use of an optocoupler will go a long way to isolate these signals from your ESP32.
The resistor controls (limits) the current to the LED.
The 1k resistor I recommended for this limits LED current to ~1.2mA on a 12volt battery and ~2.4mA on a 24volt battery. Both are well below the max current of an opto coupler LED.
Leo..
Thanks for the advice
Got it. Then I will use an optocupler. Thanks
The PC817 can be use it in high-side and low-side?
An opto coupler has two fully independent parts, a LED and a transistor,
and one or both can be used high-side or low-side.
If you connect the transistor as I explained, then you won't have to use an external pull up/down resistor. For the LED it doesn't matter how you use it.
Leo..
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.