Go to advanced search

by ghp
Mon Jun 03, 2019 5:42 pm
Forum: Python
Topic: DS18B20 temp alarm, schedule problem, reminder variables not getting updated(v2.0 w/BBcode)
Replies: 8
Views: 404

Re: DS18B20 temp alarm, schedule problem, reminder variables not getting updated(v2.0)

Code formatting would help. Think the problem is related to the way the message is prepared. The scheduler calls periodially the reminder function (each 20 secs, little bit nervous for a reminder...). The message variable is prepared outside of the 'reminder' loop formed by scheduler and reminder me...
by ghp
Sun Jun 02, 2019 8:47 am
Forum: Python
Topic: Multiple subprocesses
Replies: 10
Views: 437

Re: Multiple subprocesses

Hello, think there are a few problems. - Reading data twice, as already stated. - Too many delays. In the Thermal_Cam, there is a time.sleep(1.0 / fps), which is fine for one sensor, but this is accumulating for four sensors. So with 4 sensors, the delay is 4 * 1/fps. As you read the correct number ...
by ghp
Thu May 30, 2019 3:39 pm
Forum: Python
Topic: Using 7 segment display inside Python code
Replies: 8
Views: 1378

Re: Using 7 segment display inside Python code

Is it a python2-python3 problem? When installing with 'pip', the library goes into the python==python2 modules collection. When starting the application code then with python3, the library is not found.

Install with 'pip' and run with 'python'.
Install with 'pip3' and run with 'python3'.
by ghp
Thu May 30, 2019 6:51 am
Forum: Python
Topic: Using 7 segment display inside Python code
Replies: 8
Views: 1378

Re: Using 7 segment display inside Python code

Common problem is that the own python program has same name as an import. In your case, is your file named luma.py ? Then rename it and retry.
by ghp
Wed May 29, 2019 4:03 pm
Forum: Python
Topic: Do more than one thing on GPIO zero PIR
Replies: 5
Views: 453

Re: Do more than one thing on GPIO zero PIR

I'd propose a solution like this: def base_motion(): """all the actions which need to be done when motion is detected""" r = requests.post("http://bit.ly/xxxxxxx") # motion has been detected by the basement PIR sensor # add code here to switch LED ON baseled.on() # def base_no_motion(): """all the a...
by ghp
Tue May 28, 2019 7:04 pm
Forum: Python
Topic: controlling number of times loop is executed?
Replies: 12
Views: 863

Re: controlling number of times loop is executed?

Code: Select all

print("start")
t = 0.0
while True:
    t += 0.001
    if t > 1000:
        break
    # some other stuff here
print ("complete")
by ghp
Sun May 26, 2019 2:20 pm
Forum: Python
Topic: Cut power to USB ports w/ Python
Replies: 3
Views: 704

Re: Cut power to USB ports w/ Python

Code: Select all

try:
    subprocess.call( "echo '1-1' |sudo tee /sys/bus/usb/drivers/usb/unbind", shell=True)
except ItIsASunnySundayAndNotWorkingAtAllException:
    pass
by ghp
Sat May 25, 2019 4:27 am
Forum: Python
Topic: How to get a very accurate delay from 1 milli second in python
Replies: 3
Views: 728

Re: How to get a very accurate delay from 1 milli second in python

python delay are not very accurate. If you control signals with python, there is a noticeable jitter. When controlling a triac on 50 Hz ( BE CAREFUL AND OBSERVE ALL TECHNICAL RULES when working with mains) you also need to synchronize the on-pulses with zero crossing of input signal which introduces...
by ghp
Fri May 24, 2019 8:02 pm
Forum: Python
Topic: No errors but the window doesn't even open.
Replies: 1
Views: 532

Re: No errors but the window doesn't even open.

My formula car is currently not available to test this piece of software. Hence a proposal to make the code testable. # some code cut off from the start print('\n\rLets Go Racing!') print('\n\rBring up CAN0...') #bring up can interface at 500mbps time.sleep(0.1) print('\n\rReady') class Message: def...
by ghp
Fri May 24, 2019 6:21 pm
Forum: Python
Topic: Help reading in serial strings into pi from arduino?
Replies: 6
Views: 850

Re: Help reading in serial strings into pi from arduino?

This code is only a part of the system and it is almost impossible to help without the full picture. A few remarks are possible: - in the function, the serial line is opened, but never closed. On the other side, as it is never known when the arduino is sending, the line should be kept open. - instea...
by ghp
Sat May 18, 2019 3:29 pm
Forum: Python
Topic: Storing multiple variables
Replies: 4
Views: 296

Re: Storing multiple variables

Hello, some lines of code show can explain the concept. The assumption is that for each sensor a 'status' field is collected. import time import random class TestException(Exception): pass def unexpected_source_of_trouble(func): """produce a simulation of random error""" def wrapper(): if random.ran...
by ghp
Sat May 18, 2019 2:36 pm
Forum: Python
Topic: mqtt limit speed
Replies: 2
Views: 267

Re: mqtt limit speed

There are many reports about mqtt performance, e.g. https://flespi.com/blog/http-vs-mqtt-performance-tests http://www.scalagent.com/IMG/pdf/Benchmark_MQTT_servers-v1-1.pdf http://www.bitreactive.com/blog/2015/06/26/how-fast-can-you-publish-mqtt-messages/ What are your scripts to send data ? And whic...
by ghp
Fri May 17, 2019 4:47 pm
Forum: Python
Topic: Adafruit DHT22, CGI and Apache
Replies: 2
Views: 220

