Input toggles output in Raspberry

Sam
Posts: 34
Joined: Mon Aug 22, 2016 5:51 am

Input toggles output in Raspberry

Post by Sam »

Hi,

I would like an input (pushbutton) in Raspberry Pi to toggle an output each time input becomes high. How do you get that feature?
I would also like the output to show status (ON or OFF) in Indigo state at that time of operation. Is it possible?
Of course, you can create this via a trigger in Indigo, but I would like the feature to be in RBpi.

Thanks in advance!

/Sam
Attachments
01.JPG
01.JPG (101.7 KiB) Viewed 6329 times
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: Input toggles output in Raspberry

Post by kw123 »

Yes, after thanksgiving.


Sent from my iPhone using Tapatalk
Sam
Posts: 34
Joined: Mon Aug 22, 2016 5:51 am

Re: Input toggles output in Raspberry

Post by Sam »

Great! Thanks.

/Sam
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: Input toggles output in Raspberry

Post by kw123 »

the string for the GPIO should work as you show it..

I guess you want to have the indigo device/state status to show ON/Off the the output gpio? .. the is not implemented as you circumvent the indigo part..
But you could use the GPIO in for that?


just a question.. how do you set it to OFF? with the down button, or another button?

Karl
Sam
Posts: 34
Joined: Mon Aug 22, 2016 5:51 am

Re: Input toggles output in Raspberry

Post by Sam »

Sorry,
What i meant was... i want the same pushbutton (normally open) connected to the input, to change the status of the output by an pulse on the input. The first pulse - sets the output to 1, the next pulse sets the output to 0 etc, if possible?

/Sam
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: Input toggles output in Raspberry

Post by kw123 »

this

Code: Select all

if (gpio -g read 18 | grep 1 ); then  gpio -g write 18 0; else gpio -g write 18 1 ; fi
should set gpio18 to 1 if current 0 and to 0 if currently 1 == toggle
Sam
Posts: 34
Joined: Mon Aug 22, 2016 5:51 am

Re: Input toggles output in Raspberry

Post by Sam »

Works perfect!

Thanks Karl!

/Sam
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: Input toggles output in Raspberry

Post by kw123 »

Cool. Thanks for feedback.
Will add this to device edit menu as an example.


Sent from my iPhone using Tapatalk
Sam
Posts: 34
Joined: Mon Aug 22, 2016 5:51 am

Re: Input toggles output in Raspberry

Post by Sam »

Hi,

I have installed the latest version 7.98.255 and have some problems with the OUTPUT-GPIO-1-ON/off.
The Indigo state of that output shows ”off” when my relay is activated and ”on” when its deactivated.
I tried to inverse the OUTPUT type but do not get it right anyway.
Is there any setting for reverse that function that I have missed?

Another question..
I have a couple of RPi's that I only use for GPIO's and displays. Is there any easy way to turn off the beacon function in these Pi:s and only use the sensors, input, output and displays?

/Sam
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: Input toggles output in Raspberry

Post by kw123 »

A). the inverse option in device edit should do what you want ..
the device states show 3 states:
1.OUTPUT_00 = command send to raspberry * inversion factor
2. actual GpoiValue = is the physical output high/ low
3. Status = output_00

status and output are the same, just historical . In devices with many outputs 00-24 you could select which output is used for status.
I have stopped supporting multiple output sper indigo device.

so play with inverses/normal in device edit that SHOULD do it.

