raspberry-pi

Python rpi GPIO output control based on GPIO input and time of day

拈花ヽ惹草 提交于 2021-02-10 06:45:32
问题 I'm trying to write a little script to control two raspberry pi's gpio output pins based on two factors: the state of GPIO.input.17 and the time of day. I would like gpio.output.23 and gpio.output.25 to be low when gpio.input.17 is low. I would like gpio.output.23 to go high when gpio.input.17 is high and the time is between 0700-2159. I would like gpio.output.25 to go high when gpio.input.17 is high and the time is between 2200-0659. so far, the code i've put together looks like this: #!/usr

Python rpi GPIO output control based on GPIO input and time of day

匆匆过客 提交于 2021-02-10 06:45:31
问题 I'm trying to write a little script to control two raspberry pi's gpio output pins based on two factors: the state of GPIO.input.17 and the time of day. I would like gpio.output.23 and gpio.output.25 to be low when gpio.input.17 is low. I would like gpio.output.23 to go high when gpio.input.17 is high and the time is between 0700-2159. I would like gpio.output.25 to go high when gpio.input.17 is high and the time is between 2200-0659. so far, the code i've put together looks like this: #!/usr

How to detect removed card with MFRC522

自古美人都是妖i 提交于 2021-02-08 10:38:47
问题 I am working on project where I need to read ID of NFC tag, and then perform some action based on that ID. So far I am able to read it once (object with tag is on the reader whole time), but I also need to have some feedback when object is taken off. I am using MFRC522 reader with RPi and SimpleMFRC522 library. I've tried poking around code in that, but without any success. Do you have any directions / ideas? I have following code: reader = SimpleMFRC522.SimpleMFRC522() buffor = 0 while

Python Bluez GATT server - client cannot disconnect

余生颓废 提交于 2021-02-08 07:55:05
问题 I've been working on a simple bluetooth GATT server app working on a Raspberry pi 3 model B. This app uses Bluez (version 5.49) to advertise services and characteristics. The app is based on the following example: https://github.com/Jumperr-labs/python-gatt-server So far I have almost ended the server: clients can read and write in characteristics and services are advertised. The problem appears when the clients attempt to disconnect to the server. The server seems to be rejecting

Python Bluez GATT server - client cannot disconnect

半腔热情 提交于 2021-02-08 07:54:52
问题 I've been working on a simple bluetooth GATT server app working on a Raspberry pi 3 model B. This app uses Bluez (version 5.49) to advertise services and characteristics. The app is based on the following example: https://github.com/Jumperr-labs/python-gatt-server So far I have almost ended the server: clients can read and write in characteristics and services are advertised. The problem appears when the clients attempt to disconnect to the server. The server seems to be rejecting

how to stop one process from another in Python

筅森魡賤 提交于 2021-02-08 06:50:54
问题 On a Raspberry Pi I'm running two processes which loop constantly until an input is triggered which stops one of the processes but how do I stop both processes? The only thing that works is pressing control+c in the console I can't get it to stop with code at this moment. def stopButton(): while 1: wiringpi2.pinMode(52,0) stopBut = wiringpi2.digitalRead(52) print (stopBut) wiringpi2.delay(500) if (stopBut == 0): stopBlink() def stopBlink(): redBlink = int(0) while (redBlink < int(20)):

How to change the default python version in Raspberry Pi

流过昼夜 提交于 2021-02-08 05:16:33
问题 One day ago I did a fresh installation of Raspberry Pi OS Buster and after that I installed Python3.8 in my Raspberry pi following this tutorial. https://installvirtual.com/how-to-install-python-3-8-on-raspberry-pi-raspbian/ I added python alias to bashrc. echo "alias python=/usr/local/bin/python3.8" >> ~/.bashrc source ~/.bashrc Now typing python in terminal showing Python 3.8.0 (default, Jun 8 2020, 13:17:16) But when I run python3 it's showing Python Python 3.7.3 I added python3 alias

Executing command using Plink does not work, but does in PuTTY

对着背影说爱祢 提交于 2021-02-08 02:07:35
问题 I am trying to create a PowerShell script to SSH into a Raspberry Pi and perform some commands. I am using Plink to SSH into the Pi over command line. However I have to SSH into the Pi user which runs in lshell. I can PuTTY into the Pi with zero issues, but when using Plink I get an error saying the command I am using is forbidden. I am trying to use su which works when using PuTTY by not Plink. The error I get is below: plink : *** forbidden char/command over SSH: "su" At line:1 char:1 +

Numpy import failed

送分小仙女□ 提交于 2021-02-07 19:26:34
问题 On an RPi2, I upgraded all my packages with pip-review and numpy does not work anymore. I tried to uninstall and reinstall numpy though pip and apt but I'm getting no luck. Apt installs numpy 1.12.1, if I try to install that it does not install through pip. Pip installs numpy 1.16.4 fine, but when I go to run it I get the error below. I have already run: sudo apt install libc6 libatlas-base-dev Any help is appreciated. Python 3.7.3 (default, May 8 2019, 18:07:21) [GCC 6.3.0 20170516] on linux

How to avoid flipping between ttyUSB0 and ttyUSB1 when reconnect to USB port under Python using pySerial?

混江龙づ霸主 提交于 2021-02-07 09:20:06
问题 I have a serial Python program, Linux environment (Raspbian / Raspberry Pi), that uses a serial port via USB & serial adapter. I need to handle a situation when the user unplug the USB adapter and then re-insert it. The problem is that, on reconnect, the ttyUSB0 becomes ttyUSB1 and so the port is no longer found. However, if I stop the Python program (keyboard interrupt) and again unplug and re-insert the USB adapter, then the port goes back to ttyUSB0 (and so I can start over again). This