There is nothing wrong with the GPIO, it just can't supply enough current for your coil.
If the coil has just 24Ω, at a 3,3V the GPIO would need to supply 137mA.
This source at raspberrypi.org says that the maximum current it 51mA for all GPIOs together and 16mA per GPIO.
You can connect the GPIO to a transistor that can supply the necessary 137mA.
From the picture of the wiring I dare say that there is no connection to the 12 V power supply. So the circuit is now just a switch and the solenoid. Without a voltage source the solenoid is not going to do much.
From the product description you can tell that the operating contacts of all releays are not connected to anything - which is by the way the most ...
WARNING! NEVER put any kind of switch in the Neutral line (unless using a double pole relay). This would violate electrical wiring regulations.
Putting a switch in the Neutral just makes the other side of the relay (and the rest of the circuitry) live when off.
Go with https://www.amazon.com/dp/B07CZL2SKN/. They've been kind enough to provide the ...
Yes. There are several ways this can be done. The method used will depend upon the characteristics of the load connected to the relay's contacts.
As @OyaMist has stated, "the actual relay state may differ from its nominal state". From a distance, when the relay state must be known, we are reduced to making a simple assumption; i.e. "...
The relay module you linked (which has limited documentation) states:-
12V 16-Channel Relay interface board, and each one needs 15-20mA Driver Current
The Pi GPIO can (safely) sink up to 16mA - and if using all relays would overload an Arduino, and probably the Pi.
Of course this assumes the Pi could even drive the opto-isolator, but if this has a series ...
CoderMike's Answer addressed the problems in your code, but if you are actually using the relay module pictured and have wired it in a similar manner there are more concerns.
There are a number of similar (poorly-designed) relay modules on the market - they seem to infect ebay!
They may work with Arduino (and TTL logic) BUT ARE A LOUSY DESIGN even for that ...
Firstly does the following turn your relay on then off?
import RPi.GPIO as GPIO,time
You also need to add timeouts to your distance sensing code otherwise your code could get stuck in a while ...
Remark: Just a quick and dirty answer. Perhaps more details later.
Warning: no guarantee no nothing won't meltdown or blow up.
I skimmed the datasheets and quickly concluded that there is 80%
chance OK, for the following reasons:
(1) Touch display is SPI, and relay is I2C,
(2) I2C relay has well documented instructions to change ...
Considering the hand-drawn schematics available at the product page linked in the question, it is clear that the circuit is "active low". That is, the coil of the relays is energized if the input is low. The controlled contacts however are two-way contacts so that it is possible to either break or make a contact when either energizing or de-energizing the ...
You can power a small servo from the Pi provided there is spare power. You don't have to power it from the Pi. If you power it separately then you need to connect the servo's power supply ground and a Pi ground. Just connect the control line directly to a Pi GPIO.
In summary for the servo
+ pin connected to power supply +
- pin connected to power supply ...
Does the following turn on and off your relay accordingly?
import RPi.GPIO as GPIO
RELAIS_1_GPIO = 18
Setting a GPIO pin has a latching behavior. That is when you set it, it stays that same value until you tell it otherwise. So in your if statement, just add an else clause to reset it low if the value read is <=600:
if touch > 600:
print("moisture: " + str(touch))
OBSERVATION: I do not see a line of code / instruction to pull the GPIO back to low. If the observation is correct and this instruction is executed:
How would the line GPIO return to a low state?
Under what condition do you expect the GPIO to return to the low state?
What happens if the instructions is changed to:
You have asked many questions - this site works best if you ask a single question (otherwise you will get lots of speculative answers, but often none from experienced users).
To answer ONE of your questions
it is important that we are able to shut down the pi safely!
To safely shut down the Pi run the following command:-
To detect WHEN ...
I want to create a system that has an internet connection via a mobile
sim and allows owners of enabled telephone numbers to switch a relay
by ringing the device sim.
In this instance, you need a SIM card module. The system just tries to upload some log files which is not too large hence you can buy a GSM module and make a 2G connection to your RPi.
Use a diode with
gpio(-) and relay input(+)
if it doesn't work then reverse the diode connection. The gpio only supply 3.3 volt. Maybe this one will solve.
While using nodemcu I faced the same problem.
Here is how it works in simple terms.
Consider the following schematic.
Applying a LOW to a lamps turns it on.
It is sometimes referred to as "active low" signal.
simulate this circuit – Schematic created using CircuitLab
relay module has 12V power supply, ...
have connected all the Rpi GPIOs relay board, ...
connected 5V and 3.3V connections to the two 5V pins on the relay module (5V is being used to power the touchscreen display) , ...
Run code, nothing happen, ...
It is not clear why you connect 3V3 power to 5V. And it is not clear
1) substitute a relay for the button press - that way you don't need to worry about voltages, common grounds, pull ups, or pull downs. Eg https://www.instructables.com/id/Control-Any-Remote-From-a-Raspberry-Pi-and-Amazon-/
2) Or find an HDMI switcher with a computer input, for example the ATEN HDMI switcher has an RS232 input.
The button on the HDMI ...
@RalfFriedl is right, but I found some relays which are done for raspberry and arduino.
Now the circuit works.
@joan do you think that this kind of relay will destroy the board?
I think the circuit you've illustrated is more complex than what is needed for simply driving a 12/24V relay. The primary considerations in using GPIO to control external devices are:
GPIO has low output voltage (3.3 volts),
GPIO has low drive current
GPIO is fragile in the sense that it will not tolerate over-voltage
I feel the optimal device for ...
All the relays turned on as soon as the pin they were connected to was set to out mode.
This is because the RPi pins toggle between 0 and 3.3V, not between 0 and 5V. So, when you set the pin to 3.3V, there's still (5-3.3 = 1.7V) applied to the LED inside the opto-isolator. If that voltage is enough to turn it on, the relay will stay activated regardless of ...
Here's one of many solutions to this problem. It relies on you properly shutting down your Pi by running something like sudo shutdown or clicking a shutdown button on your OS. If you use sudo halt or sudo shutdown -h or simply unplug your Pi, this will not turn the relay off.
Turning the Relay On at Boot
You will need a script that turns the relay on. Most ...