5

You should import the GPIO library as import RPi.GPIO as GPIO than reference it by using GPIO. Also packages for python 3.x require you to use pip3 install rather than sudo apt-get install python3-rpi.gpio as it doesn't require elevated privileges and has access to the python package index (pypi.org)


4

When you have a recursive function like this (one with too much depth potential), you need to convert it into a loop. In this case you have two functions alternating calling each other: while True: watchopen() watchclose() This will loop forever (as does the original version, you are exiting on a signal), but you can also use some kind of state as a ...


4

That's one way of doing it - it will work. The better way is to use GPIO.wait_for_edge(17, GPIO.RISING) which will pause at that line until the button is pressed (on a RISING or FALLING edge). However, BOARD numbering pin 17 is not a GPIO, it's 3V3. You could also use GPIO Zero which is more intuitive (and uses BCM numbering): from gpiozero import Button ...


4

The preliminary Pi4 datasheet shows there are 6 UARTs. UART GPIO 0 14/15 1 14/15 2 0/1 3 4/5 4 8/9 5 12/13 Given that UART 0/1 are both connected to the same GPIO you can only use one of them at any one time. So potentially there are 5 accessible UARTs at any one time. You can enable each of the UARTs on the Pi4B by making appropriate ...


3

Yes, it is possible to control the built-in leds. Green LED is easier. According to here, though it is probably Pi 3 specific, since it didn't work for my Pi 4: In the terminal: sudo echo 1 > sudo /sys/class/leds/led0/brightness This turns the green led on. sudo echo 0 > sudo /sys/class/leds/led0/brightness To turn off the activity indicator ...


3

As far as I am aware it should work provided you download and install the latest version of wiringPi. http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/ cd /tmp wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb


3

It's possible that this might mirror something I was doing a couple of years ago and I preface this with the observation that I don't believe that it was good practice, but I didn't find a way around it, so I welcome any correction. The issue (in my case) was that running a python program that accessed the GPIO pins required root access. If you are going to ...


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 ...


2

Make sure that the silver contacts are well inserted into the PCB connector. (video here) Also, make sure that the sunny connector is firmly attached. This fixed it for me.


2

Answer: 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. Background: 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. "...


2

After hours of hitting my head against the wall I tried to connect it directly without passing through the level shifter and it worked... I don't understand exactly why it is, I suppose it's because of the pulldown resistors or something like that but can tell exactly.


2

I'm going to post this as an answer because I had a lot of trouble researching how to drive an ESC with just a Rasp Pi(using a zero w) and it works now, Hopefully someone having the trouble finding out how will see this: Joan was completely right with the 1000 low and 2000 ms high pulse width. I ran the GPIO pins at 50 hz. Here is some light arithmetic ...


2

No problem. It is safest to introduce a resistor. Connect any Pi ground pin to any of the other Pi's ground pins. Connect any Pi GPIO pin to any of the other Pi's GPIO pins via a resistor (if you have one, anything between 300 ohms to 100 thousand ohms will do). Set the transmitting GPIO as an output and the receiving GPIO as an input. The resistor is ...


2

Arguably, the best way is to use the package manager still (downloading the packages manually), because the installation process will keep track of the dependencies for you. First, you will need to download the package. You can do it either using the browser from http://archive.raspbian.org/raspbian/pool/, or by adding the content of Raspbian's sources.list ...


2

The GPIO is still working, it's the software refusing to continue without a warning unless you correct the condition causing the warning. Either do what the warning message says or add the following line at the (logical) end of your script. GPIO.cleanup()


2

though it is probably Pi 3 specific, since it didn't work for my Pi 4 It works on the 4 as well, you just need to set the right trigger. The instructions that you provided are not applicable to the 4 or just incorrect. This will tell you what triggers you have available: cat /sys/class/leds/led0/trigger To enable manual control on a 4, do: echo gpio |...


2

Here is what comes to mind first, but maybe there are other ways. Using FIFO file, arecord tool and using python here, something like this must be possible. :


2

On the first RPi : In a first terminal : (create FIFO) mkfifo /tmp/audio.fifo.pi1 In a second terminal : (Write datas into FIFO) arecord /tmp/audio.fifo.pi1 readfifo-writeUART.py : pyserial short-intro #!/usr/bin/python # readfifo-writeUART.py import serial def do_work(data): with serial.Serial() as ser: ser.baudrate = 19200 ser....


2

Yes, as long as the signal is 3V3 compatible. You could use the Pi's UART RX pin (pin 10, GPIO 15) and the standard Linux serial software. That will handle standard baud rates (say up to 1 Mbps). Alternatively you can use a general GPIO (any other GPIO on the extension header) and software serial. That should be good up to 19k2 bps or so.


2

Thank you all for your help in diagnosing this. Relay was faulty, swapped for one of the same make and model and now its working with the test provided by Coder Mike, as well as my original script.


2

Executive Summary Helping to understand the OP's AI (OpenCV!) robot car code. / to continue, ... Contents 1.0 Answer 1.1 motor, led python modules summary 1.2 server, run python modules summary 2.0 References 3.0 Appendices 4.0 Schematic (L298 Motor Driver) / to continue, ... 1.0 Answer 1.1 - Walking through low level (GPIO, DC motor) functions ...


2

It is inadvisable to mix libraries. You can control a servo with https://gpiozero.readthedocs.io/en/stable/recipes.html#servo See https://gpiozero.readthedocs.io/en/stable/api_output.html#servo for documentation of the servo class. NOTE that gpiozero, by default uses RPi.GPIO GPIO Zero builds on a number of underlying pin libraries, including RPi....


2

The module you have includes a resistive sensor and a comparator which produces a 1-bit value (0 or 1). There's nothing you can do to get a more detailed signal from that module. There are two main approaches which allow to read analog values from resistive sensors with devices which don't have analog pins, such as raspberries. External ADC: simulate this ...


2

Question How can Rpi python read a SPI MFRC255 RFID/NFC tag? Short Answer Part 1 - Introduction to I2C and SPI NFC/RFID Chips and Modules Part 2 - Setting up SPI MFRC522 Module Part 3 - Troubleshooting SPI Software and Hardware using Loopback Part 4 - Using Rpi4B buster Python 3 and Mfrc522 library to read NFC Tag I have successfully installed ...


2

Using software PWM for a frequency of 30 kHz is ambitious on the Pi. I would use hardware PWM (available from GPIO 12, 13, 18, 19). See http://abyz.me.uk/rpi/pigpio/python.html#hardware_PWM


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

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 ...


1

As Joan has stated only 1 of UART0/1 is accessible (UART0 /dev/ttyAMA0 is connected to Bluetooth on later model Pi). There are additional UART on the Pi4. I haven't actually tried these. I doubt UART2 would be usable as GPIO0/1 are used for HATs (and shown as reserved). I suspect that the SDA0/SCL0 connected to these pins are used for other internal ...


1

Most EEPROM chips use either SPI or I2C to transfer data, check the docs for the chip you choose to find out which and connect to the appropriate bus on the Pi. From there it's a matter of sending the right commands on the right bus -- again the chip docs will help with this. There is, no doubt, many Python libraries to help with the commands (e.g. https://...


1

Unfortunately the Pi has no GPIO programmable built-in LED. Edit: This is incorrect. As pointed out in an answer below, the on-board can be controlled using echo none > /sys/class/leds/led0/trigger to enable, echo 1 >/sys/class/leds/led0/brightness to turn the LED on, and echo 0 >/sys/class/leds/led0/brightness to turn the LED off. The rest of my ...


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