Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

3

Question How to distinguish multiple GPIO Buttons? Answer Well, for a small number of buttons, say 8, you can use 8 GPIO pins, each of which entertains one button. But that is a big waste of GPIO pins. For more than 8 buttons, you can use GPIO extenders such as MCP23017, each of which adds 16 more GPIO pins, and greedy you can "easily" (see warning ...


3

try using systemd, the following is a simple service config, runs as user pi, will restart on failure (to a point, if it always fails immediately, systemd will not try to restart the process continually) You'd create a file in /etc/systemd/system - perhaps call it something like myservice.service ... the .service is important [Unit] Description=Your ...


3

While it is possible to connect multiple buttons to the Pi's GPIO and read them in a python loop the second that second "schematic" will not work. Note that ABCDE and FGHIJ columns are connected for each numbered row. Placing the buttons as shown will make it impossible to distinguish between the two buttons on each line. In this particular case one would ...


2

Make sure you have a common ground between the Pi, the LEDs and the power supply so that referenced voltages are consistent.


2

Since plyvel 1.0.0, the minimum leveldb version is 1.20. You're using an older version. See the version history for details: https://plyvel.readthedocs.io/en/latest/news.html#plyvel-1-0-0


2

It is inadvisable, and violates the recommendation in PEP 394 to make python refer to python3. Doing so (by ANY means) risks breaking your system and any tools which use python2 are likely to fail. If you want to use python3 invoke it with python3. If you want to install Python 3.7.2 in addition to the default Python 3.5.3, by all means use update-...


2

To determine what your program is doing, you need to save the output of the program to a file. Use this type of call to start the program /path/to/script >> /path/to/log/file 2>&1 & This will start the program in the background, and send all output (both stdout and stderr) to a file of your choice. Keep in mind that if the script is long ...


2

What you need is a button array. Example you have two rows of buttons a A b B c C d D e E a and A are connected to the same input GPOP b and B are connected to the same input GPIO and so on But they way you tell which button is being pressed is to Power all the capital buttons, check the inputs. Remove power from Capital buttons, power the lower case row, ...


1

You didn't tell us if you'd tried anything, and so I'll assume that you haven't. If that's the case, I'd suggest you take a look at this answer from Stack Overflow SE. In a nutshell, it suggests that you use David Beazley's Generator Tricks for Python, but the code is actually on Beazley's GitHub page. I think the specific code you'll need is this one All ...


1

Why are you calling os.system("sudo systemctl stop serial-getty@ttyS0.service") os.system("sudo systemctl stop serial-getty@serial0.service") These are the same interface, and if you aren't using serial console it is better to disable (using raspi-config) then there is no need for sudo. There is no need to use sudo with /dev/serial0 provided the user is a ...


1

Question How can Rpi send text strings to HC05? Answer I once wrote a couple of python functions to do the following: Reset HC05 to AT command mode, Reset HC05 to connection mode, Write AT command to HC05, Read reply from HC05. With these set of basic functions, I can then do the following. Set HC05 to AT command mode Send ...


1

Question Usage of that python class will not work with my setup of one motor. I agree and I want to instead use the GPIO library to control the board controlling the motor. Example code I found: import RPi.GPIO as GPIO I do not know how to edit the code to work with my project.] but I am using IN1 on the controller board and GPIO2 from ...


1

I suggest you return to using gpiozero, but select a suitable class. We don't know anything about your robot (include detail in your question). I guess it has a single motor with forward/reverse so the following would be appropriate:- https://gpiozero.readthedocs.io/en/v1.2.0/api_output.html#motor


1

You need to run your program with python3 not python.


1

After more testing I found out that there was still active code trying to access GPIO23. As GPIO23 is in use by the kernel, the declaration btn23 = Button(pin=23, pull_up=True) fails with RuntimeError: Failed to add edge detection, which apparently was silently caught in a try/except block. When an exception is thrown while declaring a Button, the cleanup ...


1

To answer my own Question at least to a small extend: VLC seems to offer a something similar to pygame but with the advantage that (to my knowledge) no screen is needed and it plays pretty much every data Format. Here a quick link: https://linuxconfig.org/how-to-play-audio-with-vlc-in-python As for the code, Iam still greatful for every advice, especially ...


1

When you executed this line in step 3: echo "alias workoncv-$cvVersion=\"source $cwd/OpenCV-$cvVersion-py3/bin/activate\"" >> ~/.bashrc It should have added a line to the end of your ~/.bashrc file. The line should look something like: alias workoncv-3.4.4="source /your/working/path/OpenCV-3.4.4-py3/bin/activate" First make sure that line exists by ...


1

relevant sections from that post go like so: step 0: defines the opencv version echo "OpenCV installation by learnOpenCV.com" cvVersion="3.4.4" step 3: sets up an alias # Install virtual environment python3 -m venv OpenCV-"$cvVersion"-py3 echo "# Virtual Environment Wrapper" >> ~/.bashrc echo "alias workoncv-$cvVersion=\"source $cwd/OpenCV-$...


1

I personally would change your functions to be pir.isThereMotion() that returns true/false then you could do while true: if pir.isThereMotion(): filename = "pircam-" + datetime.now().strftime("%Y-%m-%d_%H.%M.%S.jpg") camera.capture(filename) time.sleep(1) .... This way it will just take a picture ever second while ...


1

You should move the camera initialisation stuff outside the while loop. from gpiozero import MotionSensor from picamera import PiCamera import time pir = MotionSensor(4) camera = PiCamera() camera.rotation = 180 camera.start_preview(fullscreen=False, window = (50, 25, 640, 480)) while True: pir.wait_for_motion() print("You moved") time....


1

You can't use 5 V relay with signal from Raspberry Pi while Raspberry Pi signal is 3.3 V. So if you used Logic level converter to convert 3.3 V from Raspberry to 5 V then to relay in I think it may solve this issue. I don't know why most distributors say it should work with raspberry pi while the ideal one for Raspberry Pi is 3.3 ...


1

This answer fixed my issues In lib_nrf24.py in function: def begin(self, csn_pin ... after self.spidev.open add: self.spidev.max_speed_hz = 4000000


1

This code : import socket import fcntl import struct def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]) )[20:24]) print get_ip_address('lo') print get_ip_address('eth0') only works ...


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