I have so far used this relay module with my Arduino Pro Mini clone (5V, 16MHz) without a problem. However, in the course of trying to save power I have reduced clock speed to 1/256, removed the power led and used the low power lib by rocketscream. In particular after the Arduino has finished its job it powers down via LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
when I turned off the power from the whole thing and turned it back on everything was ok. The arduino would boot without a cry.
now I have added a C1815 transistor with a 4.7k resistor at its base to turn off the relay circuit completely (emitter to GND (on Arduino), collector to GND (on relay module).
and this time when I turn everything off and back on again, well, the arduino does not utter another word - for at least another minute or so.
I see three possible causes here (maybe you know another):
although the relay module seems to have a flyback diode of its own it may be necessary to add another diode in the transistor circuit for some yet unknown reason. I have measured the current though with my mulitmeter and it said 77mA (before adding the transistor it said 85 mA) and immediately after I turn the transistor off it seems to go down to 0.00 mA which may be normal in powerdown mode (afaik current goes down to 27µA or 0.027mA which my meter possibly cannot display. Still there could be a short current peak when the relay is turned off that my meter is too slow to detect
before I added a delay command before turning off the transistor I noticed that the DC motor that is controlled by the relay would turn faster in the end as if it drew more current. That vanished after I inserted a short delay (1s) between turning off the motor and turning off the transistor (that turns off the relay). Still the reboot would not work for at least a minute. so maybe the resistor I use for the transistor is too small?
the sleep mode makes the arduino sleep even after I turned off the power completely - sort of a coma state - and thus the arduino needs a couple of minutes to recover from that. And since that would not occur before the added the transistor it may be due to the fact that the transistor effectively reduces the power consumption of the arduino further more from 3.1mA to a few µA.
or... quite a different reason.
I suspect reason 1 and that is also the reason why I ask the question here instead of doing further experiments to find the cause since I don't want to blow onother arduino like when I used a 3.3V relay which allegedly has a working flyback diode but which actually doesn't do its job.
as for the clock speed: the MCU hardly does anything anyway
I suspect an hardware issue. The only possible reason for a software malfunction would be the lowpower command from which the arduino may not easily recover when it's completely powered down. As I said, code works flawlessly without the transistor (which powers down the relay and hence reduces the power consumption of the arduino to an absolute minimum
the relay consumes current (at least the red led that is always on). The only way I saw to turn it off was a transistor. No, the pins are correct, base on the side (see datasheet link above). Cheers
so I have taken the risk: I put a 10 second delay after transistor off before the powerdown and some LEDs to check if the arduino is still active. Yes, it is. So it seems to be reason 3, i.e. the powerdown command seems to put the arduino into a deep coma for about a minute where you cannot boot it anymore. Probably it needs some sort of internal reset which takes time at this low power of a few µA. Any comments on that? can it be true?
the clock reset didn't make a difference. Still about 1 minute of coma. Yep that last pic is the same like my hand-drawn
edit: except pin 4 and GND which I got swapped in the image (got it right in actual circuit)
edit2: I just noticed: that's what you meant with mixed up pins, thought you meant the transistor pins as the base pin is not in the "usual" middle position. I was lucky to use the correct pinout since there are also wrong pinouts for the C1815 on the net.
I think it's really the lowpower.powerdown function that causes the issue. Just found out that after pressing the reset button the arduino will turn on immediately. So the time that passes during which the MCU doesn't come back on its own is probably the time needed for the board to do its own "reset" before it can be used again.
Plus a warning to everyone who wants to use the function: don't execute it right at the beginning of your sketch, i.e. right on start-up or just after a few seconds. If you do that there will be no time to upload a new sketch as the MCU will already be in sleep (or rather "coma") mode.
I was lucky I had about 40 seconds after which the function was executed - just enough time for a new sketch to upload. There are certainly methods to circumvent this problem but for newbies they will think they can trash their arduino.