more G-Labs products

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

April 07, 2014, 10:27:44 AM
Read 13560 times

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
This is a small program you can import in HomeGenie from Configure->Automation section and will add 8 modules that will control Raspberry GPIOs and so any led or relay connected to them.

Instructions:
 
1) enter the RaspberrySharp group in Automation section then from Actions menu choose Import Program and select the attached hgx file;

2) after importing the program, click it in the list and go to Edit Source Code, then from Actions menu select the Update option (this is required only the first time a new program is imported):


(http://www.homegenie.it/docs/images/rpi/hg_rpigpio_01.jpg)


3) go back to the program list and click again the GPIO program, that will now display configuration options:


(http://www.homegenie.it/docs/images/rpi/hg_rpigpio_02.jpg)


Each GPIO can be configured as input (IN), output (OUT) or can be disabled (OFF).
GPIOs configured as IN are mapped to a Sensor module with a Status.Level field displaying current pin level (0, 1).
GPIOs configured as OUT are mapped to a Switch module that can be controlled with on/off commands.

After changing the configuration it is required to disable and re-enable the program in order to make it load the new settings.
Program enabling/disabling can be done by simply clicking on the rounded button you see to the right side of the list.


4) go back to the Configure->Group and Modules section and now you can add the GPIOs modules to a Control group:


(http://www.homegenie.it/docs/images/rpi/hg_rpigpio_03.jpg)


5) go back to the Home->Control section and you will now able to control the GPIO connected device =)


(http://www.homegenie.it/docs/images/rpi/hg_rpigpio_04.jpg)


Note that if in the system there are other applications that are using the GPIOs allocated by the program, it will stop with an error. In this case, you have to set already allocated GPIOs to OFF.

If you have enabled the Raspberry Pi GPIO interface from Configure->System and Interfaces, disable it since it is deprecated and probably not even working in latest HG release.


EDIT1: Updated GPIO program hgx that now let user customize pins as input or output (2014-04-08 00.22)
« Last Edit: April 07, 2014, 11:28:59 PM by Gene »

April 09, 2014, 03:23:44 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
(run video full screen to see annotations)

https://www.youtube.com/watch?v=bpZ5Y2UqBUc


« Last Edit: April 09, 2014, 03:27:57 PM by Gene »

May 03, 2014, 01:46:31 AM
Reply #2

mazzon

  • *
  • Information
  • Newbie
  • Posts: 2
The DHT-11 temperature sensor doesn' t work anymore. I have Set GPIO 4 to IN. But it only reads High.
Any ideas.
Thanks

May 03, 2014, 10:03:04 AM
Reply #3

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Set it to OFF indeed.

Cheers,
g.

May 03, 2014, 11:34:11 PM
Reply #4

mazzon

  • *
  • Information
  • Newbie
  • Posts: 2
I have it set to off.  I reset both programs and nothing changed. When I put the web service call in the web browser, to retrieve the temp it says "   { 'ResponseValue' : '' }  "

May 03, 2014, 11:42:09 PM
Reply #5

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Well.. on my configuration (hg r371), leaving GPIO program as is, the DHT is still working.
What version of HG are you running?
Did you try restarting the DHT-11 program?
If still not working dunno how to help any further.

g.

May 20, 2014, 04:59:41 AM
Reply #6

bradvoy

  • ***
  • Information
  • Full Member
  • Posts: 50
Is there a way to enable the Raspberry Pi's pullup or pulldown resistor on a GPIO pin that is configured for input?  I have a switch connected to one of my input pins.  When the switch is closed it consistently shows a Status.Level of 0.  But when the switch is open the Status.Level fluctuates between 0 and 1. 

May 20, 2014, 10:23:59 AM
Reply #7

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
The GPIO program does not offer any parameter for that at the moment.

You can either change the source code by adding some hard-coded instruction or extend the GPIO program in order to offer a new user definable configuration parameter "PinResistor" for each pin.

If you look at line 31 of the source code you see:

Code: [Select]

configuration[p] = new InputPinConfiguration(PinMapping.ToProcessor(pc.Pin));


you can add an hard-coded line like this:

Code: [Select]

configuration[p] = new InputPinConfiguration(PinMapping.ToProcessor(pc.Pin));
configuration[p].Resistor = PinResistor.PullUp;


this will configure every input pin as pullup.

Cheers,
g.

May 21, 2014, 03:50:34 AM
Reply #8

bradvoy

  • ***
  • Information
  • Full Member
  • Posts: 50
Thanks Gene.  I used this code

Code: [Select]
      ((InputPinConfiguration)configuration[p]).Resistor = PinResistor.PullUp;

since the Resistor property is on the InputPinConfiguration class but not its base class.  Now my switch state is being read reliably.

July 20, 2014, 06:02:54 PM
Reply #9

Kohinoor

  • *
  • Information
  • Newbie
  • Posts: 4
Anyone succeed in getting the DHT-11 module to work?

I can´t make it work(r400). The Adafruit example in Python works when I stop Homegenie
I don´t have the GPIO module activated.
Any Clues?
« Last Edit: July 20, 2014, 08:29:37 PM by Kohinoor »

July 20, 2014, 11:14:26 PM
Reply #10

RichieC

  • ***
  • Information
  • Full Member
  • Posts: 67
Is there any easy way to configure the GPIO outputs to be active low, but still show the outputs correctly in Homegenie (i.e off when off, on when on) ?

Im using a 4 relay module connected to the raspberry pi's GPIO ports, but it's inputs are actve low so in homegenie when it shows the output as on it is off etc. I want to use these relays to connect sirens and strobes from my old/existing alarm system so that i can use home genie as the house alarm instead (already have all sensors and PIRs connected via z-wave / x10  and working great!)

Would be nice if it was possible to use "Out+" and "Out-" to configure active high or active low outputs...  the same way that the inputs work with pull up/down resistors..

Richie
« Last Edit: July 21, 2014, 01:07:06 AM by RichieC »

July 21, 2014, 01:23:57 AM
Reply #11

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
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.

July 21, 2014, 01:28:18 AM
Reply #12

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
edit the dht-11 program and try changing the start delay value at line 24 (try values between 80 and 130).

g.



Anyone succeed in getting the DHT-11 module to work?

I can´t make it work(r400). The Adafruit example in Python works when I stop Homegenie
I don´t have the GPIO module activated.
Any Clues?

July 21, 2014, 01:40:33 AM
Reply #13

RichieC

  • ***
  • Information
  • Full Member
  • Posts: 67
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.

July 21, 2014, 01:58:00 AM
Reply #14

RichieC

  • ***
  • Information
  • Full Member
  • Posts: 67
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.