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
2
votes
3answers
6k views

How to read a long int via i2c?

I tried to connect an Arduino Uno with my Raspberry using the i2c bus, with code and wiring suggested here. This example is sending only one byte from RPi to Arduino and back, and everything works ...
2
votes
3answers
248 views

Multiple GPIO Buttons

I've seen a tutorial here that shows me how to do this: But what I want to do is like this: I want to have multiple buttons and distinguish between them. The graphic I painted depicts the desired ...
2
votes
3answers
5k views

Starting Python Program with Screen Automatically

I'm trying to turn a headless Pi into a single purpose computer. The application I wrote uses a ncurses GUI and I want it to start on boot. The program also needs to be run on a separate 'screen' (...
1
vote
5answers
16k views

Python run script in new console on startup [duplicate]

I try to start a python program (for accessing the camera, but that is irrelevant) every time the raspberry pi boots. The tutorials I read said one should add the corresponding command in /etc/rc....
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 ...
1
vote
2answers
301 views

Runtime error A PWM object already exists for this GPIO channel

iam new to raspberry pi and i got an error while a running servo motor in my object detection script i need to run the servo whenever my if condition is true so the same pin run multiple times if ...
1
vote
2answers
866 views

Reliable way to play sound (ogg, mp3) in Python, on Pi Zero W

I have been trying to find a reliable method to play sound on my Pi Zero W, in Python. By default, Zero does not have audio output, but I have set up an I2S amp and speaker, following this guide: http:...
1
vote
2answers
252 views

raspberry pi 2 raspicam auto start problem

I write a python program opencv and python. also I'm using raspicam and I want using my python program without keyboard and mouse. Of course auto run mode. I tried two ways like below and I can't find ...
1
vote
3answers
352 views

No access to USB port, when running python script on boot

I have a python script running with an RFID reader. The script runs fine when ran from terminal. When I add python /home/pi/script.py & to /etc/profile and reboot the Raspberry Pi, the scripts ...
1
vote
1answer
74 views

Why is SPI not working on any of my Raspis?

I tried it on both Raspi 3 and 2 using the SpiDev python library. I've never even seen any kind of output on MOSI or CS lines with my oscilloscope. Controlling an SH1106 OLED display via the luma....
29
votes
2answers
41k views

How to program a USB device with Debian/Python

The Pi is being promoted as an educational device primarily for Python. Inline with this, there have already been some great examples online of people accessing the GPIO from Python. However, most ...
14
votes
4answers
26k views

Can Python control normal Minecraft, or only the RasPi Edition?

My son wants to make a game in Python that is materialized in Minecraft. If he does that using the RasPi Edition, can that same Python code control the normal Minecraft on a PC? My guess is that ...
8
votes
2answers
28k views

installing OpenCV 3.0 on raspberry pi b+

Is it possible to install OpenCV 3.0, opencv python on Raspberry pi b+? How to install and are there any precompiled binaries available ?
14
votes
4answers
45k views

How can I lower the usage of CPU for this Python program?

I will be having a Python run 24/7 in a while loop, here is an example of the sort of program: while True: print ("me again...") But when I run it, my CPU goes to 100%! But I don't want that ...
8
votes
2answers
17k views

What's the right way to run a python script as a daemon (service) in raspbian (or debian)?

I'd like to use my Pi as a home thermostat, with the control loop running in a python script. I want to run it as a daemon on raspbian (debian) at startup. There's an example bash script in /etc/init....
8
votes
3answers
82k views

How do I display an image file (PNG) in a simple window?

I've got a prototype I need to show for an RFID project. I've got the RFID (Parallax USB) working, and the sample Python script (my first) is displaying the ID of the card just like it's supposed to......
6
votes
2answers
10k views

Pi camera v2 - fast, full sensor capture mode with downsampling

I've a Pi camera v2 which I'm planning to use with an RPi3 for a computer vision project. I need to capture full sensor images from the camera - no cropping. The resolution actually used by the ...
6
votes
2answers
6k views

