Go to advanced search

by ghp
Tue Nov 05, 2019 10:19 pm
Forum: Python
Topic: Voltage divider false event detect
Replies: 9
Views: 1233

Re: Voltage divider false event detect

for switching my lights i'm using a 24v signal circuit which triggers a relay at the mainboard If there is a relay in the 24V-circuit in parallel to the voltage divider, then there might be a problem with high voltage spikes when the relay is switched off. Do you use a diode protection "flyback" ci...
by ghp
Sat Nov 02, 2019 3:02 pm
Forum: Python
Topic: 8 IR receivers on 8 GPIO pins
Replies: 6
Views: 1559

Re: 8 IR receivers on 8 GPIO pins

I once used aluminum foil where a sheet of paper was transmitting too much of IR light. To prevent electricl shortcuts, I glued it between two sheets of paper.
by ghp
Tue Oct 29, 2019 8:08 pm
Forum: Python
Topic: Python script at boot can't find pytz
Replies: 2
Views: 383

Re: Python script at boot can't find pytz

Possibly the path wrong ?
ExecStart=usr/bin/python3 should be ExecStart=/usr/bin/python3 ??
by ghp
Sun Oct 27, 2019 8:46 am
Forum: Python
Topic: [Solved] DCT update value from nested list
Replies: 3
Views: 615

Re: DCT update value from nested list

