Go to advanced search

by ghp
Thu Apr 18, 2019 8:24 pm
Forum: Python
Topic: python farm managing
Replies: 2
Views: 137

Re: python farm managing

Hello, difficult to see what your code is intended to do. What I can't see is how temp or humidity measurements are acquired. What did you already do to understand/ correct the problem ? What is the detailed behavior at the time of failure ? (logging, error messages, network problems, or alike) Syst...
by ghp
Thu Apr 18, 2019 9:02 am
Forum: Python
Topic: Connecting and recording data from a UGEEK Multiple Sensors Cobber v0.2
Replies: 6
Views: 313

Re: Connecting and recording data from a UGEEK Multiple Sensors Cobber v0.2

Hello, the published weather data contain air pressure referred to sea level. openweatermap has an API which allows to query weather data, including pressure. This could provide you with a reference pressure and is easier to achieve compared to the effort of drilling a hole to sea level and establis...
by ghp
Wed Apr 17, 2019 8:33 pm
Forum: Python
Topic: Servo on Adafruit 16-channel PWM/Servo HAT ZeroDivisionError: float division by zero
Replies: 1
Views: 133

Re: Servo on Adafruit 16-channel PWM/Servo HAT ZeroDivisionError: float division by zero

Some code analysis: There is a property 'frequency' in the underlying PCA9685 class. When frequency is set, the value prescale_reg is set.

Looks as if this mechanism is not working. Do you run it with python 2 or python3 ? If python2, then try python3.
by ghp
Tue Apr 16, 2019 7:45 pm
Forum: Python
Topic: Store gy-neo6mv2 gps module data into mysql
Replies: 5
Views: 218

Re: Store gy-neo6mv2 gps module data into mysql

There are some reports in the net around 2014 about "Experimental MySQL HTTP API", which allows to use a REST API with mysql.
Do not know whether this is still in current release. I am curious to see your report on how to use it, security and performance.
by ghp
Sun Apr 14, 2019 3:44 pm
Forum: Python
Topic: Threading
Replies: 2
Views: 163

Re: Threading

When running code here, I get (Thread-1 ) Sleeping 0.85 (Thread-2 ) Sleeping 0.96 (MainThread) Waiting for worker threads (Thread-1 ) Waiting for lock (Thread-1 ) Acquired lock (Thread-1 ) Releasing (Thread-1 ) Sleeping 0.88 (Thread-2 ) Waiting for lock (Thread-2 ) Acquired lock (Thread-2 ) Releasin...
by ghp
Sat Apr 13, 2019 9:10 pm
Forum: Python
Topic: Python recursion error
Replies: 10
Views: 440

Re: Python recursion error

