New answers tagged

0

You can use a wrapper script. When the python script crashes, the wrapper script can turn off the LED. So, the wrapper script would be a simple as: #!/bin/bash your_pythonscript echo 0 >/sys/class/leds/led0/brightness


1

Your program is successfully running when started from the command line. So I cannot see a reason why to run it as old style Unix daemon with Type=forking. Then you normally have also to provide the PID of the process so systemd can find the daemon again that it has forked away from its environment. If not needed for backward compatibility of old Unix daemon ...


0

Kivy can use hardware accelerated libraries on PiOS Lite. Desktop / X is not necessary. However, for the Pi4 you need to compile the SDL2 libraries from source. The version in the repos was not compiled with the kmsdrm backend, so it only works under X11. See Kivy documentation


1

LoRa is NOT intended to be used for such a thing. LoRa operates in the free ISM band. As such there are rules that don't allow transmission over a long period (the maximum allowed transmission time is regulated by the local government) in order to allow other devices to also use the shared medium - thus reducing the air-time. Also LoRa uses transmission ...


1

What command do you set in your crontab file? Is the script intended to run once and done or constantly post power readings? As you mention, crons can fail because of path issues. Not only for the script but also for python if that is how you are running the script. For example: @reboot /usr/bin/python3 /home/pi/example.py You may wish to save the output of ...


0

