Control of ESP32 with external PWM signal

Thread Starter

Dent42

Joined Sep 9, 2023
1
I am not sure how to ask this correctly, but I will try.
I am wanting to use WLED on an ESP32 to control some lights in a vehicle. The ESP32 and LEDs will be powered directly from a 12v source. ( I already have the ESP32 / WLED / LEDs working)

To turn on / off the lights the trigger will be coming from the dome light circuit. The dome lights fade on and fade off. If I use a relay that is connected to the dome light ground side, that is activated by the 12 volts that pass when the dome light is activated, this will trigger the relay that takes a pin to ground on the ESP32 that will turn on the LEDs via WLED.

So the DC signal from the dome light circuit, I assume is a PWM signal, will this operate the relay without any adverse effects on the life of the relay, and will this also make the signal out of the relay to the ESP32 a PWM signal? If so how will this effect the LEDs turning on?
I want the LEDs to have the same on / off ramp as the dome light.

Is there a more elegant way to make this happen?
Thank you for any suggestions.
 

BobTPH

Joined Jun 5, 2013
11,463
A peak detector driving a MOSFET switch could be used to activate the micro quickly (from a separate power source.)

Then you could monitor the PWW signal by dividing down the dome light power and sending it to an input in the micro. The program would duplicate the PWM signal it sees to the lights.
 
PWM usage on ESP32 with Arduino code
Choose a PWM channel (0 - 15)
Choose the PWM frequency.
Choose the resolution of the pulse width between 1 and 16 bits.
Choose the GPIO pin which will generate the PWM signal.
Assign the value of the voltage you want at the output.
 

BobTPH

Joined Jun 5, 2013
11,463
It would probably be easier in this case not to use the PWM module. You simply need to duplicate the input pin on an output pin:

C:
while(1){
   PWMout = PWMin;
}
 
Top