Implement a GPIO function with a callback calling a asyncio method

I am testing a sensor attached to the GPIO in raspberry using python 3.5. The idea is something similar to this link. My code is: gpio.add_event_detect(4, gpio.RISING, callback=lambda x: self....
5
votes
1answer
5k views

How do I boot the RPi into a python GUI instead of Raspbian desktop?

I've been trying to get the RPi to boot into a custom python script that constructs a simple GUI using pygame, but nothing I attempt has any success. What are the steps I need to follow to get this ...
4
votes
3answers
6k views

Automatically start python program at start-up

I am working on a project that needs a special GUI that takes up the full screen. I know I can make the X-Window system start up on boot (using raspi-config then changing the setting) but is it ...
15
votes
3answers
80k views

How to correctly install the python RPi.GPIO library

I downloaded RPi.GPIO 5.3a from here: https://pypi.python.org/pypi/RPi.GPIO I extracted the tar file, cd into the folder and ran: sudo python setup.py install It ran through a bunch of stuff and ...
11
votes
1answer
16k views

Sound recording using python

I'm trying to record some sound with RPI using python and pyaudio library and facing a few interesting issues - junky console output when attempting to use pyaudio and lots of noise mixing into the ...
7
votes
4answers
26k views

Ping a website and have an output turn on if online/offline?

I am new to python and programming the Pi, my aim is to make it ping a server such as a gaming server or website and tell me if it is online or offline. So far I have looked everywhere but nobody ...
6
votes
1answer
7k views

Pygame from console with PiTFT

I wrote a simple script that uses pygame to display the information. However, I found that it won't display on screen when I call it from terminal through SSH. I found this guide/solution on adafruit, ...
6
votes
2answers
2k views

What's the RPi camera board called (internally)?

I connected a Rpi-camera board to the camera socket on my RPi (not a usb webcam). I have been searching the internet on how to call the camera in Python. The camera works (raspistill and raspivid both ...
1
vote
2answers
4k views

Run python script at startup with Systemd service

I am having troubles running a python server script at startup on my RPi 3 B+. I created a python file and placed it in /home/pi/Desktop/scripts/bulb.py, it contains the python interpreter should be ...
9
votes
2answers
11k views

Can I run Selenium webdriver using Firefox as the browser?

I would like to set up the Raspberry Pi as a client that exclusively runs FireFox as a client in a Selenium grid. Has anyone tried and got this to work? Are there any tips or pitfalls that I will ...
8
votes
1answer
15k views

How to use the water flow sensor with raspberry?

I'm trying to use this water flow sensor with raspberry: https://www.adafruit.com/products/828 I'm using this python code to read the pulses: #!/usr/bin/env python import RPi.GPIO as GPIO import ...
7
votes
1answer
1k views

Raspberry Python Libraries

I am currently working with a Raspberry Pi (Model B+) and have some experience with Arduino (and it's derivates). Now, there are three Libs for GPIO access with Python for the Pi: WiringPi (...
6
votes
2answers
29k views

How to download and install Python 3.5 in Raspbian

Tried to use sudo apt-get install python3.5 and it's telling me that it can't find it. Have tried updating. Not sure what else to do.
5
votes
3answers
28k views

Python serial permission issue

I'm trying to connect my Arduino to my RPi through python and PySerial, and I'm using the following code: import serial ser = serial.Serial('/dev/serial/ttyACM0', 9600) and I was getting an issue ...
5
votes
1answer
2k views

PWM Control on Raspberry PI

Alright so I understand this question is fairly saturated, but my use in pwm is for two differing pieces of hardware. (Sourced from: https://www.modmypi.com/blog/raspberry-pi-gpio-en-franais) From ...
3
votes
1answer
839 views

RPi.GPIO mysteriously crashing when setting up pin

I'm trying to test the following simple "blink" RPi.GPIO Python script. import RPi.GPIO as GPIO LED_PIN = 18 # GPIO 18, (P1 pin 12) print 'A' GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme ...
3
votes
2answers
5k views

PIR Sensor Consistent False Positives

So, I'm trying to set up my raspberry pi to take input from a PIR sensor in order to automatically turn on a monitor when it detects motion. If no motion has been detected in 60 seconds, the monitor ...
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
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 ...
2
votes
3answers
9k views

PHP + PYTHON + LIGHTTPD + Raspberry Pi GPIO to control the Robotic Arm

I was able to control one arm of an OWI-535 (Maplin) Robot Arm using GPIO pins and python programming (via L293 driver) , so I tried to do the same using a web page created in PHP. Created buttons ...
2
votes
1answer
9k views

GPIO pin output stays high after setting to low

I'm working on a project in which I have to set a GPIO pin of the Raspberry Pi to high/low in order to signal a transponder which in turn communicates with a lock and opens it when it receives a high ...
0
votes
4answers
7k views

How do I get a GUI program to run before the login screen?

I have a Python (Tkinter) GUI program that displays fullscreen and shows some pictures. I want the following functionality: When the Pi is booted up, the python program is run with the appropriate ...
12
votes
3answers
40k views

Installing Python 3.4 on Raspberry Pi

Is it possible to run python 3.4 on a Raspberry Pi? Currently I have python 3.2, but the odd thing is that running sudo apt-get update sudo apt-get install python3 results in my Raspberry Pi ...
12
votes
4answers
6k views

How to include RPi.GPIO in a python CGI script with lighttpd?

I've recently setup python to work with lighttpd via CGI (see here). But the minute I go to include RPi.GPIO, the script stops executing (I'm assuming because no HTML gets output), but there is no ...
11
votes
3answers
20k views

Why cleanup the GPIO pins?

When running a program in Python, why would I want the cleanup command when using the GPIO's?
9
votes
4answers
10k views

12V device to a Raspberry Pi

For my school engineering project, I have a coin acceptor device which I would like to link to the Raspberry Pi. However the device requires 12V in power. I have an idea of what to do to power the ...
8
votes
3answers
623 views

How does init get to know about power events?

I have a Pi Model B Rev 2.0 (I think) and I intend to use it for a Home Automation system. As I have a prepayment meter on my electricity supply I occasionally run out of electrons to go around my ...
8
votes
14answers
42k views

PiCamera not Working

For starting the camera I am doing >>> import picamera >>> camera = picamera.PiCamera() mmal: mmal_vc_component_enable: failed to enable compononent : ENOSPC Traceback (most ...
6
votes
3answers
10k views

YOLO or SSD on raspberry pi

I've run yolov2 on my Raspberry Pi 3 but I got 1 frame each 13s (which is pretty bad for live object detection). I've also tried an SSD but the results were terrible too. Is there anything I could do ...
5
votes
2answers
2k views

Impossible to scan RFID tags using libnfc, PN532, and RPi3

I recently bought this NFC/RFID reader PN532 module V3 I want to use it with my raspberry pi 3. I have install and configured the library libnfc. The PN532 is connected with I2C. I have well enabled ...
4
votes
1answer
9k views

Activate virtualenv & start script on boot - RPi

I am trying to start a python script that exists in a virtualenv from bootup on my RPi. From reading this post and the RPi rc.local post I know that I will have to add something like this to /etc/rc....
4
votes
1answer
8k views

Custom White Balancing with picamera

I need a method to set the White Balance of the raspberry pi camera by "teaching it". Such as it is in DSLR cameras, I'd like to show a white picture to the camera and say "OK, this is white, now ...
4
votes
2answers
2k views

Raspberry Pi camera doesn't work only displays red light

When I run my code, I get this error: No data received from sensor. Check all connections, including the Sunny one on the camera board The red light on the camera module glows, but doesn't ...