Questions tagged [python]
Python is a general-purpose, dynamically typed, object-oriented high-level programming language. Interpreters for versions 3.x and 2.x come installed on the Raspberry Pi's most popular operating system distributions.
3,215 questions
0
votes
0
answers
49
views
How to control a stepper motor using Python?
I am currently trying to control a NEMA 17 stepper motor rated for 1.5A through a DRV8825 driver using a Raspberry Pi 4B for a school project. I was trying to use RPi.GPIO to control the motor but it ...
0
votes
0
answers
59
views
Raspberry Pi OS Lite Bookworm 64-Bit w/DSI Display
I run an open source project called PiFire which aims to provide an open source smoker controller using a Raspberry Pi and some off the shelf hardware.
I have used a DSI connected touch screen display ...
-1
votes
1
answer
67
views
Use RM3100 with Raspberry PI
for a school project, I would like to take measurements of the Earth’s magnetic field using an RM3100 Breakout Board magnetometer from PNI Sensor. I soldered the headers myself onto the pads. I ...
0
votes
0
answers
40
views
NRF24L01 communication between Raspberry Pi 4 and Raspberry Pi Pico (MicroPython) not working
I’m trying to set up wireless communication using two NRF24L01 modules. I’m using a Raspberry Pi 4 Model B as the receiver using the pyRF24 Library and a Raspberry Pi Pico with MicroPython as the ...
0
votes
0
answers
45
views
USB 4G Dongle disconnect with code
Using the command lsusb i am getting the following output:
pi@raspberrypi:~ $ lsusb
Bus 001 Device 005: ID 19d2:1405 ZTE WCDMA Technologies MSM ZTE Mobile Broadband
Bus 001 Device 002: ID 1a40:0101 ...
0
votes
0
answers
47
views
Installing Mojo fails on 64Bit Bookworm
I've being trying to install Mojo a replacement for Python using the instructions here. All goes well until I try to run mojo when it crashes immediately with
2343 external/tcmalloc+/tcmalloc/system-...
0
votes
0
answers
66
views
Well written soft doesnt work after update
I wrote code for my RPi as below and it was working preatty long time, unfortunatelly after system update buttons Start and Stop does not generate any reaction. What may be the reason and how to fix ...
0
votes
0
answers
146
views
Can't use gpiozero on Raspberry Pi 5 despite successful installation
I'm having trouble using the gpiozero library on my Raspberry Pi. Here's what I've tried:
Installed via apt:
sudo apt install python3-gpiozero
Output:
Reading package lists... Done
Building ...
-1
votes
1
answer
418
views
Unable to start pigpio daemon on Raspberry Pi 5 after successful installation
I'm trying to set up pigpio on my Raspberry Pi 5 (aarch64 architecture running 64-bit Raspberry Pi OS Lite). The installation appears successful, but I can't connect to the daemon from Python.
...
-1
votes
1
answer
216
views
How to read from dht11 on rapberry pi 5
I'm using a raspberry pi 5 to read from a dht11 sensor with the signal line connected to gpio pin 26. I tried using the Adafruit_DHT and adafruit_dht libraries, which led to the error messages "...
-1
votes
1
answer
105
views
Install Opencv on Raspberrypi
I am trying to install opencv on my raspberry pi 5 (os: 32-bit lite).
I've tried the code to install opencv:
sudo apt-get install python3-opencv -y
but encounter the error below:
The following ...
0
votes
0
answers
60
views
PanTiltHat and i2c failing
I have a PanTilt Hat powered by two servos over i2c. The example code below works fine and the hat mechanism will move smoothly for many minutes until ended by being terminated using Ctrl-C from the ...
2
votes
1
answer
120
views
Unexpected characters at serial port opening (Arduino Mega to Raspberry Pi via TTL-232R)
I'm using an Arduino Mega to send data via serial communication to a Raspberry Pi 5. The connection is made through a TTL-232R cable (TTL serial on the Arduino side, USB on the Raspberry Pi side). On ...
2
votes
0
answers
57
views
Detect whether USB speaker is connected to my RPi 4B, in Python
I'm building a device that if in my Python program the USB speakers are not connected it directs sound only to the headphones but the device works differently in a different mode with not so many ...
2
votes
0
answers
43
views
My motor encoder is rotating but on Rviz2, it didn't
I'm working on a custom LIDAR using TF Luna and rotating it using a motor with an encoder for mapping purposes.
As the title says, the rotated angle is not being updated to Rviz2 , resulting in a ...
2
votes
2
answers
111
views
How to unbind a GPIO pin
Hi Im working to make a car radio using a RPI5 with this Hat (version carpihat5 pro with dac+) with this project everything goes well but when I tried to add another GPIO pin to turn my amp on to his ...
0
votes
1
answer
75
views
Is this the right approach for my project?
This is my first Raspberry PI project.
I'm trying it for fun and personal use for my home.
I want to mount a device that detects a face from a short distance (maybe 1m and less) and initialize an API ...
0
votes
1
answer
172
views
- Errno 121 - Remote I/O error when sending data through i2c
I'm trying to send data to the RAM of a I2C LCD screen to clear the display (when I switch on the LCD and just after the init stage, many pixels are randomly initialized to 1 and not 0).
I'm using ...
0
votes
2
answers
91
views
Autocorrection of 1 wire system
I have 11 DS18B20 sensors distributed through my house checking temperatures of all rooms, as well as outside temperature. I check and data log from these every 5 minutes and have been doing so for ...
-2
votes
1
answer
92
views
Strange issues with using crontab to run a python script
I'm working on a project that needs to run headless - I need to run a python script "main.py" within a virtual environment at boot.
I decided to use crontab to do this. My crontab line is as ...
1
vote
0
answers
61
views
Realtime waveforms on a RasPi5 using python?
Is there a way (over in STM32-land, I would use double-buffered DMA banks) to output waveforms (4 pins in my case, though I'd like to do more) on a Raspberry Pi 5 in a continuous mode that won't go ...
0
votes
1
answer
104
views
Raspberry Pi RFID, PIN & fingerprint project
Hoping someone can help. I am currently doing a school project using a raspberry pi to allow RFID scanning, then a PIN entry then finally a fingerprint scanner, all fetched from an SQLite database. ...
0
votes
3
answers
250
views
Why doesn't python script redirect output to file?
I have a Pi 4 with bookworm, running a python 3 script.
The python script generates logging output to stdout (to the terminal) when run from a prompt.
I want to run the script from cron and capture ...
1
vote
1
answer
82
views
can write but not read with SMBUS
I'm trying to drive an I2C LCD screen.
I know the device address from
i2cdetect -y 1
It's 0x3f.
I reset the screen by setting LOW and HIGH the RST GPIO 4 (the RST pin is connected to GPIO4).
Then I ...
-1
votes
1
answer
178
views
Raspberry Pi Pico OLED SSD1306 - No I2C Devices Found & AttributeError
"I'm trying to get my SSD1306 OLED display working with my Raspberry Pi Pico using MicroPython, but I keep running into this error:
Traceback (most recent call last):
File "<stdin>&...
1
vote
0
answers
53
views
RPI 4 B gpio not working when usb printer is plugged in
I have an RPI 4 model B
below is my code
import RPi.GPIO as GPIO
import time
# GPIO pin connected to the COIN pin of the coin selector
COIN_PIN = 24
# Setup GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(...
1
vote
1
answer
107
views
how do you import Rpi.GPIO as a unit test?
Im developing some code to run on the Raspberry Pi using GPIO, but most of the time Im on my desktop, where calling GPIO will break the code. I just learned about unit testing, but Im not sure how to ...
0
votes
0
answers
399
views
Unable to run pygame script on Raspberry Pi with display out using framebuffer or X Server
I’m having trouble running a pygame script on my Raspberry Pi Zero 2W with Raspberry Pi OS Lite. The script is intended to display images directly on the screen. However, I’m encountering errors and ...
0
votes
1
answer
591
views
Why does GPIO.add_event_detect fail with 'RuntimeError: Failed to add edge detection' on Raspberry Pi?
I'm working on a Raspberry Pi project using Python and the rpi-lgpio library to monitor GPIO events. My setup involves connecting a RadiationD-v1.1 (CAJOE) module to GPIO pin 11 (physical pin 23) on ...
-1
votes
1
answer
525
views
Starting python script in a virtual environment using cron
I have a Raspberrypi 5 running bookworm and would like to run a python script at reboot. The script is in a virtual environment: /home/mipi/venv/Startup/Startup.py (where venv is the root directory ...
0
votes
0
answers
40
views
unable to use fswebcam from python script in virtual env
I am using raspberrypi4 trying to run fswebcam from within a virtual env , but i get error when i do so
(rasberry-pi-env) rishil@raspberrypi:~/proj $ ./obj-detector.py
Traceback (most recent call ...
1
vote
1
answer
916
views
Using Python Virtual Environments
When I try to install a new python library (using pip) the following message appears
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages ...
1
vote
0
answers
233
views
Cannot force video at 60fps with HQ camera and picamera2
I am using a pi 4B with 8GB RAM and bookworm OS and the pi HQ camera.
picamera2 returns sensor_mode[0] (below) that should support 60 fps video at 1332x990 image size. If I set camera configuration ...
0
votes
1
answer
56
views
OpenCV: pixel-accurate rendering
I'm having this code on my Raspberry Pi5:
import cv2
import numpy as np
box_size = (640, 480)
spacing = 1
num_rectangles = 4
window_width = 640
window_height = 1200
frame = np.ones((window_height, ...
0
votes
0
answers
128
views
I want to build a ultra low latency live streaming application using raspberry pi, picamera and ffmpeg
I’m working on building an ultra-low-latency live streaming application using the Raspberry Pi Camera Module V2. My setup includes FFmpeg for video streaming over UDP to achieve low latency, and ...
-1
votes
1
answer
101
views
GPIO.setup(BOARD.LED, GPIO.OUT)
I want to send a message using LoRa SX1278 using raspberry pi 4 as a receiver and LoRa SX1278 with raspberry pi 5 as its transmitter. we have downloaded git clone from the following link: https://...
0
votes
1
answer
197
views
Getting `segmentation fault` while running a video using `cvlc`
I have a raspberry pi model 4B.
This the os version I have
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)...
-1
votes
1
answer
100
views
Going from Raspberry Pi to embedded / real products with SoC?
Imagine having built something like Amazon's Alexa yourself. You've used all that nice HTTP / network libraries for Python and other developer-friendly things. Maybe you are also using a Python ...
2
votes
1
answer
1k
views
Migrate python application using pigpio to raspberry pi 5
I have a fairly substantial hardware control application that I'm currently running on a RPI 3b. I'm using nearly every pin on the GPIO, including using PWM output, I2C and multiple 1-wire buses. The ...
0
votes
1
answer
121
views
Problems with a direct TCP connection between a Raspberry and a Modbus device
I'm having problems with a direct TCP connection between a Raspberry and a Modbus device. If I connect a Fritzbox router in between, I can reach the Modbus device via the PI, but not with a direct ...
0
votes
1
answer
257
views
openai python module installation issues
I am having issues with downloading the openai python module onto a raspberry pi 5. I know I'm supposed to download in a virtual environment first then deactivate and download globally but that hasn't ...
0
votes
0
answers
105
views
Rotary encoder issues
I currently have a 600 p/r encoder hooked up to a pi 4. Seems to work ok, but due to the pi OS (bookworm) it usually misses some counts. From what I read, it seems that there are 2 possible ways to ...
0
votes
2
answers
106
views
programming Raspbery pi model B remotely
recently I have acquired raspberry 1 model B for a very cheap price. I want to learn some python on it but Desktop version is super laggy and command line isn't very practical for code writing. I know ...
1
vote
1
answer
128
views
Unattended upgrade is ignoring python packages
unattended upgrades is not upgrading the python packages that are available for upgrade. Other packages do get upgraded, for example raspberrypi-sys-mods got upgraded last night.
pi@raspberrypi:~ $ ...
2
votes
0
answers
82
views
Python GPIO scripts in background and command line concurrently?
I have a python script running in the background 24/7 on a Raspberry Pi. It waits for a GPIO input (IR sensor high for 10s) and triggers a GPIO output (SMS trigger to a router). It uses a locked ...
1
vote
1
answer
259
views
Problem with GLIBC when running executable on Raspberry Pi 3 Model B
I created a executable file on the raspberry pi 3 using pyinstaller. Did the regular changes to the .spec to include my other files and attempted to run it... Nothing. So, I went into terminal and ...
0
votes
1
answer
1k
views
GPIO chip Device or resource busy error
I am trying to control a E-Paper display using my Raspberry Pi 5. I want to use the gpiod library since it seems to be the best option (especially since RPi.GPIO is not supported on the Pi 5) together ...
0
votes
2
answers
308
views
Why isn't the display environment starting with this script at boot?
I have a Raspberry Pi 4 running Debian GNU/Linux 12 (bookworm)
I have a Python script in a shell file launcher.sh (with executable for all permissions) that runs happily without complaint if I ...
-1
votes
1
answer
211
views
Converting pigpio code to Gpiod library python
I have the following code of pigpio library and I have to convert it's functionality using gpiod library. Where pigpio has a good documentation I can understand the working of previous code using that....
0
votes
2
answers
3k
views
ModuleNotFoundError: No module named 'libcamera'
I have a Zero 2W and OS Lite 32-Bit inside. All I want is a python program that sends camera footage with UDP protocol and saves footage SD card inside as a video.
So I wrote this program which worked ...