trigger GPIO for max 250mSec (remote press)

Moderator: leecollings

Post Reply
imdos
Posts: 34
Joined: Thursday 03 August 2017 21:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Contact:

trigger GPIO for max 250mSec (remote press)

Post by imdos »

I have 2 remotes which I want to control from my Pi3 with Domoticz.

The problem is that I need to simulate a press once instead of continous, to overcome strange behaviour.

Therefore I need a maximum trigger of 200 milliseconds approximately.

Is this possible with a Pi and what do I need to do?

I have tried it with python

Code: Select all

pi@raspberrypi:~ $ cat GPIO-test.py
import RPi.GPIO as GPIO            # import RPi.GPIO module
from time import sleep             # lets us have a delay
GPIO.setmode(GPIO.BCM)             # choose BCM or BOARD
GPIO.setup(17, GPIO.OUT)           # set GPIO17 as an output

GPIO.output(17, 1)         # set GPIO17 to 1/GPIO.HIGH/True
sleep(0.2)                 # wait half a second
GPIO.output(17, 0)         # set GPIO17 to 0/GPIO.LOW/False

Code: Select all

pi@raspberrypi:~ $ cat GPIO-testv3.py
#!/usr/bin/python3

import RPi.GPIO as GPIO
import time
led = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(led, GPIO.OUT)
endtime=time.time()+0.2 #200 milliseconds
GPIO.output(led, 0)
while (time.time()<endtime):
    GPIO.output(led, 1)
GPIO.output(led, 0)
But couldn't get it to work. The closest I got was to use dzVents.
I can do a switchoff after the amount of milliseconds (like this example: GPIOx.switchOff().afterSec(0.250) ), but am not able to turn it on for the right amount of time.
Making use of: Raspbian(SSD), dz Beta, Woonveilig, Z-Wave(alarm+multi-sensor), RFLink(blinds), P1, Yeelight, Xiaomi temp sensors, Tasmota(SonoFF, Blitzwolf SHP2, Shelly1)
imdos
Posts: 34
Joined: Thursday 03 August 2017 21:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Contact:

Re: trigger GPIO for max 250mSec (remote press)

Post by imdos »

Got the dzVents code solved. Now I have a new hurdle. Before Domoticz starts I have to set the GPIO pins to the correct mode.
When I change the behavior of the GPIO ports; the port is active / high and can't be changed instantly (after 200 milliseconds I can make a change). Even when I set it to low / off the LED (on the remote) continues to flash/blink for a while (like 5 seconds at least). Therefore while setting the GPIO outputs it is sending commands; which is not recommended.

Now I have to find out how to stop the LED from flashing/blinking when I enable the port. The code I use:

Code: Select all

sudo echo 17 > /sys/class/gpio/export ;
sleep 0.2; 
sudo echo out > /sys/class/gpio/gpio17/direction;  
sleep 0.2; 
sudo echo 0 > /sys/class/gpio/gpio17/value ; 
gpio exports
Is there another sequence or setup I could use?

I tried both methods from the Wiki
I even tried to connect the 3.3V PIN after I have configured the GPIO ports; but as soon as the remote receives power from the Pi it starts to blink as well.
Making use of: Raspbian(SSD), dz Beta, Woonveilig, Z-Wave(alarm+multi-sensor), RFLink(blinds), P1, Yeelight, Xiaomi temp sensors, Tasmota(SonoFF, Blitzwolf SHP2, Shelly1)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests