Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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.

640 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
1k views

Emulate a Bluetooth Keyboard with a Raspberry Pi 3

Raspberry Pi 2 Model B (Raspbian Wheezy and bluez 4.99) Executes perfectly using a Bluetooth dongle. Raspberry Pi 3 Model B (Raspbian Jessie and bluez 4.99) Attempting to pair with Windows laptop ...
2
votes
0answers
7k views

Using Python with Bluetooth on Raspberry Pi 3

Following this tutorial I successfully ran PiTooth on the RPi2MB (Wheezy). Following the same tutorial on the RPi3MB (Jessie) I get the following message "Could not configure bluetooth. Is bluetoothd ...
2
votes
0answers
406 views

Raspberry Pi Robotics: How to follow line?

I'm making a raspberry pi robot in Python and it moves, but it does not follow the line and I am using an infrared line sensor. I think that I have done everything properly. Here are some results by ...
2
votes
1answer
819 views

CWiiD doesn't detect wii remote but hcitool and blueman do

I have a raspberry pi 2 model B version 1 running raspbian that I am trying to get a Wii remote to work with. I have an Inateck Bluetooth 4.0 adapter plugged in to it and have CWiiD installed. When I ...
2
votes
0answers
1k views

SpiDev - spi.xfer([xxx]) -> Invaild argument error -> what?

I got trouble with a seemingly dumb-proofly simple code: import time import pigpio import spidev DS = 17 STCP = 27 SHCP = 22 MR = 5 spi = spidev.SpiDev() spi.open(0, 0) spi.xfer([0b10011011]) ...
2
votes
0answers
729 views

Low-latency SPI for MCP 3008

So, I am using the SPI interface on the Pi 2 model B to communicate with a MCP 3008 ADC chip, following the tutorial on http://www.raspberrypi-spy.co.uk/2013/10/analogue-sensors-on-the-raspberry-pi-...
2
votes
1answer
203 views

Stepper Motor Not Responding. Wiring Issue?

I am following the tutorial: But I am using a pi t-cobbler and a Pi 2. I am also using the ULN2803 driver. When plugging a button into the appropriate gpio spots on the breadboard, I am able to run a ...
2
votes
2answers
3k views

Python Serial library for RaspberryPi2 tutorial/command list

I have a problem with using the UART on RPi2. I tried every program found on the internet but nothing works. I checked every baud rate of my two BT modules but whatever code I use I've got errors ...
2
votes
0answers
966 views

OpenCV. Can't open video from usb camera on the screen

When I'm trying to start simple code, the frame opens and don't respond. import numpy as np import cv2 cap = cv2.VideoCapture(0) while(True): ret, frame = cap.read() cv2.imshow('AIR',frame) ...
2
votes
0answers
585 views

Error running a simple python script at boot

I am attempting to create a button on my Retro Pie emulator case (A gutted NES), using the old reset switch, to exit out the of current game and go back to the menu. Then I realized it just required ...
2
votes
0answers
119 views

GPIO goes high on first initial run of script - please help get my ECTO 1 on the road!

I am having a few problems with my script, on a fresh boot of my pi, the GPIO Port goes High and switches my relay when I run this script, however, it doesn't do it after I initially run the script, ...
2
votes
1answer
257 views

Stream MP3 file from Ubuntu source to Raspberry Pi using Python

I am a newcomer to Linux and Python and I am trying to attempt to stream an audio file (preferably MP3) from a Ubuntu source computer to a Raspberry Pi running Raspbian for immediate playback. I ...
1
vote
0answers
20 views

I don't know why suddenly mjpg-streamer and webcam stop working

I have made a program that uses three webcams and three ultrasonic sensors using raspberry pi 3 and python 3. When each ultrasonic sensors detect stuff in front of them, webcam take a picture of it. ...
1
vote
0answers
46 views

Pi freezes when running a script

I'm trying to set up a trap camera using a brand new Pi Zero W with Raspbian Buster but it freezes when I run the python scirpt. originally the code was a bit complicated with multithreading, email ...
1
vote
0answers
27 views

picamera error the second time I run camera.capture(output,'yuv')

I'm getting an error the second time I run camera.capture(output,'yuv'), what am I doing wrong? my code: from time import sleep from picamera import PiCamera from picamera.array import PiYUVArray ...
1
vote
0answers
17 views

LED Strip on Raspberry Pi Check if its On - Neopixel

