more G-Labs products

Author Topic: [APP] GPIO Input/Output modules  (Read 13560 times)

July 22, 2014, 11:26:33 PM
Reply #15

RichieC

  • ***
  • Information
  • Full Member
  • Posts: 67
Gene,

How can i modify the GPIO program to change the inital state of the switches when it starts? - so that they are on instead of off  - so they are off in my case - if that makes sense!?

If i also, invert the true/false at lines 85 and 89.. it then works correctly, but when homegenie starts the switches default to on.

Thanks Gene, would be great if you could add that..

I tried making the change you suggested and this does make the on/off leds on the homegenie switch modules display correctly, but the on/off buttons are still reversed..

Hi RichieC,

I'll add this functionality to the gpio program.
In the meantime you can edit the gpio program and invert 0/1 values at line 56 (see picture).

Cheers,
g.

May 13, 2015, 11:38:05 PM
Reply #16

Strojki

  • *
  • Information
  • Newbie
  • Posts: 1
Hi,
Few weeks ago I installed HG on my RPi as a Z-wave gateway. I realized that GPIO can be of great use for adding more switches with relays, and I bought 8 port relay module, and it works great with 100 GPIO Modules.

Now, I consider it so great, that I miss GPIO ports. I found that P5 Header on RPi have 4 more GPIO ports, but it requires some work on soldering. So, I did it, and by default, I can't use it with 100 GPIO Moudules, and I made following changes in the code:

Code: [Select]
var pinMapping = new List<dynamic>();
// read GPIO configuration
var gpio4  = Program.InputField("GPIO4").Value.ToLower();
var gpio17 = Program.InputField("GPIO17").Value.ToLower();
var gpio18 = Program.InputField("GPIO18").Value.ToLower();
var gpio21 = Program.InputField("GPIO21").Value.ToLower();
var gpio22 = Program.InputField("GPIO22").Value.ToLower();
var gpio23 = Program.InputField("GPIO23").Value.ToLower();
var gpio24 = Program.InputField("GPIO24").Value.ToLower();
var gpio25 = Program.InputField("GPIO25").Value.ToLower();
var gpio28 = Program.InputField("GPIO28").Value.ToLower();
var gpio29 = Program.InputField("GPIO29").Value.ToLower();
var gpio30 = Program.InputField("GPIO30").Value.ToLower();
var gpio31 = Program.InputField("GPIO31").Value.ToLower();

// add configured GPIOs to a list that will be used to configure the connection
if (gpio4  != "off") pinMapping.Add(new { Config = gpio4, Address =  "GPIO4", Pin =  ConnectorPin.P1Pin7, Direction = ( gpio4.EndsWith("out") ? PinDirection.Output : PinDirection.Input), Reversed = gpio4.StartsWith("!") });
if (gpio17 != "off") pinMapping.Add(new { Config = gpio17, Address = "GPIO17", Pin = ConnectorPin.P1Pin11, Direction = (gpio17.EndsWith("out") ? PinDirection.Output : PinDirection.Input), Reversed = gpio17.StartsWith("!") });
if (gpio18 != "off") pinMapping.Add(new { Config = gpio18, Address = "GPIO18", Pin = ConnectorPin.P1Pin12, Direction = (gpio18.EndsWith("out") ? PinDirection.Output : PinDirection.Input), Reversed = gpio18.StartsWith("!") });
if (gpio21 != "off") pinMapping.Add(new { Config = gpio21, Address = "GPIO21", Pin = ConnectorPin.P1Pin13, Direction = (gpio21.EndsWith("out") ? PinDirection.Output : PinDirection.Input), Reversed = gpio21.StartsWith("!") });
if (gpio22 != "off") pinMapping.Add(new { Config = gpio22, Address = "GPIO22", Pin = ConnectorPin.P1Pin15, Direction = (gpio22.EndsWith("out") ? PinDirection.Output : PinDirection.Input), Reversed = gpio22.StartsWith("!") });
if (gpio23 != "off") pinMapping.Add(new { Config = gpio23, Address = "GPIO23", Pin = ConnectorPin.P1Pin16, Direction = (gpio23.EndsWith("out") ? PinDirection.Output : PinDirection.Input), Reversed = gpio23.StartsWith("!") });
if (gpio24 != "off") pinMapping.Add(new { Config = gpio24, Address = "GPIO24", Pin = ConnectorPin.P1Pin18, Direction = (gpio24.EndsWith("out") ? PinDirection.Output : PinDirection.Input), Reversed = gpio24.StartsWith("!") });
if (gpio25 != "off") pinMapping.Add(new { Config = gpio25, Address = "GPIO25", Pin = ConnectorPin.P1Pin22, Direction = (gpio25.EndsWith("out") ? PinDirection.Output : PinDirection.Input), Reversed = gpio25.StartsWith("!") });
if (gpio28 != "off") pinMapping.Add(new { Config = gpio28, Address = "GPIO28", Pin = ConnectorPin.P5Pin3, Direction = (gpio28.EndsWith("out") ? PinDirection.Output : PinDirection.Input), Reversed = gpio28.StartsWith("!") });
//if (gpio29 != "off") pinMapping.Add(new { Config = gpio23, Address = "GPIO29", Pin = ConnectorPin.P5Pin4, Direction = (gpio29.EndsWith("out") ? PinDirection.Output : PinDirection.Input), Reversed = gpio29.StartsWith("!") });
//if (gpio30 != "off") pinMapping.Add(new { Config = gpio24, Address = "GPIO30", Pin = ConnectorPin.P5Pin5, Direction = (gpio30.EndsWith("out") ? PinDirection.Output : PinDirection.Input), Reversed = gpio30.StartsWith("!") });
//if (gpio31 != "off") pinMapping.Add(new { Config = gpio25, Address = "GPIO31", Pin = ConnectorPin.P5Pin6, Direction = (gpio31.EndsWith("out") ? PinDirection.Output : PinDirection.Input), Reversed = gpio31.StartsWith("!") });


