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
5
votes
2answers
8k views

Upgrade from Python 2.7 to 3.3,x

How do I uninstall Python 2.7 and install the latest Python 3.3.x? Tried using "upgrade" but it didn't solve my problem.
5
votes
3answers
6k views

Connect sim800 to Raspberry PI (RX, TX)

I've been trying to connect my sim800L to my Raspberry pi 3 model B (rasbian) but without success... I'm at the very first step, and since I'm new to Raspberry pi, I don't understand very well how it ...
5
votes
3answers
8k 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 ...
5
votes
3answers
6k views

Cannot connect to PiCamera when using it with Flask

I am trying to create a live streaming camera with my Raspberry Pi and the Pi Camera module. I have chosen to create it with Flask so that I can use the Python API for it. Though when I run this ...
5
votes
4answers
8k views

How to use JSN-SR04T on a Raspberry Pi?

I want to try out JSN-SR04T, which is an ultrasonic distance measuring module, that is also supposedly water proof. The main reason that i want to try this module over the HC-SR04, is because the JSN-...
5
votes
3answers
4k views

OTA Update of Multiple Raspberry Pi's

I have 4 Raspberry Pi compute modules, running at different locations and I would like to run a script from the server that would connect and update the pi's with the latest version of the file found ...
5
votes
4answers
4k views

Read data from Si7021 via I2C

I have an Si7012 temperature / humidity sensor attached to the i2c pins on my Raspberry Pi. Specifically, I have the Adafruit "break-out" with this sensor attached https://www.adafruit.com/product/...
5
votes
2answers
2k views

Raspberry Pi to Arduino (Leonardo) avoiding latency

I'm using a Python script via (TkInter) on the Raspberry Pi to capture mouse movement and events. My goal is to send this data, in real time, to another connected Arduino device(Leonardo). My first ...
5
votes
2answers
2k views

Is running a CGI server as root too dangerous?

I've setup my Raspberry Pi with nginx and fcgiwrap as CGI. I wanted to control GPIO ports using a Python script with the Rpi.GPIO library. The problem is that in order to be able to control the ports, ...
5
votes
1answer
3k views

How to read the status of the Power-LED on Raspberry Pi 3 with Python

How to read the status of the Power-LED (or the rainbow square - if you like that better) on Raspberry Pi 3 to detect an low-voltage-condition in a python script? Since the wiring of the Power-LED has ...
5
votes
1answer
1k views

Does the Raspberry Pi support I2C multi-master configurations?

We are using Raspberry Pi 2 single board computers for test automation (they run our feature test against an actual DUT). Our Device Under Test (DUT) uses I2C multi-master mode to communicate with its ...
5
votes
1answer
621 views

I need to control 8 LED's but I can only control 3? [helpful pictures attached]

I'm very new to electronics in general, but I want to build a small project where I can individually control (from a GPIO pin) 8 LED's. From what I understand, each GPIO pin on the Pi (Pi2 model B V1....
5
votes
1answer
6k 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 ...
5
votes
2answers
15k views

Controlling a fan on a relay with python

I have a Raspberry pi Model B revision 2 and I've set up a mini 5v fan on a relay switch which i want to control with python now. I will be running a crontab every hour to check the temperature of the ...
5
votes
1answer
4k views

Hue saturation intensity histogram plot

I am using pi with raspbian wheezy and python 2.7. I have an image in jpg format which I can read and convert to array. But I want to convert the image from RGB color model to HSI color model and then ...
5
votes
2answers
6k views

How to install smbus to virtualenv?

How to setup python-smbus in the virtual env? Pip does not find any appropriate package. Is there a way to make main python installation's libraries visible to virtual env?
5
votes
2answers
5k views

Read keyboad input from background process

For a new project, I need to read input from a USB barcode scanner (that registers as a keyboard) and perform some actions on the "typed" text whenever the Enter key was pressed. The requirement is ...
5
votes
2answers
10k views

How to read data from arduino with raspberry pi via I2C

I have connected Raspberry pi 2 model B with arduino uno via Bi-Directional Level shifter. Raspberry pi GND ---------- GND Arduino 3.3v ---------- 5v ...
5
votes
3answers
2k views

Raspberry Pi/“Arduino” communication

I'm looking to use a raspberry pi to speak to multiple "arduino" ATMEGA328p ICs (through a logic-level converter). I figure I can do this reasonably well over the GPIO RX/TX and use qualifiers to let ...
5
votes
1answer
858 views

How to Check GPIO pins simultaneously?

Can you give me an idea on how to check the statuses of specific GPIO pins if it is HIGH or LOW? My project is all about checking the statuses of GPIO pins (6 GPIO pins). I want to check all of the ...
5
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....
5
votes
1answer
9k views

Print output not shown when run Python script CRON

I am automatically running a simple python program from start up using cron. The pi boots / automatically logs in, displays the command line and runs the python program but the print output (updating ...
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 ...
5
votes
1answer
5k views

smbus Import Error

I'm trying to use the module 'smbus' on python3. I've downloaded it - when I try to download smbus, it says that smbus is up to date and installed. However, when I try to use it, it says the module is ...
5
votes
1answer
1k views

Starting Browser from terminal and being able to control it via Python

I've got a Pi with a Adafruit TFT LCD installed. I'm using omxplayer and fbcp to stream videos at startup using python, like so: # Start Loop ct = 1 video_list = glob.glob('videos/*') os.system('...
5
votes
1answer
1k views

Raspberry Pi 2 and thermal printer

I try to print some text with python and a thermal receipt printer by a Raspberry Pi 2 model B. I use the library developped by Adafruit and the printer sold by Adafruit too. But it fails. The only ...
5
votes
5answers
41k views

pymodbus rtu RS-485 communication

I have this little device for communication, and I can see the dongle after lsusb, and it is attached to ttyUSB0 (output from dmesg). Since the module has its driver that is installed to Raspberry Pi, ...
5
votes
2answers
1k views

Using Quickly to develop apps for Raspberry Pi?

Can Raspberry Pi apps be developed with Quickly on Ubuntu? I know there isn't Ubuntu for the Pi yet but what I want to do is develop the app on my Ubuntu machine, compile it and copy the deb file to ...
5
votes
1answer
180 views

Login to Raspberry Pi Via Python Script

I am trying to make a system to login to the Raspberry Pi with an RFID tag. I successfully connected the RFID reader RC522 module to the Raspberry Pi and I can retrieve the number of the tag and write ...
5
votes
3answers
2k views

HC-SR04 randomly stops taking readings

I have implemented 3 HC-SR04 ultrasonic-distance sensors into my hobby-project, and they are working randomly, meaning they sometimes give me anywhere between 1-12 readings from the sensors and then ...
5
votes
1answer
377 views

What are the differences between these libraries? [closed]

Currently I don't know which library I should use OpenFace OpenBR OpenCV My system hast to recognize about 10 different persons and it will run on a Raspberry Pi 3 with the Raspberry Pi Camera ...
5
votes
2answers
3k views

Crontab on Rpi not running Python script

I have a simple problem that I cannot seem to find an answer to even though I have done some research. I am trying to run a python script via crontab (I have never worked with crontab before this haha)...
5
votes
2answers
77k views

Reading from serial port [loop]

I would like to read from the USB serial port from time to time in a loop. I can open the port and read data with: import serial ser = serial.Serial('/dev/ttyACM0', 9600) while 1 : ser.readline(...
5
votes
1answer
6k views

Capture video for a certain time then quit and save to a folder using OpenCV 3

I am using this sample code from the OpenCV documentation and what the code is simply doing is capturing a video and when it's interrupted it saves it to a folder. What I want to do it capture the ...
5
votes
2answers
586 views

Pi Zero W not timing accurately?

Ok, I admit this a very odd issue I'm having. My setup is that I have an ultrasonic sensor that senses the distance every five seconds, and sends the data to another Pi, (a Pi 3 in this case) via ...
5
votes
5answers
2k views

Bluetooth buttons and mpg123

This is my first post. I have started a project with a rpi2 that currently allows me to bluetooth my rpi2 to a bluetooth speaker. On that bluetooth speaker there are three buttons. One that plays and ...
5
votes
1answer
8k views

Resolution properties for python's OpenCV and uv4l camera driver

I've followed this tutorial to install OpenCV 2.3.1 in raspberry and it has worked fine. I've also installed from here the uv4l raspicam driver. But now I need to modify some capture properties as the ...
5
votes
2answers
10k views

USB microphone recording input and audio output

I've got a USB sound card which I'm trying to record from using the standard pyaudio tutorial for recording however I get the following (below). Frustratingly this script actually works on my mac and ...
5
votes
1answer
472 views

Rasberry Pi zero and 3 bluetooth transfer speed is slow RFCOMM

I am trying to send a series of bytes from the Raspberry Pi zero W to the Raspberry pi 3 via bluetooth. Im using the PyBluez python package. I believe that Raspberry Pi Zero has Bluetooth 4.1 and ...
4
votes
6answers
5k views

How do I know what version of Python script I'm writing?

As a newbie to Python on the RPi (or anywhere else for that matter), how do I know what version of Python (2 or 3) I'm writing for without looking up every command or syntax while trying to write a ...
4
votes
5answers
17k views

gpio library on windows while developing

I am new to Python so maybe this is not an appropriate question. I am working on a project on Python that will use GPIO functionalities of the raspberry Pi. Right now, I am developing the python code ...
4
votes
4answers
2k views

Raspberry Pi stable date time

I'm working on a Raspberry Pi project, in which date and time are the most important factors. So, I want them to be very accurate. I know there are two methods to configure the Raspberry Pi's date ...
4
votes
3answers
10k 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., ...
4
votes
4answers
536 views

Python script not running correctly when launched with crontab

I'm running a telegram bot on my Raspberry Pi 3. When I run it in my console or using Thonny, everything runs smoothly. python3 /home/pi/Documents/telegrambot.py The problem occurs when I set the ...
4
votes
2answers
8k views

How to Connect 6 ultrasonic sensors to a raspberry pi?

I need to connect 6 ultrasonic sensors to one raspberry pi and all six sensors should take the distance measurement same time. I have written the code and made the thread also but only two sensors ...
4
votes
3answers
16k views

Python Script Stops Running After about 3 Hours

I realize this is a somewhat vague question, but, I have a python script that needs to run for two years on a raspberry pi and is failing after about 3 hours. Without getting into to much detail as to ...
4
votes
2answers
170 views

Are there any major differences when programming of the Pi and for normal Linux

As the title says, are there any major differences in programming with Python on the RPi and a normal PC with linux? And if there are (excluding the GPIO and other platform specific stuff) could you ...
4
votes
3answers
50k views

PHP to execute Python scripts for GPIO

I found this code somewhere, that can execute Python scripts from PHP. I've installed apache2 on the Pi and I'm able to access the PHP script. But when I press the HTML buttons, nothing happens! :( ...
4
votes
3answers
1k 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 ...
4
votes
1answer
26k views

Does RPi 3 have BLE (Bluetooth Low Energy/Bluetooth 4.0/Bluetooth Smart)

I am wondering if the RPi3 has BLE built in. (Not standard bluetooth, but BLE) And if it does, how do I find BLE devices or install BLE software or whatever, as I know Raspbian doesn't support BLE ...