How can I check if the one pixel is on or not? Is there any function for that. I've googled but couldn't find anything helpful. import board import neopixel pixels = neopixel.NeoPixel(board.D18, 17) ...
1
vote
0answers
17 views

Is raspberry able to retrieve/store some n time prior a trigger with multiple cameras?

I came across a project idea which I think would demand a lot from a raspberry pi and arduino hardware capabilities. From my understanding, a master raspberry could be used to trigger n slaves through ...
1
vote
0answers
75 views

Use OBDII over WiFi

I think i've tried everything at this point, and nothing seems to work. I'm using an ELM327 WiFi Dongle, connected it to the Pi, created a socat using: sudo socat pty,link=/dev/ttyUSB0,waitslave tcp:...
1
vote
1answer
75 views

Speed up SPI transfer

So I need to transfer a byte on the spi interface on raspberry pi. Here's my code in python import spidev import time import binimp fhandle=open("white.txt") initial=binimp.extract(fhandle,'192','...
1
vote
0answers
101 views

Develop a communicattion between a Raspberry with BLE server and a Raspberry with BLE client

I have been developing an small project which requieres a communication between two Raspberries, the first one acts as a Beacon and the second one tries to connect to that beacon and obtain the RSSI ...
1
vote
0answers
46 views

PiCamera vs VideoCapture

So I have a project that requires Computer Vision (video stream). But when I want to try my Pi Camera (not USB), there's two method that I can use. They are PiCamera.capture_continuous and cv2....
1
vote
0answers
20 views

Launch a python script in a lxterminal window using supervisord

I'm trying to launch a python script in a lxterminal window using supervisord. I'm stuck on using supervisord than a .desktop file. I'd like to keep the process running on loop Below is my config: [...
1
vote
0answers
32 views

PICamera white balance difference between preview and capture

Below is a screen shot of the preview and the captured image of the same scene taken from a single PICamera at the same time. As you can see the one on the left (the capture) is noticeably bluer than ...
1
vote
0answers
28 views

efficiency of python sleep function to set a raspi pin HIGH and pause the script

I am continuously measuring some parameters using Raspberry Pi. I am using Python. When the measured value is higher than a particular value, I want to set a GPIO pin high (for some LED indicator) and ...
1
vote
2answers
593 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
1answer
519 views

Why is PIR motion Sensor always on?

I'm trying to make an alarm system but the motion sensor is always on as soon as the script is run. I've posted a question about a different problem i was having with this project so it'll confusing ...
1
vote
0answers
113 views

Mouse Control Function in Python for Raspbian

Does anyone tried to control mouse cursor position and click in Python application for Raspbian before? I am refering to this website: https://pyautogui.readthedocs.io/en/latest/mouse.html#mouse-...
1
vote
1answer
225 views

How to toggle button on and off with gpiozero?

I can't seem to find a solution of doing this using gpiozero. I've done it using rpi.gpio with add_event_detect and call back to change state but I was under the impression gpiozero is much simpler. ...
1
vote
0answers
16 views

Can I use the hostname of my Smart Plug in my Python script throughout different WiFis?

I have a Python script which retrieves the measured data from a smart plug so that I can visualize it on my Rasbperry Pi. This command gets the data send_hs_command("192.168.1.26", 9999, b'{"emeter":...
1
vote
0answers
19 views

Running mongodb as as service increases boot time by 30 seconds

Title says it all. I have an RPi 3 with Raspbian that has a web app running at start up in chromium. It took 20-30 seconds from powering on to the app appearing before I added mongo, and after I ...
1
vote
0answers
287 views

Error opening USB Cam with OpenCV4: GStreamer-CRITICAL **: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed

After installing OpenCV4.0 on my RPi, i tried a simple script below with a Logitech USB Cam (720p) but at "cam = cv2.VideoCapture(0)" it gives me an error "(python:num process): GStreamer-CRITICAL **: ...
1
vote
0answers
235 views

Getting Error: ImportError: No module named 'cv2' in Geany python editor

I'd finally installed OpenCV 4.1.0-dev in my raspberry pi with success, I checked that in Terminal by : pi@raspberrypi:~ $ python3 Python 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516]...
1
vote
0answers
36 views

How to set access rights for lighttpd using python scripts (cgi) which uses temporary files

My problem is: I have a running lighttpd web server. The files are stored in \var\www, also a python script, which can be executed to get an image from the raspi camera. Every time the script is ...
1
vote
0answers
178 views

Multiple channel and multiple sound card

I need to do the following (if possible in Python): output at the same time on multiple USB sound card (cheap one you can find on Amazon) on the main audio file, I need to output temporary sound if ...
1
vote
0answers
73 views

Need help with Controlling WS2812B LEDS

I have made a 5 x 5 WS2812B RGB LED matrix to work with my raspberry pi. I'm trying to figure out how to run several tests from this tutorial: https://tutorials-raspberrypi.com/connect-control-...
1
vote
1answer
58 views

PIGPIO bit banging UART - SLR to plaintext

I've managed to read UART input by SLRO and SLR commands from pgpiod, however, SLR returns UART bit-banged data in the following format: [number of read bytes] [bytes] http://abyz.me.uk/rpi/pigpio/...
1
vote
0answers
154 views

Raspberry Pi/OBDII/Serial Communications over Bluetooth

Thanks for having a look at my post and my problem :) I'm presently developing an automotive on-board diagnostics scanner application in python3/wxPython. For the communications heavy lifting, I'm ...
1
vote
0answers
55 views