You could start by collecting the output of a nmap run within your program, then parsing its output. For example, using Python I ran a quick 'ping only' scan of my local network. (Nmap also has an XML output format if you wish to be really thorough!). import subprocess command = [ 'nmap', '-sn', # Ping scan only (was '-sP' in older nmap) ...


0

Had this problem for a while, turned out I had it connected to the display slot and not the camera slot. There are two slots on the Pi 4 that look identical.


0

This is not really a Pi specific question but programming. Nonetheless checking buttons in callback is error prone. The traditional approach is to set flags until the callback finishes. NOTE there should be no reason you can't use gpiozero as this is (normally) just a wrapper around RPi.GPIO. I note you are still calling SystemExit. This is not normal and ...


0

The stepper motor is an incremental device. That is to say you can only command it to go in a desired direction for a desired number of steps, where each step is a fixed angular displacement, often 1.8 deg and sometimes 0.9 deg. So it is easy to go to say a EAST position, where is relative to your last position. To go to a desired absolute angle you need to ...


0

Found the error. I define RESOLUTION here and use it correctly RESOLUTION = (1024, 768) cam = PiCamera(camera_num=0, resolution=RESOLUTION, framerate=40, sensor_mode=0, clock_mode='reset', framerate_range=None) But then in the capture area I use it in the same order, and there it is wrong: output = np.empty((RESOLUTION[0], ...


1

It's been a while since I've used raspistill, but this may work as a cron job: Create your bash script at /home/pi/camera.sh as follows: #!/bin/bash DATE=$(date +"%Y-%m-%d_%H%M") /usr/bin/raspistill -o /home/pi/camera/$DATE.jpg Be sure to mark it as executable : chmod a+x /home/pi/camera.sh Add the following line to your crontab (crontab -e): * * ...


0

You can create a service to run shell script, instead of @reboot in crontab. Like this https://github.com/mohdismailj/fancontrol/blob/main/fancontrol.service


0

spidev will use the underlying Pi's Linux SPI driver. The Pi's SPI hardware supports 8 bits only on the main SPI device (spi0.x). The auxiliary SPI device (spi1.x) supports a range of bits (1 to 32). However I don't know if this is supported by the Linux SPI driver. It seems likely you will have to bit bang the SPI protocol. As an aside the pigpio SPI ...


1

Updates: I have figured out the cause of this issue, it seems like when the annotator is called several times in the loop it allocates several resources and doesn't release them between loops. The issue was fixed by avoiding to use Annotator and remove it from inside the loop


0

Make sure that you are building your Flask app in a virtual environment where you have already installed latest psutil module. I am pretty sure you will not get any errors then. Also make sure none of your python scripts are named as psutil.py. Please make a habit of using virtual environments to avoid these kind of issues if that is the case.


1

To install pyaudio in Raspberry Pi OS (for python3) use a sudo apt install python3-pyaudio command. After installing pyaudio; to confirm it is downloaded or not, check with a pip3 list command.


0

This line in your script: cd "$(/home/pi "$0")"; is trying to execute /home/pi as if it's a program, but it's surely a directory. What did you mean this line to be?


0

The problem you have is that you're trying to use RPi.GPIO without setting the numbering system as required - as the error message states. However, as mentioned in the comments, it's not recommended that you mix the two libraries, and gpiozero has implicit cleanup, so you don't need to use GPIO.cleanup() - which is mentioned in the docs: https://gpiozero....


0

It is impossible to determine the pull state of GPIO on most Pi (except by measurement). It is possible with the BCM2711 used by Pi4 and I have written a Python3 library (based on RPi.GPIO) which does this and a program gpioread which shows this and the actual programmed function/state. See https://raspberrypi.stackexchange.com/a/117593/8697 Corrupted git ...


0

You can't query the pull state with RPi.GPIO. In fact you can only query the pulls in software in the latest Pi models based on the BCM2711. I'm not sure if any of the mainstream GPIO libraries actually provide support for doing so.


0

You can install Pip as long as you have Python on the computer. The Python Packaging Authority (PyPA) maintains the code for PIP on GITHUB here and the latest instructions can be found in the readme associated with the code. Currently you download the source code: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py then run the code python get-pip.py ...


0

As an alternative you may try to install ffpyplayer (ex pip3 install ffpyplayer). I also couldn't load any video, had the same Video: Provider: null as you, though for me no issue with the installation of gstreamer and its components. Now the log tells me: [INFO ] [VideoFFPy ] Using ffpyplayer 4.3.2 [INFO ] [Video ] Provider: ffpyplayer(['...


1

As long as you have a Python application with a graphical user interface you can refer to this question.


0

PJSIP is definitely what you need. Tell something more about what exactly your problem is. Example below shows simple application based on PJSUA (high level API of PJSIP). #include <pjsua-lib/pjsua.h> #include <iostream> #define THIS_FILE "sipdtmf.cpp" using namespace std; void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id ...


0

I hit this error with code which works perfectly with my USB mic on Ubuntu but refused to work on RaspberryPi. First, since the question was asked, card is outdated and replaced with device. Second, I had to run alsaaudio.pcms(alsaaudio.PCM_CAPTURE) and use EXACT FULL line of that output as device. In my case it was full line "hw:CARD=SHG7980,DEV=0"...


0

The installation instructions is described on the given link: sudo apt install git git clone https://github.com/fruxefarms/FruxePi.git cd FruxePi sudo bash install.sh


1

The mobile phone will be the central (BLE) or client (Classic) so on the RPi you will need to create a peripheral (BLE) or server (Classic). The two ends of the Bluetooth link need to match, so what you do on the RPi will depend if you already have an app in mind for the phone. BlueZ is the underlying Bluetooth stack on Raspberry Pi and Python can use it's D-...


0

Maybe the camera isn't getting enough power and disconnects for a split second... (this would explain why restarting is the only way to fix it... Since if you disconnect and then reconnect the ribbon cable while using the camera, you get the same effect and have to restart the Pi) Try making sure the camera and pi are getting enough voltage while it's in use....


0

use this command: sudo apt-get install --upgrade python3-pyside2.qt3dcore python3-pyside2.qt3dinput python3-pyside2.qt3dlogic python3-pyside2.qt3drender python3-pyside2.qtcharts python3-pyside2.qtconcurrent python3-pyside2.qtcore python3-pyside2.qtgui python3-pyside2.qthelp python3-pyside2.qtlocation python3-pyside2.qtmultimedia python3-pyside2....


3

Unless a device actually communicates on USB, there is no way to know whether it is plugged in or not. The Pi has not built-in equipment to measure the power supply current, or current in a given USB port. And, as you rightfully notice, such measurement wouldn't be a reliable indicator of connection, because once the battery is charged, it stops drawing ...


0

Have a look at Imagenode, Imagehub, and Imagezmq, I use them in a security camera system that I use on the RPI, you may be able to adapt them to your needs. Imagenode only sends a pic to imagehub when motion is detected. Imagehub does an image classification on pic and tells me if its a dog, cat, car, or person. Then Imagehub sends me a txt alterting me ...


0

Assuming you mean Python. Yes, you can run Python on the Pi. Python 2 and Python 3 are supported. Copy your code to a file on the Pi. I'll assume your code is called my_code.py. To run it use either For Python 2 python my_code.py For Python 3 python3 my_code.py


1

you need to use the cue path as seen in the cue log. So sync /osc:10.0.0.80:56505/play_this. This should have popped up in the autocomplete after the first message was received by Sonic Pi from your Python script. If you want your sync to work regardless of where the message came from you can use the * sync /osc*/play_this. Also, a great place to ask Sonic ...


0

As you have to with cron if you had put a PATH= in your script it would have found the files. Cron does not inherit any PATH or other environment variables they need to be set or you use absolute paths to the files, as you discovered.


0

I think you should be putting to photo in /home/pi/Pictures/image_shell.jpeg if you don't have the leading / it's not going to select the right path.


2

I would recommend using GStreamer for this. Check out their tutorials to understand how to play a video file, and this page documents how to apply a text overlay. You will probably want to test using the gst-launch-1.0 command line tool, but to trigger from a GPIO I expect you'll need to write a program. You can use GStreamer from a wide variety of ...


Top 50 recent answers are included