Does the LED need a resistor in this situation? - Page 1
Forum section: electronics / projects

author: FBMinis
author_rank: Regular Contributor
timestamp: October 15, 2022, 05:42:32 pm
content: I would like to add a red LED to my project to give me a visual indication of when my PIR sensor goes HIGH (when it senses movement).Both the PIR and MCU are powered by 3.3V and the logic is also 3.3V. The output of the PIR triggers an interrupt which makes my MCU perform an action.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 15, 2022, 05:46:38 pm
content: The LED would be okay, with the resistor source in there. But the MCU won't read a valid logic level. You need a resistor divider so that the MCU gets a bit more voltage and the LED gets the rest.Tim

author: FBMinis
author_rank: Regular Contributor
timestamp: October 15, 2022, 05:51:54 pm
content: Would a 100 Ohm resistor be enough, considering there's the 1.5K there already. At 3.3V it would probably be pretty dim, no?What if I connect the PIR directly to the MCU but also to the gate of a logic level n-mosfet, which would turn the LED on?

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 15, 2022, 05:55:53 pm
content: Unless you have the output specifications of the motion sensor and know it can drive a couple of mA for turning the led on, it would be better to use a buffer to not strain the output of the motion sensor. The buffer can either be a single gate device like a SN74LVC1G125 or a small fet like the 2n7000.But if the sensor can deliver the needed current I would do like T3sl4co1l wrote. Use a small resistor (47 Ohms or so) in series to the MCU pin and another resistor like the 1.5K in your schematic in series with the led.The series resistor to the MCU input is not really needed though.

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 15, 2022, 06:01:35 pm
content: Quote from: FBMinis on October 15, 2022, 05:51:54 pmMy previous post crossed with yoursIt depends on the led you are going to use. You need to know or determine the forward voltage of it, and the current needed to have it be bright enough. Use the two values to calculate the appropriate resistor for the job.Is the 1.5K resistor a given? Is it build into an existing device and no getting around it?

author: FBMinis
author_rank: Regular Contributor
timestamp: October 15, 2022, 06:08:47 pm
content: The 1.5K is part of the sensor. It's just behind the dupont pin to which the mcu connects to.The max output current is 10mA, according to the datasheet.

author: FBMinis
author_rank: Regular Contributor
timestamp: October 15, 2022, 06:21:49 pm
content: I dont have any buffer chips but I do have some AO3400 n-channel mosfet here. Would something like this be adequate?

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 15, 2022, 06:35:44 pm
content: Yes that would do the trick.If the sensor is made for 3.3V then with the 1.5K in there the max current can only be 2.2mA

author: FBMinis
author_rank: Regular Contributor
timestamp: October 15, 2022, 06:36:54 pm
content: Ok, thank you so much for your suggestions, have a nice saturday

author: Benta
author_rank: Super Contributor
timestamp: October 15, 2022, 08:05:09 pm
content: The correct way would be to let the MCU drive the LED (IO-port). Then you'd know that the MCU has also understood the signal from the PIR.Putting annunciators on the input of a controller is bad practice.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 15, 2022, 08:57:41 pm
content: Your problem here is that the LED would need to have high enough forward voltage (Vfd) so that the MCU registers the high level as high. This will exclude typical red LEDs, which are usually close to 2V (there are exceptions). Green LEDs may or may not work. Blue LEDs have high enough Vfd in almost all cases, but many have higher Vfd than 3.3V, so that would not even light up.Point being, it will work if you carefully select the LED. And, when it works - say for a Vfd of about 2.5V-2.7V - the LED current will be < 1mA so it will be pretty dim.

author: FBMinis
author_rank: Regular Contributor
timestamp: October 15, 2022, 10:38:36 pm
content: Quote from: Benta on October 15, 2022, 08:05:09 pmIn this case, the purpose of the LED is to indicate when the sensor is working, not that the MCU is performing an action. In practical terms, the MCU will stay switched OFF while I place the device where I want it, with the LED showing how far it picks up movement and for how long the output will be high; only then I will switch the MCU ON, to send me a notification, a photo and a short video.https://github.com/jameszah/ESP32-CAM-Video-Telegram/blob/main/v9.5/ESP32-CAM-Video-Telegram_9.5/ESP32-CAM-Video-Telegram_9.5.inoThe following circuit is working fine, thank you all once more

author: Benta
author_rank: Super Contributor
timestamp: October 15, 2022, 10:49:31 pm
content: OK, didn't understand your desired functionality, sorry.Glad it's working.

author: tunk
author_rank: Super Contributor
timestamp: October 15, 2022, 11:34:19 pm
content: Ignorant question, would it work if you put e.g. an 1.5k resistor between the LED and ground?

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 16, 2022, 12:02:02 am
content: Quote from: tunk on October 15, 2022, 11:34:19 pm^^Don't need the transistor, but it works too. On the upside, can run the LED brighter, if that's helpful.Tim

author: tunk
author_rank: Super Contributor
timestamp: October 16, 2022, 12:22:52 pm
content: Quote from: T3sl4co1l on October 16, 2022, 12:02:02 amSorry, should have been more clear, I was thinking about the first hand-drawn schematic.