1
\$\begingroup\$

I'm not quite sure how to word this so I don't know how to search for it to see if there's already been an answer. I am an uber basic noob can't even draw out schematics, so sorry in advance.

I have a Raspberry Pi Zero w with a 5v relay board. Pi is supplied with 5v. The relay is connected with 5v and GND to the 5v and GND of the pi. I then have a lamp spliced into the relay to be turned on and off via the pi.

Edit


There is more to my setup. This is when the issue started happening. I put in a momentary push button. It seems like the input is extremely sensitive.


Here is my issue: If I turn on or off the exhaust fan in the bathroom (for example) or if I turn on a hair dryer or another fan, it will turn on the lamp. It doesn't happen all the time. I assume it is some kind of surge. I just can't quite figure out how to make sure that doesn't happen.

I've tried adding resistors, but that didn't. I'm not sure if this is a capacitor thing.. That's about the time I realized I have no idea what I'm doing and so I figured i'd ask!

Edit #2


Ok, I did by best to draw up a schematic using fritzing. enter image description here

Here is a picture enter image description here


EDIT 3 And fix*

I accidentally my raspberry pi and caused it unsafe power off which corrupted the SD card. I had an ESP8266 laying around that I decided to use instead. The issue was indeed a floating state as I had the same issue with the ESP. Using a 10k resistor to ground fixed the issue. Also, using the ESP8266 is MUCH better for this application than the rPi!!

\$\endgroup\$
4
  • \$\begingroup\$ Your problem is the same as discussed here. GPIO on the RPi Zero is 3.3V, not 5V, so cannot reliably switch your 5V relay module. \$\endgroup\$
    – Jules
    Jun 3, 2018 at 2:41
  • \$\begingroup\$ That doesn't seem accurate because I am able to switch on and off the relay any time reliably. I had the same issue as the person in that post (I happen to be using the same relay). I solved that issue by putting in a diode (LED, works as a power indicator and diode). I really feel like my issue has something to do with surging power. I'm running out here, so i have to update my post for more information. \$\endgroup\$
    – fleshTH
    Jun 3, 2018 at 3:12
  • \$\begingroup\$ Sounds simple but let's make sure. Can you please provide at least a sketch or photo of the construction? Do the fans turn on the lamp briefly or does the lamp remain on for as long as those other devices are powered? Do you have the lamp circuit nearby when turning on those devices or does it happen when the lamp circuit is in other rooms? \$\endgroup\$
    – user133493
    Jun 3, 2018 at 3:55
  • \$\begingroup\$ The lamp comes on and stays on. I have monitored the input from the raspberry pi and it against signal, like the momentary push button is being pressed. I updated the post with a schematic and a picture. Hope that helps. \$\endgroup\$
    – fleshTH
    Jun 3, 2018 at 20:20

1 Answer 1

1
\$\begingroup\$

You're not the only one who's complaining. I suppose is about this module or similar:

enter image description here

I see this isuue over and over, the answer is the same as here, the bad design of the module, the driver transistor base is left floating which makes it sensitive to EM noises. If you have some soldering skills you can put a 1k ohm resistor from the pin 3 of the optocoupler to the ground (transistor emitter). Somebody should be fired for releasing such a crappy design.

Edit using updated quesstion, the pushbutton needs also a stronger pullup, put a 1 kohm resistor from the gpio pin to 3.3V.

\$\endgroup\$
3
  • \$\begingroup\$ I have a 1kohm resistor there (i didn't put on the schematic), But i put it inline with the switch, so I should go from GPIO 12 to 3.3v with 1kohm resistor? I'll give that a shot. \$\endgroup\$
    – fleshTH
    Jun 4, 2018 at 15:51
  • \$\begingroup\$ @fleshTH Yes, it will keep a stronger up state for gpio while the button is not pressed \$\endgroup\$
    – Dorian
    Jun 4, 2018 at 15:57
  • 1
    \$\begingroup\$ The orientation of the diodes in the schematic in the question would make it unable to intentionally active the active-low-input relay module you have pictured. So something is not as described or supposed. \$\endgroup\$ Jan 21, 2019 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.