5

See RPi.GPIO documentation. Cleanup At the end any program, it is good practice to clean up any resources you might have used. This is no different with RPi.GPIO. By returning all channels you have used back to inputs with no pull up/down, you can avoid accidental damage to your RPi by shorting out the pins. Note that this will only clean up GPIO channels ...


4

All I can think of is the fan causes a power spike which temporarily drains power causing a voltage drop. I suppose you could sort of test that by using the script without the fan connected.


4

First of all, test the LED by connecting it to 3V3 and GND to make it come on without needing code. Then move from 3V3 to a GPIO pin and make sure you know which pin you're connected to. Refer to pinout.xyz. Your gpiozero example is wrong. Running led.blink() in a loop is repeatedly starting the loop but never giving it chance to cycle. You can either create ...


3

The stated question is regarding contact bounce. However, the data presented in the question does not reflect contact bounce - contact bounce does not repeat over the 100msec & 300msec durations presented in the text of the question. Let me try to be clear: The data provided does not rule out contact bounce, but the issue described by the data is not due ...


3

Probably found an answer thanks to @joan 's answer. It seems like RPi.PWM can only do software PWM, but the fan requires hardware PWM to run as smooth as possible. To do hardware PWM on any GPIO pin, the pigpio daemon has to be executed, and controlled by Python. Therefore, pigpio has to be installed first and configured to be started on boot (systemd). ...


3

The FIRST thing you MUST do in interconnecting 2 devices is ensure they have a common reference (incorrectly called Gnd - as the Pi will float wrt Ground). It is also recommended to join Gnd FIRST - before making any other connection. It is acceptable to directly connect 2 GPIO, but it is prudent to use a series resistor (~1kΩ) to protect the GPIO in the ...


3

The code you have should be fine. I'd expect the resulting sleep to be within 1% of n the majority of the time (getting more accurate for larger values of n). If you are seeing 2 times n it suggests something like: your system is exceptionally busy or the circuit you are driving has a large amount of capacitance to overcome or some other program is ...


2

I doubt you will reliably be able to read NEC IR signals with RPi.GPIO. The combination of Linux scheduling and GPIO interrupt handling and Python will likely conspire to miss transitions. I suppose that is something you will have to find out for yourself by trying. My pigpio Python module will capture the data. See the following examples. http://abyz....


2

I expect in reality the final state of the GPIO is pretty random. As you don't do a cleanup GPIO 17 will be left as an output. Its level will remain at whatever it was when the sleep elapses and RPi.GPIO terminates. The final level may appear stable over successive runs for a variety of reasons. E.g. in a perfect world the sleep will elapse at exactly ...


2

I have finally found a Python library with documentation gpiozero I recommend this to anyone attempting to manipulate GPIO with Python. Just to clarify I also highly recommend the pigpio Python module which has more functionality.


2

I'm not sure if this is the best/cleanest answer but you could have annother button called Autonomos mode off which you would press before you press the sensor off relay on. That button would have go to a different script in that directory that you would call stop.py. fileObject = open("isAutonumous.txt", "w") fileObject.write(0) ...


2

You could use a breadboard to create a "bus" for distribution of the RPi's +5V (or +3.3V) power to your "add-ons". You should understand which sockets/holes on the breadboard are common before you get too far along with this. You should also keep in mind when patching connections from the RPi's GPIO pins that many of these pins are "...


2

Try connecting the wire to another Pin like Pin 11. Then run one of these: gpiozero: from gpiozero import Button from time import sleep button = Button(17) # The 11th Pin is GPIO 17 while True: if button.is_pressed: # Your code here sleep(0.2) RPi.GPIO: import RPi.GPIO as GPIO from time import sleep butPin = 17 GPIO.setmode(GPIO....


2

Your Question is misleading. Debounce settings work for their intended purpose (short term contact bounce), but this is not really your problem. Incidentally if you wanted to test bounce you couldn't have found a better "switch" to generate it - proper switches are designed to minimise bounce, although relay contacts are notorious for bounce. What ...


2

I have written several GPIO Python modules. They each implement a "proper" debounce. pigpio set_glitch_filter lgpio gpio_set_debounce_micros rgpio gpio_set_debounce_micros


2

The RPi.GPIO module only runs on the Raspberry Pi. You will have to create your own dummy copy if you want to develop on another computer.


2

From a quick search on FOTEK 40A SSR, the data below in Figure 1 and Figure 2 was located. From these specifications, it appears that you do not need the 2N2222 transistor. Figure 2 states that only 2.4V are required to turn the SSR "ON", and 1.0V to turn it "OFF"; further that the current needed (Trigger Current) is 7.5 mA. (The ...


1

I would go with the RPi.GPIO on the Raspi. Which Version of Raspberry Pi you have? Two things that came up to my mind by reading your post were: Have you checked that the LED is working? Connect it with a Resistor which fits your led. If Resistor is to high the LED maybe flashing not very bright. Have you checked that you use the LED in the proper way (not ...


1

I have had this issue myself. What you are after is a mock library. Give this one a go: https://pypi.org/project/Mock.GPIO/ pip install Mock.GPIO Just replace your import: import RPi.GPIO as GPIO with: import Mock.GPIO as GPIO


1

I believe the problem is really in the old OS (or probably rather: Old libs) in use. The Pi4 requires an update to the I/O library for the input pull-up resistor setting to work properly, which is likely used by the above Button class. Try a never version of Rpi.Gpio, when possible. Alternatively, you could add an external pull-up resistor to your button pin ...


1

No, the GPIO pins can not be used to drive a DC motor. They can only supply a few milliamps of current at 3V3 which will not be enough. In addition driving any inductive load direct from a GPIO is likely to destroy the GPIO and the Pi. An inductive load is such as a DC motor or a relay coil. You need a motor driver board or chip or discrete components (e.g. ...


1

"Reference voltage"... do you mean supply voltage? The answer to your question is: "Yes - you can probably use RPi's 3.3V & 5V supples to power your level shifter.". The caveat was added because you didn't specify a particular device, and there are many devices called "level shifters". Both the 3.3V and 5V regulators on the RPi have some "excess" ...


1

If you are using a fresh image you don’t need to install it. For the old version sudo apt-get update sudo apt-get install rpi.gpio


1

If the script already has root privileges, then why would you need to run it with sudo? At the terminal, launch Python 3 using sudo and try this: $ sudo python3 >>> import RPi.GPIO as GPIO If it still says ModuleNotFoundError, than install it using: pip3 install RPi.GPIO Make sure in your current directory that the script is in, that no files ...


1

At the command line prompt type dmesg. The log will tell you if you are having power problems.


1

You need to design the structure of your script to support this usage. Generally wherever you have a time.sleep() you will need to replace that with a loop testing for an early completion signal. E.g. change def blink_slow(): GPIO.output(blueLED, GPIO.HIGH) sleep(3) GPIO.output(blueLED, GPIO.LOW) sleep(3) to something like SHORT_DELAY=...


1

I suspect the answer is to have events rather than a while loop. Not sure on the logic on this project... Is it: when the button is pressed, check for the phone being connected (or nearby)? This would mean you could use when_pressed https://gpiozero.readthedocs.io/en/stable/recipes.html?highlight=when_pressed#button For reading the phone connection, you ...


1

Driving a 3.3V pin with a 12V signal will require a level shifter anyway, and inverting level shifters have essentially the same complexity as non-inverting ones. For instance, here's an example using an optocoupler: simulate this circuit – Schematic created using CircuitLab The advantage of an optocoupler is that you don't have to have the same ...


Only top voted, non community-wiki answers of a minimum length are eligible