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
4
votes
1answer
2k views

motion detection and recording video with webcam

I want to record a video with a webcam when a PIR sensor detect motion, I have the picamera library installed, can any one help, thank you? import RPi.GPIO as GPIO import time import picamera import ...
4
votes
5answers
11k views

How do I start two different Python scripts with rc.local?

I have two different Python scripts I'd like to run at start-up on my Raspberry Pi A+. Both work perfectly if I run them via sudo python filename.py. I can get the first one to run, but not the second ...
4
votes
1answer
1k views

One channel relay control

I'm trying to connect a small one line relay to my Raspberry Pi but the relay doesn't react. The red light on the relay is on the whole time. #!/usr/bin/python import RPi.GPIO as GPIO import time ...
4
votes
1answer
436 views

Why is everything a background process?

I am new to RaspberryPi, I am using RaspberryPi 2 with windows 10 core, using visual studio 15 community for development. Under C# code template and python code template why is everything a background ...
4
votes
1answer
309 views

Pi Glow programming on python

After following the steps on this page. I did everything correctly and when I try to run the test.py file it says this. Traceback (most recent call last) : File "test.py" , line 9, in <module&...
4
votes
2answers
3k views

Python Synth with Raspberry

I'm trying to create a synth using python with raspberry pi. I've written the code for manipulate the gpio input (i've modified the electronic of an old pianola and connected it to raspberry with the ...
4
votes
2answers
9k views

I can't download PyCharm for Raspberry Pi 3

I have had my raspberry Pi 3b for a few months so I'm just getting used to it. I would however want to install PyCharm because I want to use my Pi to program on rather than my PC. Any ideas would be ...
4
votes
1answer
265 views

How to make sense of this Raspberry Pi project guide for building a theremin?

I have just started out using a Raspberry Pi, and for my first project, I wanted to build a pseudo theremin using an ultrasonic motion detector and other electronic components (requirements are laid ...
4
votes
2answers
748 views

Can no longer send emails with Python

I was having issues with the Pi so I put a new image of Jessie on it. I reloaded a python script that has been running for a year and a half that sends a email. Now when it tries to send the email I ...
4
votes
0answers
727 views

/sys/class/gpio values only working if python gpio script was used before [closed]

i have a problem with the gpio sysfs files. when i use cat to get the values of a gpio pin it will always show 0. but after using a python script ( https://github.com/elParaguayo/RPI-Info-Screen/blob/...
4
votes
4answers
3k views

Speech Recognition

I'm making a project that requires the user to control the computer through speech. I've seen a couple of libraries, for python, that can do this but most of the ones that I have seen are windows only....
3
votes
3answers
8k views

Debouncing buttons with RPi.GPIO — too many events detected?

I'm using RPi.GPIO to handle events from a simple pushbutton. Pushing the button connects the associated GPIO pin (4) to ground. I would like to trigger an event when the button is released (e.g., ...
3
votes
3answers
16k views

I changed my Raspberry Pi default keyboard settings. How can I reset this change?

I changed my Raspberry Pi keyboard (using command the sudo nano /etc/default/keyboardp). I set: XKBLAYOUT = 'in' Now, after reboot I just can't login! Can I somehow reset this CHANGE?
3
votes
2answers
9k views

Can't install Flask-Bcrypt: `libffi` is missing

I try to install Flask-Bcrypt on Raspbian to hash passwords in my Flask application, but I get this error: Searching for flask-bcrypt Best match: Flask-Bcrypt 0.7.1 Flask-Bcrypt 0.7.1 is already the ...
3
votes
2answers
1k views

How to view outputs in a terminal window of a Python application launched at start-up?

I've created a python program that is launched at start-up. To launch it at start-up I've appended a row to the file /etc/rc.local as follow: sudo python3 /home/pi/myProgram.py Every some seconds, ...
3
votes
3answers
743 views

Is my code too intensive on the cpu?

I am currently building a remote controlled car with the RPi model A+. I am using pygame to run a continuous loop to check the states of the desired keys on the keyboard(w,a,s,d) and based on that run ...
3
votes
1answer
833 views

Importing RPi.GPIO

I am just writing some code for a Raspberry Pi robotics project. Since I don't have a Pi set up as a workstation, I am using a Google Drive notepad to do write it in, which recognises Python syntax ...
3
votes
6answers
30k views

How to install python3-matplotlib on RasPi?

I hope there is a simple way to install python3-matplotlib package on my RasPi. My OS is raspbian. I've tried already: sudo pip3 install matplotlib (command gcc failed with exit status 1) also: ...
3
votes
2answers
16k views

Use PyDrive to upload files to Google Drive folder

I'm using PyDrive to upload files to Google Drive but could not figure out how to define the destination folder. The following code saves a copy to the root on GDrive: gauth = GoogleAuth() drive = ...
3
votes
1answer
294 views

Can the Raspberry Pi 4 better distribute Python scripts to all four cores?

This relates to previous questions regarding the GIL (Global Interpreter Lock) for Python on the Raspberry Pi. My question has to do with the new processor on the Pi 4 - does it still have the same ...
3
votes
3answers
7k views

5v Relay will not close (unless using GPIO cleanup)

This seems like it should be really simple, so maybe I am missing something. I am just trying to open and close my relay but all it does it open's and doesnt close. I can use GPIO.cleanup() to make it ...
3
votes
1answer
10k views

Threading with GPIO and Buttons

Following the RPI Education Manual I am trying to check if the button has been pressed in a separate thread so i can continue the rest of my program, I have followed the Manual exactly but I must ...
3
votes
2answers
5k views

Best way to create a web frontend for Python-based automation project

I have a pretty big Raspberry Pi project for controlling a Paludarium (see http://www.paluweb.nl ). The entire automation is done in Python, and the Python scripts talk via the serial port to +- 12 ...
3
votes
2answers
566 views

Why is 14 (board numbering system) listed as a GPIO pin, and not 13?

>>> RPIO.RPI_REVISION 2 >>> RPIO.GPIO_LIST_R2 (2, 3, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 22, 23, 24, 25, 27, 28, 29, 30, 31) Pin 14 is ground, shouldn't this be pin 13 instead?
3
votes
3answers
3k views

When does the OS kill an application?

I have an application which polls a bunch of servers every few minutes. To do this, it spawns one thread per server to poll (15 servers) and writes back the data to an object, however sometimes the ...
3
votes
1answer
63 views

Alternatives to Matlab - Running Matlab code in Raspberry Pi [duplicate]

I have to run some Matlab scripts on Raspberry Pi. As per my understanding, Matlab is quite heavy and cannot be installed on Raspberry Pi. Are there any other safe alternatives? My Matlab code does ...
3
votes
1answer
513 views

Is there a way to read the pullup status of a GPIO pin in python with, or if not, without pigpio?

I've discovered pigpio and am starting to learn to use it with Python. I thought I would use it to "discover" the pullup status of a pin before setting it, but while mode has both .set_mode() and ....
3
votes
2answers
6k views

PIL.Image from picamera.capture()

I want to get an image from the pi camera module and use the pillow imaging library to modify the image. The way I have been doing it up to now is to take a picture with the camera and then open that ...
3
votes
2answers
24k views

How do I pass a variable to a python script run from crontab? [closed]

I am running a python script using the following command: 0,30 * * * * python /home/pi/pythonscripts/script.py & and I would like to pass a variable 'test' to the script in the crontab, ...
3
votes
4answers
29k views

Update Python version on Raspbian

So I got my Raspberry Pi with NOOBS and decided to use Raspbian. Then I wanted to test a python script I wrote with python 3, and it threw me an error, because I used an unknown import. Then I ...
3
votes
2answers
6k views

Setting camera module to /dev/video0 to scan QR Codes using zbar

I'm trying to use the library zbar to scan qr codes using Raspberry pi's camera module. I've connected and tested the camera, but I don't know how to access that from the library because it isn't on /...
3
votes
3answers
8k views

2.8" TFT Touchscreen with pygame script from console

I have recently gotten the Adafruit 2.8" TFT Touchscreen I've got it all set up and working correctly. All of my touchscreen calibration went well and appears to be functioning correctly. I am now ...
3
votes
1answer
17k views

Does Raspbian come with tk?

I'm considering writing a graphical front-end for low-end wearables (why should the wealthy have all the fun) featuring our prized Raspberry Pi. I know that TK is the standard for python, however I ...
3
votes
2answers
4k views

Which framework is best to communicate with Internet?

I see a lot of tutorials who use node.js with Raspberry pi (and even with the Raspberry Pi and Arduino working together). I also see a lot of examples in Python (Python is already installed in ...
3
votes
1answer
220 views

Multiple /etc/rc.local?

I run a Python program in a screen session which is started from my /etc/rc.local with this command: su me -c "screen -d -m /usr/bin/python /mnt/usbdrive/pgms/mypgm.py" Recently my program has been ...
3
votes
2answers
185 views

why GPIO.LOW is used to turn the switch on?

I am learning raspberry pi and somewhere i found the tutorial of turning the bulb on when clap is heard and off the bulb when clapped again. The following code was written for this to work #!/usr/bin/...
3
votes
1answer
1k views

I can't get RPI.GPIO working

I have just gotten a raspberry pi 3 model b for x-mas. In a short time I have come a long way. In a python script that I am making, I need to control two buttons (sense what one is pressed) so button....
3
votes
2answers
5k views

Smoke sensor MQ-135

Does Smoke sensor MQ-135 need to be connected to ADC if it has separate pin for analog and digital outputs? I'm about to interface it in raspberry pi.
3
votes
1answer
2k views

RPIO not working on Pi Zero, Pi2, or Pi3

How do you use RPIO on a Pi Zero, Pi2, or Pi3? When I run an RPIO script I get a Python error message such as RuntimeError: rpio-pwm: Page 0 not present (pfn 0xa100000000015bba)
3
votes
2answers
1k views

How to make a Minecraft door in python on Minecraft Raspberry Pi edition

I have tried many times placing a door but all that seems to appear is the bottom half. How do I get the top half? My python code is: mc.setBlocks (10,11,16,10,10,16,64)
3
votes
4answers
2k views

How to know when the pi finished shutting down

I wrote a python program that boots with pi, do it's job, and shutdown pi when finished working. It works fine, and when I'm connecting an lcd to the pi, I can know whether the pi finished shutting ...
3
votes
2answers
4k views

Getting extremely low fps on Rpi 3 while image processing

I am working on a project that requires image processing to detect a traffic light and take action based on its status (on or off). I initially developed the code on my PC, using OpenCV and Python, it ...
3
votes
3answers
7k views

GPIO.wait_for_edge on 2 channels at once?

So, I have 2 buttons set up on pins 17 and 27. buttons = (17, 27) GPIO.setup(buttons, GPIO.IN, pull_up_down=GPIO.PUD_UP) I need to accept input from EITHER of these for a set period of time. I ...
3
votes
1answer
369 views

Help lighting LED via GPIO pins

So I got an RPi and a canakit, I'm trying to follow a guide to get a simple program to make the LED blink. I have very little experience with RPis so it's probably a very simple error, but I can't ...
3
votes
2answers
2k views

Raspberry Pi and serial only working one shot

I am using a USB-to-serial adapter to let the Raspberry Pi talk with some motor controller through the serial bus. I made the following Python script: #!/usr/bin/ipython import serial import time ...
3
votes
2answers
225 views

Spotify 'one touch' player for disabled user

I'm trying to create a 'one touch' system for a disabled user to play a Spotify playlist - the Raspberry Pi seems an ideal candidate for this project. Info: User can only hit a plastic switch (like ...
3
votes
2answers
3k views

9 Data Bits on UART pins?

I am wondering if it is possible to send 9 data bits framed with a start/stop bit at 1.25MBaud. I am currently using PySerial to configure the UART pins on the pi. I've stumbled across a few ...
3
votes
1answer
2k views

GUI for Pi - Python or Java

I would like to know whether a Java based (using Pi4j library and Swing) or Python based GUI (using Tkinter) is more suitable for Pi in terms of execution speed. Following things need to be ...
3
votes
3answers
7k views

Multiple Callbacks from GPIO interrupt

I created a quick program that uses the GPIO library to create an interrupt with a callback that is initiated when a (pink) button is pressed. It works, but when the button is pressed and then ...
3
votes
1answer
1k views

Options for a kid to write a 3D game in Python?

I'm a programmer and would like to help my son learn to program a 3D game in Python that can run slowly on the RasPi or quickly on a PC. I thought about using the RasPi edition of Minecraft, but it ...