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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
34 views

Logging data from High Precision AD/DA board using Raspberry Pi 3B

I have a High Precision AD/DA board from waveshare with Raspberry Pi 3B (running on Raspbian). With this setup, I get a sampling rate of above 20KPS at my terminal display. However, I can write only ...
user avatar
0 votes
1 answer
32 views

hc-sr501 goes high every minute

So I bought three HC-SR501 PIR and all of them keep trigging (high) every single 60 second on the dot. I don't know what I am doing wrong. The PIR does detect motion when a person is moving but it ...
user avatar
  • 1
0 votes
1 answer
12 views

Python program runs successfully through Thonny IDE but I get ModuleNotFoundError when I run the same through Terminal

I have a python code for attendance system which I'm trying to run in raspberry pi. I'm using python 3.9.2 and have installed all the required libraries through terminal. The code runs fine in Thonny ...
user avatar
  • 3
0 votes
0 answers
25 views

How to open website with Python with 'sudo' permission?

I am writing a Python script to run on Raspbian that opens a webpage using webbrowser.open() and also writes to the GPIO pins to control some external LEDs. The problem is that writing the GPIO pins ...
user avatar
0 votes
1 answer
22 views

How to decode struct data sent from an Arduino via NRF24L01?

So basically I'm sending this struct data from my Arduino to my RPi, both fitted with an NRF24L01 module. Library on the Arduino is tmrh20, and on the RPi, BLavery. struct values{ char ...
user avatar
0 votes
0 answers
31 views

I2C sending data from arduino to python gives gibberish data

It's my first time working with SMBUS and I've read the docs of arduino and the Wire object. It states that I can send a string. To quote the docs: string: a string to send as a series of bytes. https:...
user avatar
-1 votes
0 answers
17 views

Wrong sound output when using pygame

I am using a raspberry pi 4 and am having issues with the sound output. I am trying to run a program in python using pygame to play an audio file when I run the program. The program works and it plays ...
user avatar
-1 votes
0 answers
25 views

Running a parallel buzzer function

FIXED: I didn't know how global variables work, had to specify that "warning" is global in each function. I am making a camera that is looking for red objects and when one is detected, the ...
user avatar
0 votes
0 answers
29 views

GPIO script that counts each time a reed switch is activated

My goal is to attach a magnet to a hamster wheel and use a reed switch to determine the distance traveled and speed of my hamster over a long period of time (several weeks/months) and output it as an ...
user avatar
0 votes
1 answer
32 views

I am trying to make a camera turn on and off with the press of a button, but the GPIO ports are not working, and it is not acknowledging the button

I am using python, and I am getting an error where it says "GPIO.output(24, False)" in the else statement. I don't know what it means, or how I fix it. from picamera import PiCamera from ...
user avatar
0 votes
0 answers
21 views

How to autorun a python script running ssl on raspberry pi startup

I am working on a project on a Raspberry Pi. I am trying to autorun a Python script automatically when the Raspberry Pi is powered up. However, this Python script generates an HTTPS link to access a ...
user avatar
0 votes
0 answers
27 views

Raspberry Pi Speedometer

