Go to advanced search

by ghp
Sat Feb 09, 2019 9:45 pm
Forum: Python
Topic: subprocess question
Replies: 3
Views: 93

subprocess question

Hello, I write some code where a python3 script is loading other scripts from an usb-stick. These scripts can be shell- or python scripts. Found that running python scripts results in a problem related to using subprocess.run with arguments in arrayor string . The problem is, that when using argumen...
by ghp
Fri Feb 01, 2019 9:35 pm
Forum: Python
Topic: Not sure if this is possible...
Replies: 11
Views: 373

Re: Not sure if this is possible...

Hello, there is linux syslog and python syslog which writes log messages to /var/log/messages. import syslog syslog.syslog("this is my message" ) Start a terminal with a command "tail -f /var/log/messages" to see the messages as they are written. Some customization can be done in /etc/syslog.conf.
by ghp
Thu Jan 17, 2019 8:43 pm
Forum: Python
Topic: Using multiple mariaDB queries in Flask webpage
Replies: 6
Views: 240

Re: Using multiple mariaDB queries in Flask webpage

Hello, I assume that your table 'readings' has more than one column. Your query sample point to this direction. SQL is very flexible. You can write cur.execute('SELECT TempSensor1,HumidSensor1,TS FROM readings ORDER BY readingID LIMIT 1;') data = cur.fetchone() print( "data", data) print("Temp", dat...
by ghp
Mon Jan 14, 2019 8:47 pm
Forum: Python
Topic: Sent data over GPIO, need help
Replies: 1
Views: 331

Re: Sent data over GPIO, need help

Let me propose another approach: get an arduino micro or leonardo (atmel32u4) which has build in usb support. Arduino IDE provides keyboard methods. The chance its working is reasonable high. Then use digital serial from raspberry to arduino (with level shifter) to provide strings to send as keyboar...
by ghp
Sun Jan 13, 2019 12:02 pm
Forum: Python
Topic: Wake screen & refresh browser with USB RFID
Replies: 1
Views: 198

Re: Wake screen & refresh browser with USB RFID

Hello, to activate screensaver, issue command with subprocess. subprocess.run("xscreensaver-command -display :1.0 -deactivate", shell=True) assuming your screensaver is xscreensaver. You need to know which xdisplay is used, can be multiple. My example above works for a VNC connected display, try ech...
by ghp
Mon Jan 07, 2019 6:00 am
Forum: Python
Topic: Inserting dynamic data into mysql database
Replies: 2
Views: 136

Re: Inserting dynamic data into mysql database

Hello, there are some tutorials in the net, e.g. https://www.w3schools.com/python/python ... tarted.asp
For installing the database, see for example https://www.stewright.me/2016/04/instal ... pberry-pi/
by ghp
Sun Jan 06, 2019 9:34 pm
Forum: Python
Topic: Conflict between ic2-bus and GPIO pins?
Replies: 2
Views: 173

Re: Conflict between ic2-bus and GPIO pins?

Hello, not sure what this "IO PI expander" is, but possibly a MCP23017 driven by I2C-signals. These I2C-signals are usually provided by GPIO-2, GPIO-3 . Setting these pins to specific directions could conflict with the I2C driver.
Do you have a link to this product (including schematic ?)
by ghp
Sat Jan 05, 2019 9:52 pm
Forum: Python
Topic: web server based on Python , how ?
Replies: 3
Views: 199

Re: web server based on Python , how ?

This sample given in the link runs a web app on port 5000. The startup messages are: pi@raspberrypi:~ $ python3 app.py * Serving Flask app "app" (lazy loading) * Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead. * De...
by ghp
Sat Jan 05, 2019 6:50 pm
Forum: Python
Topic: web server based on Python , how ?
Replies: 3
Views: 199

Re: web server based on Python , how ?

1. how use current ip address of raspberry as ip address for server, or how manually give ip address and port. The web server runs on the computer and uses the computers network connection. So the ip address of server and this of the computer are the same. The port is usually defined in config file ...
by ghp
Fri Jan 04, 2019 9:46 pm
Forum: Python
Topic: Parallax SF11-C Laser Rangefinder
Replies: 5
Views: 230

Re: Parallax SF11-C Laser Rangefinder

Hello,
see https://pyserial.readthedocs.io/en/late ... intro.html or use a search engine 'python serial'.
by ghp
Fri Jan 04, 2019 12:20 pm
Forum: Python
Topic: Parallax SF11-C Laser Rangefinder
Replies: 5
Views: 230

Re: Parallax SF11-C Laser Rangefinder

Hello, the datasheet explains the options. USB serial should be possible, digital serial and I2C are available. Use the proposed method to setup the device using the provided terminal emulator. Then try to connect usb serial using python serial library.
by ghp
Fri Jan 04, 2019 5:36 am
Forum: Python
Topic: Help with python code for flow meter
Replies: 3
Views: 189

Re: Help with python code for flow meter

Hello, please use code tags for attached code.
What is the exact error message ?
There is another place in your code which looks weird: "time.time() = + 10"
by ghp
Thu Jan 03, 2019 8:14 pm
Forum: Python
Topic: RFID to read from CSV File
Replies: 1
Views: 115

Re: RFID to read from CSV File

There are some tutorials, for example https://realpython.com/python-csv/
by ghp
Thu Jan 03, 2019 12:49 pm
Forum: Python
Topic: Check Network-Connection
Replies: 3
Views: 134

Re: Check Network-Connection

by ghp
Wed Jan 02, 2019 7:02 pm
Forum: Interfacing (DSI, CSI, I2C, etc.)
Topic: How to connect 20 stepper motors to Raspberry Pi 3b+ ?
Replies: 2
Views: 623

Re: How to connect 20 stepper motors to Raspberry Pi 3b+ ?

In the datasheet DRV8880 the Enable pin is described to disable H-Bridge (which I assume will remove power from the motor, no hold torque available). Whereas step counter will remain active. So Enable pin is not perfect to 'cut off the chip from control signals'. A demultiplexer like a 74HC154 could...
by ghp
Mon Dec 31, 2018 3:45 pm
Forum: Python
Topic: How to send command to PC from Raspberry Pi GUI
Replies: 8
Views: 311

Re: How to send command to PC from Raspberry Pi GUI

The subprocess module is a bit tricky to use. What works for me is: import subprocess server_ip = "192.168.2.111" rep = subprocess.Popen('ping -c 1 ' + server_ip , shell=True, stdout= subprocess.PIPE, stderr= subprocess.PIPE) (stdoutdata, stderrdata) = rep.communicate() print(server_ip, rep.returnco...
by ghp
Mon Dec 31, 2018 1:17 pm
Forum: Python
Topic: How to send command to PC from Raspberry Pi GUI
Replies: 8
Views: 311

Re: How to send command to PC from Raspberry Pi GUI

Hello, everything is possible. Go from os.system to subprocess.Popen https://docs.python.org/3.6/library/subprocess.html and capture stdout, stderr with the communicate method.
There is a nice how-to in https://www.saltycrane.com/blog/2008/09 ... ss-module/
by ghp
Mon Dec 31, 2018 8:57 am
Forum: Python
Topic: How to send command to PC from Raspberry Pi GUI
Replies: 8
Views: 311

Re: How to send command to PC from Raspberry Pi GUI

Think the most simple approach is to use the os package and execute the ping command. Works on raspberry. import os server_ip = "192.168.1.111" rep = os.system('ping -c 1 -q ' + server_ip + ' > /dev/null') print(server_ip, rep) results rep == 0 when ok, else not ok. You can see the ping options with...
by ghp
Sun Dec 30, 2018 7:40 pm
Forum: Python
Topic: Help with shut.copy()
Replies: 5
Views: 158

Re: Help with shut.copy()

Hello, obviously you try to use python commands from a command line. This is not the way python works. Usually you write the commands into a file ( something like sample.py) and execute this with an interpreter (on the command line type 'python3 sample.py' without the quotes). There are some more op...
by ghp
Sun Dec 30, 2018 4:31 pm
Forum: Python
Topic: How to compare current and next day
Replies: 27
Views: 756

Re: How to compare current and next day

The datetime class provides a rich set of methods and fields. See https://docs.python.org/3/library/datetime.html for more information.
by ghp
Sun Dec 30, 2018 4:20 pm
Forum: Python
Topic: Help with shut.copy()
Replies: 5
Views: 158

Re: Help with shut.copy()

See https://www.pythonforbeginners.com/os/p ... til-module, it might help you to find answers.
by ghp
Sun Dec 30, 2018 8:08 am
Forum: Python
Topic: How to compare current and next day
Replies: 27
Views: 756

Re: How to compare current and next day

Think this approach is better than your initial code. But you have two problems in which you had solved in between:
the callback method needs a parameter (channel)
the variables count, now and last_minute need to be defined as global.

The update of the tk frame works, well done.
by ghp
Sat Dec 29, 2018 6:40 pm
Forum: Python
Topic: How to compare current and next day
Replies: 27
Views: 756

Re: How to compare current and next day

Hello, it is in most cases quite simple to execute code on a laptop without GPIO attached. Just 'conditionally' remove the rpi.gpio import and replace the event detect by a thread. ... ... debug = True INPUT_PIN = 21 if debug: import threading else: import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPI...
by ghp
Sat Dec 29, 2018 4:26 pm
Forum: Python
Topic: How to compare current and next day
Replies: 27
Views: 756

Re: How to compare current and next day

Hello, think you should handle all three variables count, now, last_minute as global variable and declare all three at the beginning of your code. count = 0 now = datetime.datetime.now() last_minute = now.minute # or "= None" In your code there is another problem: the check_count-method is never lea...

Go to advanced search