Go to advanced search

by ghp
Sat Mar 16, 2019 8:27 am
Forum: Python
Topic: input triggers only work once
Replies: 19
Views: 751

Re: input triggers only work once

Hello, think the import system of python imports each module only once. See https://docs.python.org/3/reference/import.html When I create a small program for _ in range (5): import B with in subfolder B the __init__.py file is ( B/__init__.py ) # Folder B, file __init__.py print("B") then B is print...
by ghp
Tue Mar 12, 2019 6:19 am
Forum: Python
Topic: Send hex commands via uart port
Replies: 4
Views: 341

Re: Send hex commands via uart port

There was some change in device assignment for recent pi3. Think /dev/ttyAMA0 is used now for the bluetooth-device and /dev/ttyS0 is controlling the pins 8, 10. You need to disable console output on serial with raspi-config. Doublecheck output with e.g. an usb-serial converter, an arduino (3.3V) rec...
by ghp
Wed Mar 06, 2019 8:42 pm
Forum: Python
Topic: Voltage leakage from PLCs or fried GPIO on Pi?
Replies: 7
Views: 390

Re: Voltage leakage from PLCs or fried GPIO on Pi?

Hello,
what does " But in the presence of the Siemens and Allen Bradley PLCs on my machines on the same circuit" mean, especially the 'on the same circuit' ? How exactly are the sensor, the machine, the plc and the pi connected ?
by ghp
Sun Mar 03, 2019 10:12 am
Forum: Python
Topic: Google calendar get color ?
Replies: 8
Views: 641

Re: Google calendar get color ?

There are colorId provided by other api. Found one in calendarList. Perhaps the default color is provided related to calendar.
by ghp
Sat Mar 02, 2019 10:16 pm
Forum: Python
Topic: Google calendar get color ?
Replies: 8
Views: 641

Re: Google calendar get color ?

Hello,
when I run the sample code, then in a few of the events I get a '"colorId"-field. Think it is only available when assigning a non-default color in my calendar-app.
No idea what the 'default-color' is. Ask google ?
by ghp
Sat Mar 02, 2019 11:36 am
Forum: Python
Topic: Google calendar get color ?
Replies: 8
Views: 641

Re: Google calendar get color ?

Hello, think you use google calendar api. If not, where is the documentation of the service you use? If yes, then see: https://developers.google.com/resources/api-libraries/documentation/calendar/v3/python/latest/calendar_v3.colors.html, there is a description of the color structure. Try to print th...
by ghp
Wed Feb 27, 2019 6:42 pm
Forum: Scratch
Topic: GPIO not respond to Scratch 2
Replies: 1
Views: 1087

Re: GPIO not respond to Scratch 2

Hello, if you have tried everything, then only few options are left over to solve this problem. In my environment, it works perfect. The option you may have missed is: - start scratch2 as provided by raspbian, NOT from the website scratch.mit.edu. - More blocks, add an extension, choose PI GPIO - an...
by ghp
Sun Feb 17, 2019 8:40 am
Forum: Scratch
Topic: Problem with the GPIO extension in Stratch 2
Replies: 3
Views: 5058

Re: Problem with the GPIO extension in Stratch 2

Hello, the design of the blocks is made to use pick list with available GPIO. If you need to address gpio by number, then you can write a wrapper which provides this possibility. Here an idea how this could work: variable_output.jpg You set a variable with the gpio-number to set (here 'gpio') and th...
by ghp
Sat Feb 09, 2019 9:45 pm
Forum: Python
Topic: subprocess question
Replies: 3
Views: 222

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: 531

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: 352

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: 375

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: 237

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: 276

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: 236

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: 289

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: 289

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: 377

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: 377

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: 327

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: 156

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: 200

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: 720

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: 431

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: 431

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/

Go to advanced search