Hello, in this json is a slight problem: missing ',' after """{"point": "2", "start": "11.00", "stop": "14.35", "available": 1}""". import json x = """ { "timestamp": 1412282459, "res": [ { "group": "1", "catlist": [ { "cat": "1", "start": "none", "stop": "none", "points": [ {"point": "1", "start": ...
by ghp
Wed Oct 23, 2019 6:42 pm
Forum: Python
Topic: Robot with stepper motor 28byj-48
Replies: 4
Views: 823

Re: Robot with stepper motor 28byj-48

Hello, these stepper motors have an internal gear box with prox 1:64 ratio. The internal stepper needs to make 64 turns internally to perform one external turn on the axle. I once disassembled a defect motor and the internal stepper is really tiny. In the datasheet found in the net the frequency is ...
by ghp
Sun Oct 20, 2019 5:55 pm
Forum: Python
Topic: Turning on LED strip and printing with button push
Replies: 7
Views: 1077

Re: Turning on LED strip and printing with button push

There are some slight problems in your code. The line numbers given are related to the code given in your first post here. Your print statements are not very precise. Line 65: The """print ("led on")""" is indented two levels. You have gotten 32 times "led on" printed ? Line 87: The """print("button...
by ghp
Sun Oct 20, 2019 9:17 am
Forum: Python
Topic: Turning on LED strip and printing with button push
Replies: 7
Views: 1077

Re: Turning on LED strip and printing with button push

Hmm, what is 'it' in this context ? Give more details !
The code worked in initial revision posted ?
by ghp
Sat Oct 19, 2019 7:55 pm
Forum: Python
Topic: Turning on LED strip and printing with button push
Replies: 7
Views: 1077

Re: Turning on LED strip and printing with button push

In the led_on() method, there is a line
strip.setPixelColor(x, Color(255,0,0))

Try writing a similiar method led_off() where this line is
strip.setPixelColor(x, Color(0,0,0))
by ghp
Sat Oct 19, 2019 7:19 am
Forum: Python
Topic: Random Pin Selection
Replies: 1
Views: 628

Re: Random Pin Selection

Think there is no [random pin selection]. But with [random] combined with [pin selection], there are solutions: Add your pin numbers into an array. Then select random number and pick the related pin number from the array. ## import RPi.GPIO as GPIO ## setup GPIO... import random # just some sample n...
by ghp
Wed Oct 16, 2019 5:33 pm
Forum: Python
Topic: Pyserial output equals input
Replies: 12
Views: 920

Re: Pyserial output equals input

Here some code which (in various flavors) I use with my serial devices. It uses a thread to receive and display data independent from the sending task. #!/usr/bin/python3 # execute with python 3 import threading import time import serial import sys # use one of the following strings eol_string = "\r...
by ghp
Mon Oct 07, 2019 6:15 pm
Forum: Python
Topic: [Update]Controlling the Microsteps of Stepper motor + Python3
Replies: 25
Views: 1959

Re: Controlling the Microsteps of Stepper motor + Python3

as far I can see from the datasheet, there are switches at the side of the device which define the microstep behavior. These switches (most possibly ) can't be modified by code, but only manually. You own this device, you can see these switches ? in pseudocode, the logic for one revolution is: N = 2...
by ghp
Wed Oct 02, 2019 6:42 pm
Forum: Python
Topic: [Update]Controlling the Microsteps of Stepper motor + Python3
Replies: 25
Views: 1959

Re: Controlling the Microsteps of Stepper motor + Python3

Hello, when looking to the datasheet of the device, there are switches which define the microstepping behavior. SW5, 6, 7, 8 on, off, off, off should give 256 microsteps. When your python code controls the rotation, there should be a considerable slowdown. As far I can see, there is no software cont...
by ghp
Sat Sep 28, 2019 6:18 pm
Forum: Python
Topic: Extracting data from ADXL345 code
Replies: 1
Views: 232

Re: Extracting data from ADXL345 code

Hello, first idea is alway something like what_is_this = adxl.read_one() print( what_is_this ) When looking into the source code, the method is implemented as def read_one(self): count, data = self.pi.spi_xfer(self.h, self.READ_DATA) if count == 7: x = ct.c_int16(((data[2] << 8)) | data[1]).value * ...
by ghp
Tue Sep 24, 2019 5:17 pm
Forum: Python
Topic: Pregunta puertos COM Raspberry - Question COM Port.
Replies: 2
Views: 282

Re: Pregunta puertos COM Raspberry - Question COM Port.

Think that udev rules can help with this. See for example https://www.silabs.com/community/interface/knowledge-base.entry.html/2016/06/06/fixed_tty_deviceass-XzTf Although I have to admit I never used this on my own. In my projects, I have implemented a unique ID string in EPROM of arduino. The appl...
by ghp
Mon Sep 23, 2019 7:41 pm
Forum: Python
Topic: Run more scripts forever
Replies: 6
Views: 571

Re: Run more scripts forever

One possible solution is to use a shell script which first starts script 1, then script 2. This needs script 1 to terminate before script 2 is executed. The while true; executes this in a forever loop. #!/bin/sh while true; do python3 script_1.py python3 script_2.py done save as exec_loop.sh and exe...
by ghp
Mon Sep 23, 2019 6:43 pm
Forum: Python
Topic: LED-button with detected pressed time
Replies: 10
Views: 540

Re: LED-button with detected pressed time

... and possibly the indentation is wrong ? buttonTime = time.time() - start_time if buttonTime >= 4: writetotxtfile("Long Pressed1","text1.txt") elif buttonTime >= 2: writetotxtfile("Medium Pressed1","text1.txt") elif buttonTime >= .1: writetotxtfile("Short Pressed1","text1.txt") Should be more lik...
by ghp
Fri Sep 20, 2019 9:49 pm
Forum: Python
Topic: Send datas to an arduino with pySerial
Replies: 5
Views: 834

Re: Send datas to an arduino with pySerial

Hello, raw_input is for python2. Better to use python 3 with input(). I have prepared a small python code along your proposal, which also reads in what arduino sends. # execute with python 3 import serial import threading import time s = serial.Serial("COM9", 9600) s.timeout=0.3 loop = True def rece...
by ghp
Tue Sep 17, 2019 5:41 pm
Forum: Python
Topic: Python curses issue
Replies: 3
Views: 262

Re: Python curses issue

Hmm, possibly the reason is that your file curses.py has the same name as the library imported. Rename your file to something different like 'my_project_with_curses.py'.
by ghp
Tue Sep 17, 2019 4:53 pm
Forum: Python
Topic: Read serial port using pyserial problem
Replies: 23
Views: 3668

Re: Read serial port using pyserial problem

Hello, try to check the data using a 'serial terminal' program like "minicom'. sudo apt-get install minicom use with minicom -D /dev/ttyUSB0 Setup port settings (baudrate etc). You should see the remote device deliver data continuously. In your python code, you do not set the baud rate ? https://pys...
by ghp
Mon Sep 09, 2019 7:14 pm
Forum: Scratch
Topic: Raspberry Pi 4 and Scratch 2
Replies: 12
Views: 5213

Re: Raspberry Pi 4 and Scratch 2

Hello, had similiar problems here. Happens here on pi4, scratch2 both when uploading file for a sprite or stage background 'backdrop'. Selection menu opens, pi seems to be frozen in the menu. A ssh-connection to the pi is still working. "top" shows low cpu usage. "killall electron" stops scratch2. E...
by ghp
Sat Aug 31, 2019 5:04 am
Forum: Python
Topic: Help understanding 74HC595
Replies: 3
Views: 404

Re: Help understanding 74HC595

Calling clear() at the beginning of the operations, just after setup(), is needed. This avoids problems by GPIO having unknown state because program is stopped and restarted with again calling setup(). I would propose to change the code a bit. Instead of the block def inputBits(dat): for bit in rang...
by ghp
Sun Aug 25, 2019 8:04 pm
Forum: Python
Topic: ADS1115 I2C audio with python
Replies: 2
Views: 359

Re: ADS1115 I2C audio with python

The ADS1115 is a high precision device but rather slow: "programmable Data Rate:8 SPS to 860 SPS". This means that 430Hz are highest frequency resolvable. Cited from https://physics.stackexchange.com/questions/76463/what-is-the-meaning-of-frequency-of-a-human-voice: "According to the Wikipedia artic...
by ghp
Fri Aug 23, 2019 7:00 am
Forum: Deutsch
Topic: Schwingungsmessung bzw. Zeitwaage
Replies: 3
Views: 1819

Re: Schwingungsmessung bzw. Zeitwaage

Vielleicht wäre noch eine Echtzeituhr von nöten ? Wenn mal der Strom ausfällt und der Pi rebootet, dann ist die Zeit weg. Oder ggf. ein GPS Empfänger als Uhr-Ersatz. Die Erfassung der Pendelperiode sollte einigermassen genau sein ? Was sind da die Anforderungen ? 1 sekunde aufs Jahr würde bedeuten, ...
by ghp
Fri Aug 23, 2019 6:27 am
Forum: Python
Topic: Read IR Remote scancodes (no LIRC) from Waveshare ir sensor
Replies: 3
Views: 621

Re: Read IR Remote scancodes (no LIRC) from Waveshare ir sensor

Hello, your getkey method is matching the NEC code timings. Found a description for NEC here: https://exploreembedded.com/wiki/NEC_IR_Remote_Control_Interface_with_8051 To compare with RC5: https://en.wikipedia.org/wiki/RC-5 Your decoding logic could be improved: your code grabs logic levels and jus...

Go to advanced search