When I try to complie it, I get following error:
Code: [Select]
Connector pin P5-3 is not mapped to processor with pin layout revision 1

And, my expertise stops here. Any help ideas?

June 22, 2016, 08:47:07 AM
Reply #17

divanshu6467

  • *
  • Information
  • Newbie
  • Posts: 21
i tried to gpio module in my homegenie of rpi but it shows the following error

1. MemoryGpioConnectionDriver is only supported on Raspberry Pi
2. at Raspberry.IO.GeneralPurpose.MemoryGpioConnectionDriver..ctor () [0x00000] in :0
3. at Raspberry.IO.GeneralPurpose.GpioConnectionSettings.get_DefaultDriver () [0x00000] in :0
4. at Raspberry.IO.GeneralPurpose.GpioConnectionSettings..ctor () [0x00000] in :0
5. at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.GpioConnectionSettings settings, IEnumerable`1 pins) [0x00000] in :0
6. at Raspberry.IO.GeneralPurpose.GpioConnection..ctor (Raspberry.IO.GeneralPurpose.PinConfiguration[] pins) [0x00000] in :0
7. at HomeGenie.Automation.Scripting.ScriptingInstance.RunCode (System.String PROGRAM_OPTIONS_STRING) [0x00000] in :0
8. at HomeGenie.Automation.Scripting.ScriptingInstance.Run (System.String PROGRAM_OPTIONS_STRING) [0x00000] in :0


suggest some channges to do in code

July 02, 2016, 12:10:42 AM
Reply #18

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271
what model Pi are you trying to use?

September 19, 2016, 09:04:31 PM
Reply #19

Satya

  • *
  • Information
  • Newbie
  • Posts: 3
Hi Folks,

  Could anyone any help me out configure GPIO PIN as IN.

My Setup:
  - Installed HG on RPi through .deb  package. ( v1.1 beta r525 )
  - Installed RaspberryPi GPIO Package in HG.

Able to configure GPIO pin as OUT and toggle switch.

How to do it as INPUT ?

H/w setup pin GPIO17 with button.

In GPIO Modules:
Set GPIO PIN 17 as IN.
Imported that PIN on to a group and Display -Sensor.
Also observed in backend GPIO 17 is configured as "in" direction.

I didn't observe the Level changing on Displayto ON/OFF.  It always shows OFF. But through commandline Python script able to catch
button press event.


One more thing.
Can i use python program directly in HomeGenie ProgramCode by setting Progarm Type as Python Script.


Thanks for help

Regards,
Satya

« Last Edit: September 19, 2016, 09:10:13 PM by Satya »

September 20, 2016, 05:31:22 PM
Reply #20

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I'm running r519 but I doubt this would be any different.  I use GPIO25 as an input for my motion sensor.

September 21, 2016, 08:09:37 PM
Reply #21

Satya

  • *
  • Information
  • Newbie
  • Posts: 3
Cool.. Thanks @bkenobi.

I was setting just IN. Changed IN+. Its working.

I will find which setting works for my setup.

I am going to try PIR sensor as IN. I am not sure i can try that or not. any help before experiment will be great to me.

September 22, 2016, 05:26:59 PM
Reply #22

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I'd just give it a try.  It will probably need the pull-up or pull-down set depending on your hardware.  Once you get it in there, add a virtual module of type sensor and it should show motion out of the box.  I believe I initially had an issue with the sensor being reversed but believe switching pull-up/pull-down fixed it.  It's been a while, so I don't remember actually.

October 11, 2016, 10:16:16 AM
Reply #23

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271
PIR's work fine on GPIO :) - so long as the output for the PIR is compatible, IE dry contacts :)

I got some external 12v Pir's from china via ebay which work great, I just wind the timer right down and turn the light level whichever way works in day light..

I had to alter the connections from the relay to do what I needed, but domestic alarm pir's would be fine..

I have these wired to gpio's for the outside lights :)

October 11, 2016, 04:26:59 PM
Reply #24

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
My motion sensor is not actually compatible with GPIO's so I had to do a little hacking about.  I was initially going to modify the module, but chose an alternate route that works well.  The motion sensor is intended for use with a lamp so the output is 110VAC.  Since I can't send that to the RPi, I installed a 110VAC relay with a dry contact output.  Since the motion sensor must have a load, I installed a 40W bulb inside the garage which toggles on any time motion is sensed (turns into a really nice motion notifier if your in the garage).  The dry contacts on the relay go to the GPIO directly.  I turned the motion sensor into "test" mode since that triggers for all events rather than using the 1-30 minute timer and only at night.  As a result, I can use HG to determine what sensed motion means day or night.  If your interested, check out the Advanced Smart Lights code in the APP section.  It uses this setup to trigger a chime(s) and/or a light module(s) and can even be over-ridden by a switch if desired.

October 11, 2016, 08:37:45 PM
Reply #25

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271
Does anyone else use inverted inputs and have issues with the widget needing to be inverted?

November 23, 2016, 05:16:24 PM
Reply #26

djatie

  • **
  • Information
  • Jr. Member
  • Posts: 34
today i upgrade to HomeGenie 1.1 beta r525, my gpio on but after restart its off so i must mannualy on it, its normal or not? if normal i want to downgrade the homegenie version, dont like this feature.

and now my homegenie if go home page its show nothing, i must click refresh button.
« Last Edit: November 23, 2016, 05:18:37 PM by djatie »