Issue with controlling GPIO via Flask web app

I am currently building a project in which I am using a Flask web app to control various different components with the pi's GPIO. The issue i am currently having is stopping the execution of code that ...
1
vote
1answer
101 views

Two stepper motors with python

I want to make a motorized rc paddle boat type machine for fun. I plan to use two stepper motors to spin two wheels on either side of the boat. I am controlling it with python. I have a master script ...
1
vote
1answer
51 views

Play a defined set of MP3's on defined days

am new to Python and have been struggling to create a workable script for a friends project - am hoping someone can point me in the right direction! The script is to control playback of mp3 files ...
1
vote
0answers
49 views

Supervisor config and certain python files

I need to start on boot and monitoring a python script with supervisor. The python script works when starting manually by sudo python getdata.py My scripy getdata.py executes subprocess.call(['bash',...
1
vote
0answers
151 views

Interrupts with MCP23017 using the mcp23017 dtoverlay

I'm at my wits end with this one. Okay, so we've got an MCP23017 with its INTA wired to the Pi gpio12 (bcm) in /boot/config.txt dtoverlay=mcp23017,addr=0x20,gpiopin=12 so far so good. I'm looking ...
1
vote
1answer
291 views

Feh in startup script only displaying images on reboot, not startup?

I have a Python script running on a Raspberry Pi Zero W that calls the image program feh in order to loop through some directories and display the enclosed images. The script is supposed to run on ...
1
vote
0answers
86 views

How to run a graphical program from a restricted user

I have two users. admin can see everything. pi is restricted. I have a tkinter python application. pi must be able to run the program, but it cannot read any of the files directly. There is a data....
1
vote
0answers
370 views

Selenium on raspberry - headless firefox not working as expected

i wrote a python code using selenium to interact with a headless browser. I altered the code a little for the use on the raspberry. The code for the PC works fine, but on the raspberry it stops to ...
1
vote
0answers
52 views

Raspberry Pi jammed after few days of continuous work? size full?

I made a project on raspberry pi 3+ and left it on over a weekend. After 4 days, when I came back, the program was not working. When I try to connect it with Remote Desktop, it was not working. I ...
1
vote
2answers
47 views

Cronjobs sometimes fail to run fully when launching many Python scripts

I have about 30 Python scripts that I have scheduled to run via cron. Usually, I can run cronjobs on a Raspberry Pi just fine but I usually also only do a handful only. These scripts are essentially ...
1
vote
0answers
80 views

Sense HAT LED matrix displays incorrectly

When I try to light up one pixel at a time, the whole column lights up. This happens no matter what color I set it to. The rainbow when the pi boots up is also distorted since the columns are lighting ...
1
vote
3answers
3k views

Serial to USB, no ttyUSB0

I'm trying to open a Serial communication between a Raspberry Pi 3 (model B, running on Raspbian) and a device (a traffic counter to be precise). I've a USB to Serial cable, using the rs232 standard. ...
1
vote
0answers
224 views

How can I pause a video of omxplayer with out using keyboard?

I am working on my project that can display video when a magnet (signal ) is detected using a hall-effect sensor. Then after, if the magnet is removed from the sensor the video has to pause (not to ...