Fast pulsing input at Raspberry GPIO24 (gpio 5) pin 18 (input)

Moderator: leecollings

Post Reply
jesperlykke
Posts: 15
Joined: Sunday 25 October 2015 18:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Fast pulsing input at Raspberry GPIO24 (gpio 5) pin 18 (input)

Post by jesperlykke »

Hi here :)

I have this homemade Doorbell, which i have been using for some time now.
It's a standalone wireless doorbell, which i hacked and connected to the GPIO24 through/via a optocoubler for protecting the Pi.

The signal, which is sended from the bell, is around 3,5 - 4 Vdc... then this signal is converted into 3,0 Vdc via, as i described the optocoubler.
Anyway, the signal is fast pulsing, so there will be hundreds of pulses on the input, everytime someone push the doorbell buttom.

Until now i managed to use a Bashscript (Se below), but sometimes Domoticz is driven into 80-100% CPU useage, when using the doorbell.
I think it's a combine of filling the virtual switch which executes the script, whith hundreds of log lines :D , and the fact that the Domoticz are really occupied, with this pulse input. It's like pushing a lightswitch for hundreds of time, very fast.

So i was woundering if someone have an idea of howto solve this? -My thoughts was to completly avoid the Domoticz, and then let a Python daemon or like control this input? -Any ideas -Any code snippet?

Thanks everybody in advance !

Rgds; Jesper

Link to thread i opened in "Show youre projects" :
http://www.domoticz.com/forum/viewtopic ... 38&t=11304

Code: Select all

#!/bin/bash

SCRIPTDIR=/home/pi/scripts/doorbell
MESSAGE_1=$SCRIPTDIR/MESSAGE_1_ON_OFF

if [ ! -e $MESSAGE_1 ]; then
    touch $MESSAGE_1
echo 0 > $MESSAGE_1
fi
chown pi:pi $MESSAGE_1

EXECUTE_ON_OFF=$(cat $MESSAGE_1)

TOKEN=xxx:xxx
TEXT="HEY... DOORBELL"
CHAT_ID=xxx
RSER=192.168.1.121
RSER_PORT=8080
RIDX=71

SLEEPTIME=60            # Must be set to minimum time of MP3 tune (Seconds)
UNIXTIME=$(date +%s)    # %s   seconds since 1970-01-01 00:00:00 UTC

TIME1=$SCRIPTDIR/TIME1
if [ ! -e $TIME1 ]; then
   touch $TIME1
   let INIT_TIME=($UNIXTIME+$SLEEPTIME)
   echo $INIT_TIME > $TIME1
fi

UNIXTIME1=$(cat $TIME1)
echo "Unixtime ="$UNIXTIME1

if [ $UNIXTIME -gt $UNIXTIME1 ]; then
   let UNIXTIME2=($UNIXTIME+$SLEEPTIME)
   echo $UNIXTIME2 > $TIME1
   echo "EXECUTE"
        curl -s -i -H "Accept: application/json" "http://$RSER:$RSER_PORT/json.htm?type=command&param=switchlight&idx=$RIDX&switchcmd=On"

sleep 0.3

if [ $EXECUTE_ON_OFF -eq 1 ]; then
        curl -s -X POST https://api.telegram.org/bot$TOKEN/sendMessage -d text="$TEXT" -d chat_id=$CHAT_ID
fi

fi
exit

Edgar
Posts: 24
Joined: Saturday 13 September 2014 23:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands, -6 NAP
Contact:

Re: Fast pulsing input at Raspberry GPIO24 (gpio 5) pin 18 (input)

Post by Edgar »

Expand your electrical circuit with a retriggerable monoflop setup. It will recondition the pulse train to a single signal.
Only Robinson Crusoe had everything done by Friday
jesperlykke
Posts: 15
Joined: Sunday 25 October 2015 18:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Fast pulsing input at Raspberry GPIO24 (gpio 5) pin 18 (input)

Post by jesperlykke »

Expand your electrical circuit with a retriggerable monoflop setup. It will recondition the pulse train to a single signal.
Hi... Thanks for reply!

I am not into making an "advanced" circuit for this to accomplish :D ... Actually i find my Raspberry rather capable of acting as an flipflop/plc, in such cases as this.

So i am thinking going another direction (Python daemon / whatever...) - But again thanks for suggestion!

Rgds; Jesper.
Bikey
Posts: 331
Joined: Sunday 22 February 2015 12:19
Target OS: Linux
Domoticz version: 2020.x
Location: Netherlands
Contact:

Re: Fast pulsing input at Raspberry GPIO24 (gpio 5) pin 18 (input)

Post by Bikey »

Just adding a resistor and a capacitor is probably justthe easiest solution!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest