Nodemcu + relay

I have a nodemcu which controls a 74hc595. From the 74hc595 I have a 5v relay module that I'm going to use to power a fan with a 12v solar panel. If nothing is wired into the relay, everything works fine - the relay comes on and leds also wired to the 74hc595 work. As soon as I wire in the solar panel and fan to the relay, it runs for anywhere from 10 seconds to 2 minutes then the relay shuts off and all other leds on that shift register also shut off. The arduino continues to function. If I access the web page on the nodemcu and shut off the relay manually, then I can turn it back on and all works for a few more seconds before the shift register goes funky.

Any ideas?

Yes. Please post code and schematics.
More useful advice here: How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum

1 Like

You have two problems.

One seems to be related to how your project is powered. The second, nobody can help you if you do not provide the required information :man_shrugging:t2:

1 Like

The 74HC595 outputs cannot source the current for a relay coil. What kind of relay?

Here is the schamtic.

The circled relay with the heater currently has the fan and solar panel wired in. I was going to use the transistor pair but I wired it wrong when I soldered it so I'll have to fix that later.

I can post the code later, but essentially it just takes a value from a dht22 and if the value exceeds a set threshold, it sets pin 6 high on the shift register, which triggers the relay. Another note, all works well if I wire in a 5v fan and batteries to the relay. It seems to only be an issue with the solar panel and 12v fan

Except the relay does turn on when I don't have the solar panel and fan wired in. If I wired in a 5v fan and batteries to that relay, it works with no issue. It's the srd-05vdc-sl-c

Google can be your friend. Its easy to post links to the devices you are using.

image

It has a nominal current of 90mA and the pull-in current may be higher.

Your schematic doesnt show the power supply and there also may be a problem with the layout. (esp grounds)

One of those optoisolated ones with JD-Vcc pin and jumper?
Put a photo of your module..

As a further test, I powered the relay with a separate battery bank so that the only tie to the Arduino is via the signal pin on the relay. The relay has a 12v solar panel and 12v fan tied into the NO and com ports, with ground direct from solar panel to fan

Nice photo, unfortunately I don't see anything on the control part...

Your diagram shows the relay +5V connected to 3.3V, won't work correctly.

I modified it during testing to power the relay via a USB battery bank. So the only thing from the relay tied to the Arduino is the input pin. Unfortunately, the shift register still goes funky

Can you elaborate? If you mean wiring, the relay was ground and positive to a USB battery bank with input/signal tied to a pin on the shift register

Your diagram shows the heater connected in parallel with the relay contacts with no power supply, won't work.

Yeah that was the original plan but I decided to wire the fan to that instead. I'll do an updated diagram and post that

Of course.
I just don't see relay trigger components, not pinout, neither your wiring.
There are dozens of different relay module implementations out there, a good photo could help to identify...

Your motor is in the emitter circuit of the TIP42, don't see how that could work correctly.

OK, because the TIP42 is a PNP transistor.

+1
VCC of that relay should be connected to 5volt (IN can still be driven with the 595).
You can find 5volt on the Vin pin of the NodeMCU, assuming it's powered via USB.
Leo..

@Wawa Doesn't that make it an emitter follower? If the motor pulled the 12V supply down to 9V, what effect would that have?

Yes, but the base is pulled (almost) to ground with the 2N2222. That leaves about 0.7volt on the emitter (BE diode drop), which leaves "VCC - 0.7volt" for the motor.
Maybe the "upside-down" version with an NPN power transistor is easier to understand. Try to see Q1 as a switch (with < 0.2volt across CE).
Leo..