Had a look to your code. What I understand is that you have six temp/moisture sensors, six pumps switched by a relais board. The waterlevel sensor is not used ? Writing the code object oriented would be a good approach. Something like: class Waterer: START = 0 PUMP = 1 SEEP = 2 def __init__(self, pu...
by ghp
Sat Apr 13, 2019 5:03 pm
Forum: Python
Topic: Python recursion error
Replies: 10
Views: 440

Re: Python recursion error

Perhaps you want to have a look to "The State Machine Compiler" on http://smc.sourceforge.net/.
There are a lot of examples and howto on this site.
Even if you do not want to add generated code to your app, the examples are a good entry point to understand state machines.
by ghp
Sat Apr 13, 2019 4:53 pm
Forum: Python
Topic: can you switch X and z and Z and x
Replies: 4
Views: 217

Re: can you switch X and z and Z and x

You can implement a wrapper around 'mc' doing the switch job. Something like a "Man in the Middle" Let me name the wrapper 'SwitchCoordinates' class SwitchCoordinates: def __init__(self, mc_): self.mc_ = mc_ def getBlock(self, x,y, z): return self.mc_.getBlock(x,y,z) def setBlocks(self, x0,y0,z0, x1...
by ghp
Thu Apr 11, 2019 8:38 pm
Forum: Python
Topic: Real time ECG filtering
Replies: 3
Views: 334

Re: Real time ECG filtering

Hello, asking google for ecg filtering brings up more than 3 million entries. I did not read everything, but basically you will need a band pass filter (low pass and high pass filter combined) for an effective band of prox 0.05Hz to 150Hz. It could be a good idea to add an analog low pass filter bet...
by ghp
Sat Mar 30, 2019 6:52 pm
Forum: Python
Topic: Sqlite3 DELETE
Replies: 22
Views: 575

Re: Sqlite3 DELETE

Hello, I have used vacuum in a database where there have been 100GB and more data. A sample with prox 27 MB size: #!/usr/bin/python3 import os import sqlite3 import time dbname = "mydb_10.sqlite" if os.path.exists(dbname): os.remove( dbname) db = sqlite3.connect(dbname) cursor = db.cursor() cursor.e...
by ghp
Sat Mar 30, 2019 5:10 pm
Forum: Python
Topic: Sqlite3 DELETE
Replies: 22
Views: 575

Re: Sqlite3 DELETE

Perhaps it needs to be clarified what the intended behavior of the application is. When a database deletes a row, the data are lost (ok, still there on some files in disk for some time, possibly somewhere in a backup, but not available easily with sql statements). Depending on how the database is wo...
by ghp
Sat Mar 30, 2019 9:26 am
Forum: Python
Topic: Sqlite3 DELETE
Replies: 22
Views: 575

Re: Sqlite3 DELETE

Hello, a few comments. - Pragma vacuum is needed to reduce file size. It allows the sqlite to free deleted entries from the file. It does not affect the way how sqlite handles primary keys. Scenario: assume to insert zillions of records, delete most of them and database size does not shrink. With va...
by ghp
Fri Mar 29, 2019 7:57 pm
Forum: Python
Topic: Reliably read sensor data
Replies: 4
Views: 262

Re: Reliably read sensor data

It could help to know the type of sensor and then also where to find a datasheet. What I think is strange is the size of the data package: '1268 byte' for a 'single pixel ... sensor'. Many sensors with long data packages have some message frame including checksum which allows to find out if somethin...
by ghp
Wed Mar 27, 2019 9:12 pm
Forum: Python
Topic: Systemd service for python script not writing to file
Replies: 10
Views: 539

Re: Systemd service for python script not writing to file

Agree with PhatFil: do not open same file in the python app "open(/home/pi/senselog.csv)" AND at the same time write to this file with a redirect of stdout ( >> /home/pi/senselog.csv). Might result in strange results. When you use redirect, den use print()-statements in the python app which will be ...
by ghp
Sun Mar 24, 2019 11:04 am
Forum: Python
Topic: How to copy MySQL table into Python variables
Replies: 1
Views: 115

Re: How to copy MySQL table into Python variables

Reading data from mysql is explained in many places, e.g. in https://www.w3schools.com/python/python_mysql_select.asp An example is mycursor = mydb.cursor() sql = "select A,B from table_AB" mycursor.execute(sql) myresult = mycursor.fetchall() print ("myresult", myresult) The printout shows: myresult...
by ghp
Sat Mar 23, 2019 5:18 pm
Forum: Python
Topic: Solved: How to avoid that math problem?
Replies: 11
Views: 442

Re: How to avoid that math problem?

But if I modify dB = (ret[0] + ((ret[1] & 3) * 256)) * 0.1 + 30 to dB =decimal( (ret[0] + ((ret[1] & 3) * 256)) * 0.1 + 30) I get an error: Traceback (most recent call last): File "devdB.py", line 35, in <module> update() File "devdB.py", line 26, in update dB = decimal((ret[0] + ((ret[1] & 3) * 25...
by ghp
Sat Mar 23, 2019 1:58 pm
Forum: Python
Topic: RPi Tempmon
Replies: 10
Views: 348

Re: RPi Tempmon

In the webpage you reference, there is an extensive documentation.
What did you try so far, which problems did you find ?
by ghp
Wed Mar 20, 2019 7:07 pm
Forum: Python
Topic: Temperature
Replies: 8
Views: 311

Re: Temperature

Yes, this is possible.
If you are new to python, choose an easy to interface chip with good documentation.
A recommendation would be an ADT7410, you can buy a breakout board with this chip from adafruit.com and they have good documentation and sample code available.
by ghp
Mon Mar 18, 2019 8:00 pm
Forum: Python
Topic: spi and max7219 issues with custom board
Replies: 2
Views: 356

Re: spi and max7219 issues with custom board

Hello, think that SPI interface is not perfectly useable for this special circuit. The 7219 clocks in data from Mosi at rising edge. In SPI mode 0 (transfer data on pos edge of SCK), the clock signal stays low after last transfer. But clock signal is used to form the LOAD (12) signal: When clock goe...
by ghp
Sat Mar 16, 2019 9:48 pm
Forum: Python
Topic: input triggers only work once
Replies: 19
Views: 751

Re: input triggers only work once

Hello, hopefully I do not contribute to confusion. One strategy to solve this problem would be: (1) write a function which sends the email. Parameter is 'purpose', at least for the moment. (2) add this function to your main code. You will now have only one file for your program. (3) in the places wh...
by ghp
Sat Mar 16, 2019 2:22 pm
Forum: Python
Topic: Sending Commands to a raspberry pi
Replies: 4
Views: 321

Re: Sending Commands to a raspberry pi

fabric2 allows to execute commands on a remote machine.
https://pypi.org/project/fabric2

or consider thrift. https://thrift.apache.org/
it allows to execute methods in a remote python (or c, java, ...) application.
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: 335

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 ?

Go to advanced search