Go to advanced search

by ghp
Fri May 22, 2020 9:48 am
Forum: Python
Topic: SCT013000 python code
Replies: 6
Views: 176

Re: SCT013000 python code

Browsing the net gave me
https://openenergymonitor.org/forum-arc ... e/156.html
which gives a basic schematic for an arduino. How is the schematic you use ?
by ghp
Thu May 21, 2020 5:34 pm
Forum: Python
Topic: Get JSON from remote server
Replies: 3
Views: 130

Re: Get JSON from remote server

The urllib returns bytes. From the doc: "Note that urlopen returns a bytes object. This is because there is no way for urlopen to automatically determine the encoding of the byte stream it receives from the HTTP server. " You should add a conversion to a string .decode('utf-8'). What worked for me a...
by ghp
Mon Mar 23, 2020 9:04 pm
Forum: Python
Topic: PID Controller.
Replies: 6
Views: 257

Re: PID Controller.

class PID: def __init__(self, P=1.0, I=0.0, D=1.0, Integrator_max=180, Integrator_min=-180): self.Kp=P self.Ki=I self.Kd=D self.Derivator=0 self.Integrator=0 self.Integrator_max=Integrator_max self.Integrator_min=Integrator_min self.set_point=0.0 self.error=0.0 self.max = max def update(self,curren...
by ghp
Sun Mar 22, 2020 3:51 pm
Forum: Python
Topic: PID Controller.
Replies: 6
Views: 257

Re: PID Controller.

pid.png
pid.png (39.83 KiB) Viewed 199 times
I have added a 'system' to the control loop and plotted system values (dropping from 180 down to 0 slowly) and the pid output. The second chart shows the integrator values. These are 'clamped' to a limit (see your PID code).
This clamp results the constant output values in your sample.
by ghp
Sun Mar 22, 2020 1:51 pm
Forum: Python
Topic: PID Controller.
Replies: 6
Views: 257

Re: PID Controller.

Increase the I-part to 0.1 ( or something larger 0), then the PID output decreases as the setpoint (0) is constantly off the input value (50).
Which P and I values are appropriate depends on what system is controlled.
by ghp
Sun Mar 22, 2020 9:51 am
Forum: Python
Topic: MFRC522 - python syntax error - Raspi 3 Model
Replies: 6
Views: 274

Re: MFRC522 - python syntax error - Raspi 3 Model

In the github code, in line 376 is a print statement. As you made a remark that the print-statements have been changed to python3 style with brackets (), most possibly in line 376 the brackets are not perfect. print "%s backdata &0x0F == 0x0A %s" % (backLen, backData[0]&0x0F) if status == self.MI_OK:
by ghp
Fri Mar 20, 2020 7:08 am
Forum: Python
Topic: search in sqlite with 2 variables
Replies: 3
Views: 167

Re: search in sqlite with 2 variables

think it is not possible to substitute the table name. Try the following: import sqlite3 conn = sqlite3.connect('example.db') cur = conn.cursor() cur.execute("""drop table if exists TABLE_A; """) cur.execute("""drop table if exists TABLE_B; """) cur.execute("""create table if not exists TABLE_A ( ID...
by ghp
Sun Mar 15, 2020 8:49 am
Forum: Python
Topic: Mqtt - milions of input payloads
Replies: 12
Views: 581

Re: Mqtt - milions of input payloads

#!/usr/bin/env python3 #-*- coding: utf-8 -*- import paho.mqtt.client as mqtt import threading import time from multiprocessing import Process # the MQTT connection HOST = "localhost" PORT = 1883 debug = False N_MESSAGES_PER_PROCESS = 4 topics = ['pi', 'pa', 'po'] # number of messages for a specifi...
by ghp
Sat Mar 14, 2020 9:50 pm
Forum: Python
Topic: Mqtt - milions of input payloads
Replies: 12
Views: 581

Re: Mqtt - milions of input payloads

Multithreading in python won't speed up the system. I tried to speed up by - using multiprocessing, here one for three cores, having performance left for mosquitto. - sending multiple data in sequence, challenging the data transport systems. With three processes with four messages each the total tim...
by ghp
Sat Mar 14, 2020 7:18 pm
Forum: Python
Topic: Mqtt - milions of input payloads
Replies: 12
Views: 581

Re: Mqtt - milions of input payloads

Just did a simple test on a pi4. The local client subscribes to a topic. Payload is a number, starting at '0'. When receiving a number, increment and publish again. So no parallel execution in this example. The broker is mosquitto. For 1.000.000 cyles (publish, receive, qos 0) it needs 312 sec: prox...
by ghp
Sun Mar 01, 2020 2:13 pm
Forum: Python
Topic: VL53L1X module not found error even after pip/pip3 install
Replies: 2
Views: 225

Re: VL53L1X module not found error even after pip/pip3 install

Hello, I assume you installed the module using the command:

Code: Select all

sudo pip3 install VL53L1x
And you then start the code with

Code: Select all

python3 TOF.py
by ghp
Fri Feb 28, 2020 9:30 pm
Forum: Python
Topic: Detecting both magnetic door sensor when they are open/closed
Replies: 5
Views: 410

Re: Detecting both magnetic door sensor when they are open/closed

Hello, assuming you want to track the two doors independent from each other, then a more modular approch is possible. The idea is to have a message queue between the 'gatekeeper' for door1 and door 2. The gatekeeper feed in messages when state is changing. On the reading end of the queue is a sender...
by ghp
Fri Jan 24, 2020 9:12 pm
Forum: Python
Topic: Trouble writing BME280 sensor data to mariadb
Replies: 10
Views: 649

Re: Trouble writing BME280 sensor data to mariadb

There is a document available on python and mariadb https://mariadb.com/resources/blog/how-to-connect-python-programs-to-mariadb/ Related to your code, change it like (untested) ambient_temperature_value = 43.2 air_pressure_value = 32.4 humidity_value = 24.3 c.execute("INSERT INTO weather(AMBIENT_TE...
by ghp
Thu Jan 23, 2020 9:13 pm
Forum: Python
Topic: GPIO Behavior with python
Replies: 5
Views: 417

Re: GPIO Behavior with python

The timings are different. brightLED : high 1 , low 0.01 >> on-ratio 1 / (1+0.01) almost always on ledmain : high 0.05, low 0.01 + 0.06*3 >> on-ratio 0.05/ (0.05 + 0.19) prox 21% on ledOn-dimcode: high very short, low 1 >> on-ratio (almost zero) / 1 almost alway off You control brightness by pulsing...
by ghp
Tue Jan 21, 2020 6:22 am
Forum: Python
Topic: Relay Off + python + cron + sunwait not working
Replies: 1
Views: 204

Re: Relay Off + python + cron + sunwait not working

Hello, what are the differences: - the off-code uses cleanup() at the end, the on-code does not. cleanup() will set used outputs to inputs. Depends on how the relay is connected whether this makes problems. But as it works from terminal not a problem. - calling from cron or calling from the terminal...
by ghp
Sun Jan 19, 2020 12:20 pm
Forum: Python
Topic: Neopixel Stick
Replies: 14
Views: 676

Re: Neopixel Stick

the magic three steps are - solder the connections. - install the library (think you did with the corrected command "sudo pip3 install adafruit-circuitpython-neopixel") - run the sample code from adafruit web page(https://learn.adafruit.com/adafruit-neopixel-uberguide/python-circuitpython, neopixel_...
by ghp
Sat Jan 18, 2020 6:02 pm
Forum: Python
Topic: Neopixel Stick
Replies: 14
Views: 676

Re: Neopixel Stick

define " editing?"
by ghp
Sat Jan 18, 2020 4:39 pm
Forum: Python
Topic: Neopixel Stick
Replies: 14
Views: 676

Re: Neopixel Stick

pip is a recursive acronym for "Pip Installs Packages". Packages are software packages for python.
pip3 is pip for python version 3.
The pi board version is not related to pip.
by ghp
Sat Jan 18, 2020 2:19 pm
Forum: Python
Topic: Neopixel Stick
Replies: 14
Views: 676

Re: Neopixel Stick

Hello, the screenshot is a little bit blurred, bit I think you misspelled the install command. Adafruit webpage says (https://learn.adafruit.com/adafruit-neopixel-uberguide/python-circuitpython) sudo pip3 install adafruit-circuitpython-neopixel There is also a wiring diagram on this page. Compare wi...
by ghp
Sat Jan 18, 2020 10:01 am
Forum: Scratch
Topic: Scratch 1.4 Squeak is almost out of memory. Already compressed sounds
Replies: 14
Views: 2269

Re: Scratch 1.4 Squeak is almost out of memory. Already compressed sounds

scratchClient allows to play sounds using Linux aplay tool, see http://www.heppg.de/download/scratchCli ... line_aplay
There is also control for sonic pi available, there is an entry in my blog http://heppg.de/ikg/wordpress/?p=960
by ghp
Thu Jan 16, 2020 7:22 pm
Forum: Scratch
Topic: Using Scratch with Raspberry Pi (Analog inputs)
Replies: 5
Views: 998

Re: Using Scratch with Raspberry Pi (Analog inputs)

scratchClient supports some AD converters as MCP3202, MCP3008 (SPI) or ADS1015, PCF8591 (I2C). Also atmel328 on e.g. arduino nano boards with its ADC (connected by USB Serial).
scratchClient is available for scratch 2 and scratch 1.4.
by ghp
Sat Jan 11, 2020 9:45 pm
Forum: Interfacing (DSI, CSI, I2C, etc.)
Topic: 20x DS18B20 Temperature Sensors with 20M cabling each
Replies: 4
Views: 570

Re: 20x DS18B20 Temperature Sensors with 20M cabling each

Wireless communication is one solution. - ESP8266 are interesting for wifi, but use quite a lot of power. - RFM69HCW Packet Radio at 433MHz use less power and there are controller/radio boards around, even with lipoly support. With small solar panels there could be autonomous stations. - raspberry i...
by ghp
Sat Jan 11, 2020 6:52 pm
Forum: Python
Topic: Hangups python script to send messages automatically?
Replies: 2
Views: 241

Re: Hangups python script to send messages automatically?

What do you mean with "in case of a system trigger" ?
by ghp
Tue Jan 07, 2020 7:43 pm
Forum: Python
Topic: pwm.set_pwm(0, 0, pwm0), what does pwm0 equal??
Replies: 4
Views: 335

Re: pwm.set_pwm(0, 0, pwm0), what does pwm0 equal??

You do not provide much context. If my assumption holds true that you refer to adafruit-16-channel-servo-driver-with-raspberry-pi, then in https://learn.adafruit.com/adafruit-16-channel-servo-driver-with-raspberry-pi/library-reference you find an explanation. look for set_pwm(channel, on, off): Argu...
by ghp
Tue Jan 07, 2020 6:01 pm
Forum: Python
Topic: multiple i2c sensores
Replies: 5
Views: 516

Re: multiple i2c sensores

With two VEML6070, connected to the setup described earlier here with two I2C bus, a sample program reads data: import smbus import time bus_1 = smbus.SMBus(1) bus_3 = smbus.SMBus(3) class VEML6070: _ADDR_CMD = (0x70 >> 1) _ADDR_LOW = (0x71 >> 1) _ADDR_HIGH = (0x73 >> 1) def __init__(self, nbus): se...

Go to advanced search