B) use non beacon RPI
1. delete RPI in initial setup
2. wait 1 minute, may be reload plugin, to clear everything
3. make new RPI with sensor only (# 10..19) in initial setup.

Karl
Sam
Posts: 34
Joined: Mon Aug 22, 2016 5:51 am

Re: Input toggles output in Raspberry

Post by Sam »

Thanks,

In my previous version (7.94.244), the control of the output worked well, but now I can not get Indigo state to show "on" when the physical relay is active, regardless of whether I set the output type as normal or inverse.

/Sam
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: Input toggles output in Raspberry

Post by kw123 »

could you post parameters file from the RPi (is also on you indigo mac ~/indigo/pibeacon/parameters.x)

remove pwd ..

Karl
Sam
Posts: 34
Joined: Mon Aug 22, 2016 5:51 am

Re: Input toggles output in Raspberry

Post by Sam »

Is this the correct file?

Code: Select all

{
  "BLEserial": "sequential", 
  "GPIOpwm": "1", 
  "IPnumberOfRPI": "192.168.10.21", 
  "IndigoOrSocket": "indigo", 
  "acceptJunkBeacons": "0", 
  "acceptNewiBeacons": -999, 
  "addNewOneWireSensors": "0", 
  "authentication": "digest", 
  "bluetoothONoff": "on", 
  "debugRPI": {
    "debugRPIBEACON": 0, 
    "debugRPIBLE": 0, 
    "debugRPICALL": 0, 
    "debugRPIOUTPUT": 0, 
    "debugRPISENSOR": 0, 
    "debugRPImystuff": 0
  }, 
  "deleteHistoryAfterSeconds": 86400, 
  "deltaChangedSensor": "5", 
  "distanceUnits": "1.0", 
  "enableMuxI2C": "0", 
  "enableRebootCheck": "restartLoop,-", 
  "enableiBeacons": "0", 
  "indigoInputPORT": 12087, 
  "ipOfServer": "192.168.10.11", 
  "minPinActiveTimeForShutdown": 60, 
  "myPiNumber": "10", 
  "networkType": "fullIndigo", 
  "output": {
    "OUTPUTgpio-1-ONoff": {
      "17624462": [
        {
          "gpio": "21", 
          "initialValue": "-", 
          "outType": "0"
        }
      ]
    }
  }, 
  "passwordOfServer": "XXXXX", 
  "portOfServer": "8176", 
  "pressureUnits": "bar", 
  "rPiCommandPORT": "9999", 
  "rPiRestartCommand": "master", 
  "rebootCommand": "sudo killall -9 python; sleep 2;sudo reboot", 
  "rebootHour": 1, 
  "rebootWatchDogTime": "-1", 
  "restartBLEifNoConnect": false, 
  "sendAfterSeconds": "60", 
  "sendFullUUID": "0", 
  "sendToIndigoSecs": 90, 
  "sensorList": "", 
  "sensorRefreshSecs": 20.0, 
  "sensors": {}, 
  "shutDownPinInput": -1, 
  "shutDownPinOutput": -1, 
  "tempUnits": "Celsius", 
  "timeStamp": "2018-12-10-18:15:25", 
  "useRTC": "0", 
  "useRamDiskForLogfiles": "0", 
  "userIdOfServer": "Indigo", 
  "wifiOFF": "off"
}
/Sam
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: Input toggles output in Raspberry

Post by kw123 »

yes looks good...

could you go into the rpi and do:

cd pibeacon
sudo python master.py
tail -F temp/messageSend

w capital F

it should show any messages and also error messages

you should see something like this:

Code: Select all

tail -F temp/messageSend 
OUTPUTgpio:  {"outputs":{"OUTPUTgpio-1-ONoff":{"1964742022":{"actualGpioValue":"low"}}},"program":"OUTPUTgpio","ipAddress":"192.168.1.198","pi":"0"}
and some other lines

and do ps -ef | grep .py
should show:

Code: Select all

pi@raspberrypi:~/pibeacon $ ps -ef | grep .py
nobody     288     1  0 02:00 ?        00:00:00 /usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --socket /run/thd.socket --user nobody --deviceglob /dev/input/event*
pi        3044  2631  0 12:25 pts/0    00:00:00 grep --color=auto .py
root     30898     1  0 11:07 ?        00:00:06 /usr/bin/python /home/pi/pibeacon/master.py
root     31355     1  0 11:07 ?        00:00:02 /usr/bin/python /home/pi/pibeacon/copyToTemp.py
root     31482     1  0 11:07 ?        00:00:34 /usr/bin/python /home/pi/pibeacon/OUTPUTgpio.py   <<<<<=== this must run
root     31519     1  0 11:07 ?        00:00:22 /usr/bin/python /home/pi/pibeacon/INPUTgpio.py
root     31582     1  0 11:07 ?        00:00:10 /usr/bin/python /home/pi/pibeacon/tmp006.py
root     31588     1  0 11:07 ?        00:00:01 /usr/bin/python /home/pi/pibeacon/receiveGPIOcommands.py 9999
root     31821     1  4 11:07 ?        00:03:34 /usr/bin/python /home/pi/pibeacon/beaconloop.py
root     31972     1  0 11:07 ?        00:00:02 /usr/bin/python /home/pi/pibeacon/BLEconnect.py
Karl
User avatar
kw123
Posts: 8705
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: Input toggles output in Raspberry

Post by kw123 »

the line
"outType": "1"
should flip when you do normal/inverse.

and did you post the file from the RPI or from the indigo MAC.ie are the files updated?
do a menu send xxxx "all programs .." to the RPIs

Karl
Post Reply

Return to “piBeacon”