more G-Labs products

Author Topic: Send infrared commands  (Read 2966 times)

February 15, 2014, 09:18:33 AM
Read 2966 times

Jens

  • *****
  • Information
  • Global Moderator
  • Posts: 211
Hi Gene,

my idea is to use HG for complete scripts like close shutters, turn on the light and turn on the television. To be able to control the TV Set (or any other IR controlled device) I connected my IR transmitter to GPIO24. The layout I used is described here:

http://alexba.in/blog/2013/01/06/setting-up-lirc-on-the-raspberrypi/

I assumed, that /etc/modules would contain already a configuration for GPIO18 which is already
used as IR receiver from HG - but it's not.

Can I start adding

lirc_dev
lirc_rpi gpio_in_pin=18 gpio_out_pin=24

in /etc/modules or would I screw up HG for receiving IR commands?

Your support would be much appreciated to include this in HG UI.

Many thanks
Regards
Jens




February 15, 2014, 06:12:02 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi Jens,

in current HG SD card you will find this code in /etc/modules

Code: [Select]
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.

snd-bcm2835
lirc_dev
lirc_rpi gpio_in_pin=18 gpio_out_pin=17

also the following file must be present in order to make HG work with lirc (that is usually auto-generated by HG):

Code: [Select]
pi@raspberrypi ~ $ sudo cat /root/.lircrc
begin
        prog = homegenie
        button = KEY_1
        repeat = 3
        config = KEY_1
end

As long as you keep IR input on GPIO18, HG IR receiving will work.
So IR input is going through GPIO18. But currently HG do not handle IR output so, the driver should be improved to support this.
It shouldn't be difficult.
The source code of HG lirc handler can be viewed here:

http://sourceforge.net/p/homegenie/code/HEAD/tree/trunk/MIG/MIG/Interfaces/Controllers/LircRemote.cs

What should be done there is to add HG interface command for sending IR codes in the function

Code: [Select]
...
public object InterfaceControl (MIGInterfaceCommand request)
{
...
    switch (request.command) {
    ....
case "Remotes.IrSend":
            // call lirc irsend by calling ShellCommand("irsend", "SEND_ONCE "" + request.GetOption(0) + " " + request.GetOption(1) + """);
            // where request.GetOption(0) is the IrSend argument (eg. "mceusb/VolUp")
            // see C# automation program example later on this message
            break;
     ....
     }
}
...

Then it will be possible using HG automation wizard scripting or c# program to control the lirc interface for sending ir codes, eg:

Code: [Select]

var lirc = Modules.InDomain("Controllers.LircRemote").WithName("IR");
lirc.Command("Remotes.IrSend").Execute("mceusb/VolUp");


« Last Edit: February 15, 2014, 07:16:23 PM by Gene »

February 15, 2014, 07:49:46 PM
Reply #2

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Well... ended up adding IR send support to HG.
It is now available in r331.
Unfortunately I have no IR Led transmitter for testing it.

Cheers,
g.

February 16, 2014, 10:10:11 AM
Reply #3

Jens

  • *****
  • Information
  • Global Moderator
  • Posts: 211
Wow, Cool, thank's a lot. Will try once the new release is available for download.

BTW, I am doing manual install, can I just copy the new version to raspberry and run again

sudo gdebi homegenie-........

over the existing version or do I have to delete files before?

The upgrade via HG UI is for some reason not working for me and ended up in a waiting indicator continiously running.
So I started from scratch with R329.

Thanks
Jens

February 17, 2014, 12:16:45 AM
Reply #4

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
New r332 release is available for download.

If you are updating HG prebuilt sd card, you've to use the tgz archive: rename current HomeGenie folder, and unpack the new one.

If you want to proceed with installing on official Raspberry Pi debian sd card image, you can use the deb package and gdebi.
But then you'll also ave to configure yourself lirc as described in the previous post.

Upgrading from HG UI is still very untested and there are a couple of known issues.

Yesterday I found an old IR transceiver (mce usb) and so I could finally try IR sending. This is very cool =) I also added the ability of capturing an IR sequence from a Wizard Script. So now it's very easy to create scenarios that involve IR pheriperals as Hi-Fi, Tv, HVAC and so on.

Enjoy!
g.

February 17, 2014, 10:42:02 PM
Reply #5

Jens

  • *****
  • Information
  • Global Moderator
  • Posts: 211
Hi Gene,

It works fine with the IR LED on GPIO17 many thanks.

There is one more challenge ;-) In Interfaces / Lirc / add Remote the Database is not up to date for newer remotes. Are you pulling  the information online from the lirc webpage or is it stored locally?
I have to use irrecord to create a valid lircd.conf file. Unfortunate the created remote does not show up in HG UI - any suggestion to make it happen? It is still working but it would be even more perfect ;-)

BTW I upgraded this morning, this afternoon X10 was not working any more. I had to disable and enable X10 in Interfaces to make it working again - was there any change from R329?


Regards
Jens