Re: Adafruit DHT22, CGI and Apache

Instead of reading in the glass ball, I would prefer to read the CGI script. Probability for good answers increases with the number of lines of codes posted here.
by ghp
Wed May 15, 2019 5:17 pm
Forum: Python
Topic: l298 python code
Replies: 16
Views: 639

Re: l298 python code

Hello, on one of the photos there is a small, blue plastic case with a label 'tower pro'. These devices are IMHO not suitable to be driven by a L293, but need a constant power supply with 5V and pulse width modulated signal to control them.
by ghp
Mon May 13, 2019 5:30 pm
Forum: Python
Topic: Retrieving counts from an [Absolute Rotary Encoder]
Replies: 3
Views: 273

Re: Retrieving counts from an [Absolute Rotary Encoder]

Hello, according to the datasheet there are 3.3V and 5V flavors of this device available. Be sure to use the 3.3V device or provide a level shifter for the input signal. The device has two data pins DI (data in) and DO (data out). The data input DI pin should be set to low when not needed to cascade...
by ghp
Sat May 11, 2019 1:07 pm
Forum: Python
Topic: Installed LAMP on Raspberry and PHP works strangely
Replies: 8
Views: 432

Re: Installed LAMP on Raspberry and PHP works strangely

Hello, there are always many options. When you need to 'push' values to a javascript application, possibly websockets are an option. Almost everything supporting 'web' also supports websockets. Examples https://www.tornadoweb.org/en/stable/websocket.html https://websockets.readthedocs.io/en/stable/i...
by ghp
Thu May 09, 2019 3:52 am
Forum: Python
Topic: Why is PIR motion sensor always set to high?
Replies: 1
Views: 193

Re: Why is PIR motion sensor always set to high?

i'm assuming this is because the input is high from the beginning and so it meets the condition of the alarm? yes. If there is a 'high' then the LED are switched on. Possible reasons: - a wire to motion sensor broken. As you use internal pullup, a broken wire results in high level. - your sensor is...
by ghp
Wed May 08, 2019 8:18 pm
Forum: Python
Topic: I wrote a program in Python but I want to send data to a JavaScript program
Replies: 6
Views: 349

Re: I wrote a program in Python but I want to send data to a JavaScript program

Hello, could you give mire details on how this javascript code is started ? Running standalone, or is it in a browser?
by ghp
Fri May 03, 2019 4:22 am
Forum: Python
Topic: Raspberry pi 3 auto backlight dimmer with vcnl4010
Replies: 2
Views: 216

Re: Raspberry pi 3 auto backlight dimmer with vcnl4010

Did you enable I2C for your pi ? Use raspi-config and look for
5 Interfacing Options
by ghp
Fri May 03, 2019 4:14 am
Forum: Python
Topic: Python + JSON, how to create a good log file for diagnostics
Replies: 5
Views: 325

Re: Python + JSON, how to create a good log file for diagnostics

there is a logging package in python
https://docs.python.org/3.7/howto/logging.html
which allows for file rotation, output for syslog, log levels, formatting and much more.
by ghp
Sat Apr 27, 2019 11:25 am
Forum: Python
Topic: python to binary file from ubuntu
Replies: 9
Views: 636

Re: python to binary file from ubuntu

For Sending / deploying and execution of python code (partially other code too) there are quite a few approcahes: - use scp, ssh to copy and execute (console programs only) - personally I use ant ant.apache.org to script deployments using scp, ssh. Easy to use from within eclipse. - have a look to f...
by ghp
Tue Apr 23, 2019 6:49 pm
Forum: Python
Topic: Replicating an existing keypad interface
Replies: 4
Views: 261

Re: Replicating an existing keypad interface

Hello, so what I understand is that you want to leave the PIC in place and just to 'simulate' the signals. One possibility would be to use 3 rows * 4 columns = 12 analog switches to emulate the old switches. Then the pi could control the switch control lines and this is an easy thing as timing is no...
by ghp
Tue Apr 23, 2019 6:27 pm
Forum: Python
Topic: Use RPi.GPIO Library on Eclipse (mac)
Replies: 2
Views: 235

Re: Use RPi.GPIO Library on Eclipse (mac)

Hello, welcome to the world of cross-deleveopment. Depending on what you want to achieve, there are different strategies: (A) develop on computer, transfer to pi and test on pi. Run on pi. (B) develop on computer, test on computer using mockup, transfer to pi and test on pi. Run on pi. (C) develop o...
by ghp
Tue Apr 23, 2019 5:03 pm
Forum: Python
Topic: Controlling LED strip from GPIO Help?
Replies: 4
Views: 201

Re: Controlling LED strip from GPIO Help?

Timing for these ws2811 is very strict and is difficult to achieve on a linux system. I propose to use an arduino board as LED controller and to transmit the led brightness data by serial connection.
by ghp
Tue Apr 23, 2019 10:13 am
Forum: Python
Topic: Threading serial read in python GUI
Replies: 15
Views: 961

Re: Threading serial read in python GUI

import tkinter import time import threading import random import queue import sys class GuiPart: def __init__(self, master, queue, endCommand): self.queue = queue # Set up the GUI console = tkinter.Button(master, text='Done', command=endCommand) self.v = tkinter.StringVar() self.v.set( "abcde") lab...

Go to advanced search