I am using a raspberry pi to track information from an animals running wheel such as distance travelled and speed. I am using a script (source: https://drive.google.com/file/d/1kKWoHWWLt008tQB-...
user avatar
1 vote
0 answers
71 views

Python code not working: Programming a motor to turn on using a switch (Raspberry Pi)

HELP! Ideally within the next 24hrs PLEASE!!!!! We have a simple circuit where we have a button, that when pressed, starts a motor that needs to run at a certain speed for a certain amount of time. (...
user avatar
  • 11
0 votes
0 answers
26 views

Back and forth communication between Pico and PC

I am making a Pico powered PWM fan controller, and I currently have 2 potentiometers to control the fan speed. I am however thinking about writing some software in Python to modify the speed. The ...
user avatar
0 votes
0 answers
28 views

pybluez bad install

Yesterday I installed my Raspberry Pi OS Lite (Debian Bullseye) using Raspberry Pi imager on my Mac. Everything in the most straightforward, up-to-date version. Today I began working with Python. ...
user avatar
0 votes
0 answers
40 views

Help! GSM/GPRS/GNSS HAT - SIM 868

have be struggling for a while with this bit of Python. I have not wrote this code it got installed with the the tracker from this website (https://medium.com/@onehitwonder/how-to-build-a-raspberry-pi-...
user avatar
1 vote
1 answer
61 views

I'm unable to install FLAC on my Raspberry Pi 3

I'm trying to make a tts program on my Raspberry Pi 3 and I'm using Googles TTS API which requires that I have FLAC installed on the Pi. When I attempt to install FLAC, I'm thrown this error- pi@...
user avatar
0 votes
0 answers
24 views

How to use 'bcm2835' to control 'PmodAd1' so that he can at least 500KSPS sample rate?

my device is 'raspberry pi 3' I am using 'PmodAD1', a 12bit ADC with 1Msps sampling rate https://digilent.com/reference/pmod/pmodad1/start Due to linux's 'spidev' system, my sample rate is compressed ...
user avatar
0 votes
1 answer
28 views

bcm2835_spi_begin failed. Are you running as root?

I use bcm2835's mcp3008 sample program to export to .so Then use ctypes to draw .so in python But in the process of compiling python, the following error is thrown bcm2835_spi_begin failed. Are you ...
user avatar
0 votes
0 answers
61 views

How do I calculate the transmission of a mobile robot?

I have some questions about implementing a mobile robot. I have an old construction mobile robot wherein this robot the main controller has been removed, and I put in its place a Raspberry Pi 4. I ...
user avatar
0 votes
1 answer
26 views

Storing Database or installing program on USB drive

I am planning to use by old Raspberry Pi Model B for webscraping with a python script. The data stored will eventually get huge (in GBs). So my SD card will run out quickly. I have a larger capacity ...
user avatar
0 votes
0 answers
27 views

How can I modify my sampling rate using methods other than DMA?

The ADC module PmodAD1 I am currently using with 1M sampling rate and 12bit resolution I use spidev as a library to connect to ADC But it seems that he can only sample up to a sampling rate of 20KSPS ...
user avatar
0 votes
0 answers
20 views

How to use adc to receive 40khz and 43khz modulated signals?

I am currently using thePmodAD1 in this mod for signal reception This is my code from DesignSpark.Pmod.HAT import createPmod import numpy as np import pandas as pd import matplotlib.pyplot as plt adc =...
user avatar
0 votes
0 answers
12 views

Connecting to mysql server with python tls

I am trying to implement TLS in mysql and everything works with in connecting to it except a python code in the raspberry pi. the code looks like this: import mysql.connector import mysql.connector....
user avatar
  • 1
0 votes
0 answers
31 views

Detect motor running physcially

I'm using the pigpio library to run my motor in my Raspberry Pi like below. ESC = 18 esc_pi = pigpio.pi() esc_pi.set_servo_pulsewidth(ESC, 2000) I'm wondering is there any way to detect the motor is ...
user avatar
0 votes
2 answers
57 views

GPIO detects rising edge but does not change status to 1 [closed]

I am really confused: I have a lightbarrier connected over an optocoupler (ACPL-827) with my Raspberry Pi. When the lightbarrier gets triggered (detects a rising edge), it calls the scan-function. ...
user avatar
0 votes
1 answer
159 views

How to run libcamera-still in python trough crontab?

I'm trying to make a time lapse using crontab to manage time intervals. The camera I use is an arducam Autofocus imx519. The libcamera-still command works normally when run via terminal. But when I ...
user avatar
0 votes
1 answer
148 views

AttributeError: module 'RPi.GPIO' has no attribute 'ChangeDutyCycle'

Starting Day 2 troubleshooting this error. Code used to work on a previous rasp pi 4B but doesn't on a new one so I'm assuming I'm missing some breaking change. Problem: Using import RPi.GPIO as GPIO ...
user avatar
  • 143
1 vote
1 answer
50 views

How to check on which OS system the python program is running to import rpi.gpio?

Is there an easy way to let a python program check if it running on the raspberry Pi or the pc running windows? I would like to use this to automaticly use the rpi.gpio functions in my code. I am ...
user avatar
  • 13
1 vote
0 answers
22 views

adafruit_hcsr04 sonar not working on certain GPIO pins pi 4B

I have 8 adafruit_hcsr04 range finders wired in the exact same way to a raspberry pi 4 but only 4 of them work and i'm at a loss. I've verified with an ohmmeter the echo and trigger pins are ...
user avatar
  • 143
0 votes
0 answers
112 views

No module named RPi.GPIO even though it's installed

When running code import RPi.GPIO as GPIO import MFRC522 import signal continue_reading = True # Capture SIGINT for cleanup when the script is aborted def end_read(signal,frame): global ...
user avatar
  • 105
1 vote
1 answer
89 views

Reading data from GPS module using Python on Raspberry PI

I am using a NEO-8M Satellite Positioning Module on a Raspberry PI. I am trying to read data off the device using python. I am new to the Raspberry PI and Python. I can read data from the NEO-8M GPS ...
user avatar
1 vote
0 answers
25 views

Detect an unconnected pin on an MCP3008 [closed]

I have a couple moisture sensors loosely connected to an MCP3008 and was wondering whether it was possible to detect if a sensor is unconnected. I then tried to detect it with the channel voltage in ...
user avatar
  • 11
0 votes
1 answer
49 views

Can a raspberry pi get the video feed of another through a NFS server between the two?

For my project, I need to get the feed (preferably simultaneousely) of 2 pi cameras (one on each pi 4). As of now, both are communicating through ssh over wifi. It's very slow, not reliable and very ...
user avatar
  • 3
0 votes
0 answers
18 views

Running script from cmd for bluetooth connection

my project requires data transfer with android app via bluetooth. I’ve tested the code by running it in thonny and it works fine. Since I want to run the script as soon as raspberry pi boots up, I ran ...
user avatar
0 votes
0 answers
28 views

Using the camera on 64bit vs. 32bit from Java

I have Raspberry Pi 3 B. And a camera module v. 2.1. I have installed the Raspbian OS 64bit, the latest - "bullseye" Tried to record some video in any way, and after some experimentation, I ...
user avatar
0 votes
0 answers
56 views

How to use Raspberry Pi 4 with an USB to RS232 adapter cable over the serial port

I would like to use a Raspberry Pi4 to control a syringe pump [(see datasheet here and in particular the quick start manual on page1)][1] The connector cables I used are RJ11 from the Pump to RS232 (...
user avatar
1 vote
3 answers
62 views

Rpi GPIO code not working

Following commands work well as full speed PWM. echo "s 18 2000" >/dev/pigpio pigs s 18 2000 But following code do nothing. I am using Raspberry Pi4 8G B model import RPi.GPIO as GPIO ...
user avatar
0 votes
0 answers
118 views

Problem using OpenCV and Raspberry PI camera V2

I had been using the following code for the past two months with no problem whatsoever, however, just yesterday I have been getting errors using the code which I will detail as follows. The code in ...
user avatar
0 votes
0 answers
30 views

how to read keystrokes in RPi and send something else to PC?

I found this thread and a few others but they don't seem to consider that a keyboard is attached to the pi and that the primary data is sent from it -- rather, the pi just emulates. What I'd like to ...
user avatar
  • 1
2 votes
1 answer
137 views

How to PID control a heater with SSR, Raspberry Pi and python

I would like to PID control the temperature of a water bath using a RaspberryPi4, a solid state relay (SSR) and a heater (200W, 230VAC) using python. The IVMech library seems a good starting point. As ...
user avatar
1 vote
0 answers
29 views

SpiDev xfer not working when called from inside function

I have been working on integrating an absolute encoder using SPI (link to datasheet) into my project and have run into a problem with the SpiDev library for Python. When running the test script below,...
user avatar
  • 11
0 votes
1 answer
40 views

How to decrease RPi image capture time?

I have two camera connected to RPi (1 USB camera and 1 RPi camera). I need to capture both images to do some processing on them right after image capture I have this code: file1 = 'imagecapture' + '...
user avatar
  • 99
0 votes
1 answer
70 views

How to aggregate time-synced data from one RPi to another over bluetooth

I am currently working on a landslide-detection project coded in Python for a research group. At present we have two different sets of sensors running on two different RPis. One RPi has a strain gauge ...
user avatar
0 votes
0 answers
31 views

Background Python Script Stops Running After A While

I'm trying to use my pi as a temperature monitor. The purpose of it is to sense the temperature and humidity via a sensehat, log it to a database and a local csv and if it meets a certain range then ...
user avatar
0 votes
0 answers
41 views

Code works in Windows but not Raspberry pi (opencv)

I'm new to coding and using a raspberry pi. I've searched through many tutorials online and found a how to get OpenCV library into the pi itself and downloaded VSC on my laptop and the pi. The issue ...
user avatar
0 votes
0 answers
110 views

two raspberry pi 4 communication via BLE

I need to pass a stream of data from raspberry pi 4 to pi 4. and I downloaded /home/pi/Downloads/bluez-5.50/test/example-advertisement,and can successfully run it,two pi can connect,but I don't know ...
user avatar
-1 votes
1 answer
25 views

How to assign one input when matrix keypad key is held down?

I have a simple matrix 3x4 keypad that executes a function based on the code entered. However I'm running into the issue when someone holds down a key. I would like it to where only one value is ...
user avatar
  • 1
0 votes
0 answers
35 views

Playing video programmatically

How to play a video triggered by an external event (e.g. button push)? Previously, one could use omxplayer and DBUS but apparently that is not longer an option on Pi 4 and newer systems. From what I ...
user avatar
  • 111
0 votes
1 answer
80 views

Can we get the path of a USB drive programmatically(Python) when connected to a raspberry pi?

I am currently working on a small project on Raspberry Pi. I want to make my project as automated as possible. I have a code that saves videos to a USB drive. However, for it to work, I have to ...
user avatar

1
2 3 4 5
62