Photoresistor delay - Page 1
Forum section: electronics / beginners

author: kovrob
author_rank: Newbie
timestamp: December 01, 2023, 06:49:41 pm
content: Hello! I have an XH-M131 type photoresistor relay module, which otherwise works well, but I would like to delay the on and off time so that it is not disturbed by possible short-term flashes at night or short periods of darkness during the day. For now, I have decided to connect a capacitor in parallel in front of the photoresistor for its output. As far as I know, there should also be a resistor in series with the capacitor. Does anyone have an idea how to solve this? I just want a delay of a few seconds

author: RJSV
author_rank: Super Contributor
timestamp: December 01, 2023, 07:19:11 pm
content: Your delay time, say 3 seconds, is a loooooong time, in electrical terms. I looked at a couple of videos it looks like a useful module, including an AC Mains relay.Obviously (I hope) you mean a 'delay' right at the sensor end but would be helpful to see or describe in more detail. But I believe any practical delay wouldn't be more than a fraction of a second...like 400 milli seconds.So in theory you might be able to get it to ignore the really fast stuff going on, the requirement to 'ignore' longer dark periods is likely going to need a processor, with code written to have the long delays.But that's part of it, you also need to consider that the (lethal !!!) AC Mains relay output doesn't lend itself to additional delay...circuit would have to operate using AC 240 Volts in and out.You might be able to trick up a custom Arduino or other processor to manipulate the LDR input (that's light dependant resistor), and supply an input to the XH-M131 according to your wishes, but by that time that's a lot ofwork ! Essentially the processor output would mimic a LDR sensor (resistance) so the XH-M131 thinks it's an LDR.

author: Zero999
author_rank: Super Contributor
timestamp: December 01, 2023, 07:22:18 pm
content: It's a bit difficult without the schematic. I Googled and found different possible schematics for the XH-M131. Some use the LM393 and others the NE555.A capacitor across the photoresistor will do, but to ideally, you need to reverse engineer it. What IC does it use?

author: Jwillis
author_rank: Super Contributor
timestamp: December 02, 2023, 12:15:14 am
content: I' have not come across any XH-M131 Modules with 555 timers. The only ones I have are LM393. The only others that are marketed as XH-M131 are actually HCW-417 and they have a LM339 and a CD4541 used for a delay timer. If you have a XH-M131 with the LM393, putting a cap in parallel with the LDR will delay the ON time but not the Off time. The time delay is 47uF per second . 100uF is about 2 seconds. Resistor in series won't change Off delay, only the On delay. To high of a resistor and the unit won't switch because the LDR becomes ineffective.

author: kovrob
author_rank: Newbie
timestamp: December 02, 2023, 08:04:22 am
content: Thank you for your answers. I have a unit with LM393, it seems. Currently, a 2200 uF capacitor is connected in parallel and the switch-on takes place with a delay of about 3 seconds. I also tried a 470 uF capacitor, but that only got about 1 second. In this video, it also works with a smaller capacitor. I don't understand why I had to use such a large capacity.https://youtu.be/B_YgOITXyM8?si=mn9DNoYusKLaPTdM

author: Zero999
author_rank: Super Contributor
timestamp: December 02, 2023, 05:34:53 pm
content: It turns out there are different configurations of the LM393 in the XH-M131.The reason for the large capacitor is because the RC time constant requires a large value resistor and capacitor to produce a long delay. In your case, you don't know what R is.https://en.wikipedia.org/wiki/RC_time_constant?useskin=vectorThe photoresistor will be connected as a potential divider with another resistance, which might be a single fixed resistor, or a variable resistor and fixed resistor in series. The comparator will compare the output voltage to another potential divider.Here's an example of a dark detector circuit I designed, which just switches an LED.The R element in the RC circuit will be equal to the values of the series resistance and photoresistor in parallel.Here's a modification which will slow it down and not require a huge capacitor. To implement it, you need to know how the photoresistor is connected to the potential divider circuit. The only way is to look at the PCB and LM393 data sheet.

author: DavidAlfa
author_rank: Super Contributor
timestamp: December 02, 2023, 05:40:30 pm
content: And that's when you start going MCU instead adding 30 analog parts and fine-tweaking, makes things specially simple for timers.

author: kovrob
author_rank: Newbie
timestamp: December 02, 2023, 08:18:21 pm
content: I want it to not switch on and off erratically at dusk/dawn because it will be in a 12 volt outdoor fixture, I only thought of the delay so that the flashes at night wouldn't bother it. In the meantime, I found a wiring diagram for the module. The only expectation would be that when it gets dark, it turns on, and when it gets light, it turns off, and it doesn't flash at the border.

author: DavidAlfa
author_rank: Super Contributor
timestamp: December 02, 2023, 09:08:57 pm
content: Then you only need hysteresis.

author: Zero999
author_rank: Super Contributor
timestamp: December 02, 2023, 09:57:25 pm
content: Quote from: DavidAlfa on December 02, 2023, 05:40:30 pmIf it's just a few seconds' delay, then an MCU won't gain much.Quote from: DavidAlfa on December 02, 2023, 09:08:57 pmThat circuit already has hysteresis.Quote from: kovrob on December 02, 2023, 08:18:21 pmAre you sure that's the correct schematic?I found a Russian seller with this schematic.

author: Jwillis
author_rank: Super Contributor
timestamp: December 02, 2023, 11:11:39 pm
content: Quote from: kovrob on December 02, 2023, 08:04:22 amThe LDR that was supplied didn't work as it turned out to be far to high resistance . Lower resistance in bright light is around 2.5M ohms. It didn't matter where the sensitivity was set, the module wouldn't work. I switched it out for a5539 LDRwhich has around a 50K in bright light. I used the screen of my laptop as a reference light source. I don't have a Lux meter to do a proper measurement. Measurement should be made at 10LUX.Best guess is your LDR is probably different. That would explain the difference in capacitor value.I'll try to sketch up a schematic. At a glance, it looks nothing like the Russian version Zero999 presented but more like the design Zero999 made. The Russian schematic has no hysteresis where as the modules have 100K resistor (104) between pin 1 and pin 3. Changing the hysteresis to much will cause the relay to chatter.

author: Jwillis
author_rank: Super Contributor
timestamp: December 03, 2023, 03:56:20 am
content: I put together the schematic for the XH-M131

author: kovrob
author_rank: Newbie
timestamp: December 03, 2023, 08:44:02 am
content: If I change the value of resistor R7 to a lower value, will that help the relay to switch more stably at the light limit?I want definite switching, but I don't know if it requires low or high hysteresis? High hysteresis low resistance, low hysteresis high resistance? (between pins 1 and 3 of comparator)

author: Zero999
author_rank: Super Contributor
timestamp: December 03, 2023, 08:48:06 pm
content: More hysteresis will help, but I would recommend increasing the value of R4, rather than reducing R7. Try 10k, but it won't introduce much a delay, but it will increase the stability.For a much longer delay, the only way to avoid a large capacitor is to add a resistor, as well as the capacitor, which would require cutting a track.

author: BeBuLamar
author_rank: Super Contributor
timestamp: December 03, 2023, 10:21:35 pm
content: Use 2 of the boards. One set for high level of light and the other for lower level of light. Use the output relays of one to turn on and latch a third relay and the other to unlatch the relay. That way you can have the hyterisis very large.

author: Jwillis
author_rank: Super Contributor
timestamp: December 04, 2023, 04:03:01 am
content: Quote from: Zero999 on December 03, 2023, 08:48:06 pmYou'll have to make a correction to D4. It didn't make sense to me that it would be a zener. Further investigation of code B3 brings up a Schottky MBR0530T1G, which makes more sense.Would you agree?

author: Terry Bites
author_rank: Super Contributor
timestamp: December 04, 2023, 11:08:34 am
content: Use a 555 mono as a "digital filter". It will ignore all inputs shorter than 1.1*C1*R1C1*R1 sets the delay on. Use a pot to set the trigger "on" to the 555 threshold @ 2/3 Vcc.An optional pnp can be used to get an active high output.If you're using a VCC<5V, then a 7555 will be a better choice.

author: Ian.M
author_rank: Super Contributor
timestamp: December 04, 2023, 11:35:01 am
content: A delay wont help. If the sensor 'sees' the controlled light, even via its reflection off the area it illuminates, it will pulse due to optical feedback unless the difference in sensor illumination due to the light is less than the hysteresis band. Adding a delay will simply change the pulse rate.The only reliable fix for this is to carefully shield the sensor from the light so there is no line of sight between it and the area illuminated. This is very difficult to do indoors. Outside, simply put the sensor in a black tube aimed at the sky, though that will still fail during fog conditions due to backscatter if the sensor is anywhere near the light.If you cant prevent optical feedback, your only cheap and easy option would be to use two sensor boards and a third relay to implement separate setpoints for On and Off to get enough hysteresis to swamp the optical feedback as BeBuLamar suggests in #14 above.Anyone interested in hacking the board to add delay should consider using the spare OPAMP as a unit gain buffer after it to allow a much higher value timing resistor, and prevent the hysteresis feedback interacting with the timing capacitor.

author: Zero999
author_rank: Super Contributor
timestamp: December 04, 2023, 06:31:53 pm
content: Quote from: Jwillis on December 04, 2023, 04:03:01 amYes, D4 is just there for reverse polarity protection. It can even be plain old silicon if the extra voltage drop isn't an issue.

author: kovrob
author_rank: Newbie
timestamp: December 04, 2023, 09:23:18 pm
content: Thanks to everyone for the help and ideas so far. I had to realize that this device is not suitable for automatic control of the outdoor lamp, because it is not a twilight switch, just a simple static light sensor. The circuit does not have any processing time, it reacts immediately to even the smallest change and thus the relay often wobbles on the limit. I will stick with the traditional twilight switch, which will operate a 12V power LED lamp with a current and voltage generator electronics, through a power supply, which will be switched on by the twilight switch.

author: liaifat85
author_rank: Regular Contributor
timestamp: January 02, 2024, 03:45:13 pm
content: As an alternative, you can consider this design too. This is an Automatic Light Control System with Arduino and an LDR Sensor:https://www.jakelectronics.com/solution/automatic-light-control-system-with-arduino-ldr-sensor