[userMODULE] Lircd - Razberry IR control

Tips, Tricks and Scripts to enhance your home automation and workaround known device bugs, limitations and incompatibilities
Post Reply
dolpheen
Posts: 119
Joined: 10 Feb 2015 00:38

[userMODULE] Lircd - Razberry IR control

Post by dolpheen » 19 Apr 2015 20:27

Here is a razberry module for popular Lirc library that will allow you to control your Razberry Smart Home with any ordinary remote control or replace your any IR remote control with razberry.

In this topic I'll describe how to control your razberry devices with simple IR control priced 5$ or you can choose Logitech harmony for 150$ :)

Checked on razberries with 2.0.1-rc25 version.

Step 1 - Buy TSOP38238
To allow razberry to recieve IR commands we need the next part:
TSOP38238 Datasheet
IMG_0204s.JPG
IMG_0204s.JPG (142.24 KiB) Viewed 11612 times
Step 2 - Connect TSOP38238 to your Razberry
Power off your board. :!:
Connect 1st pin of TSOP to GPIO24
Connect 2nd pin of TSOP to Ground
Connect 3rd pin of TSOP to 3.3V

On my PI 2(same for PI B+) board it looks like
IMG_0206s.JPG
IMG_0206s.JPG (145.51 KiB) Viewed 11612 times
Where Red wire is 3.3V, Black wire is Ground and White wire is GPIO24

Step 3 - Install Lirc
Power on razberry.
Connect to SSH and issue the next command.

Code: Select all

sudo apt-get install lirc
With your favorite editor add the next lines to your '/etc/modules' file:

Code: Select all

lirc_dev
lirc_rpi gpio_in_pin=24 gpio_out_pin=25
and change '/etc/lirc/hardware.conf' file like

Code: Select all

########################################################
# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS="--uinput  --listen"

# Don't start lircmd even if there seems to be a good config file
# START_LIRCMD=false

# Don't start irexec, even if a good config file seems to exist.
# START_IREXEC=false

# Try to load appropriate kernel modules
LOAD_MODULES=true

# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="default"
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"

# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""
########################################################
For raspberry Pi 2 and B+ add the next lines to '/boot/config.txt'

Code: Select all

dtoverlay=lirc-rpi,gpio_in_pin=24,gpio_out_pin=25
For raspberry Pi 2 also run 'rpi-update'


Step 4 - Test IR reciever
Restart your Lirc deamon

Code: Select all

sudo /etc/init.d/lirc restart
Input the next commands to put IR reciever driver in debug mode

Code: Select all

sudo /etc/init.d/lirc stop
mode2 -d /dev/lirc0
Point any of your IR remote at your TSOP reciever and you then should see some lines added evry time you press a button on it
If something goes wrong check your TSOP connections and check this link

Step 5 - Learn IR codes from your remote
To learn codes from your remote follow a procedure described in this link


Step 6 - Install Lirc module to your razberry
Unpack and copy attached zip file to 'opt/z-way-server/Automation/userModules'
restart z-way server with '/etc/init.d/z-way-server restart'
After restart there will be a new Lircd module in Home Automation UI 'preference->modules->devices'
Select it and configure with 'localhost' for lircdURI.

Uh, at last installation is complete! :)


How to use it
On IR code recieving from one of your previously configured remotes the Lircd module emit event 'lircd.key' and pass an object with keyName (name of the key pressed) and isPressed (weather it was pressed or pressed and hold down).

Below is the sample for test.
Instantiate CustomUserCode module from 'Preferences->Modules->Scripting' and put the next code in it

Code: Select all

controller.on('lircd.key', function (event) { 
  if(event.keyName == 'KEY_1') {
    controller.devices.get('RemoteHA_3_ZWayVDev_zway_10-0-38').performCommand('on');
  }
})
or with eazyLogic module just put

Code: Select all

_z('dimmer on desk').onRemote('KEY_1').on()
_z('dimmer on desk').onRemote('KEY_2').off()

That's all! Comments are welcome ;)

In the next topic I'll describe how to replace all your IR remotes for your audio/video/climate equipment with Razberry.
Attachments
Lircd.1.0.1.zip
(1.92 KiB) Downloaded 258 times
Last edited by dolpheen on 20 Apr 2015 17:33, edited 2 times in total.
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test

dolpheen
Posts: 119
Joined: 10 Feb 2015 00:38

Re: [userMODULE] Lircd - Razberry IR control - Reciever

Post by dolpheen » 20 Apr 2015 16:59

How to replace IR remote controll with Razberry.
In the following section I'll describe how you can send IR signals to your electronic equipment allowing to replace native remote controls.

Step 1 - Buy IR emitter
You can buy any IR emitter powered from 5 or 3.3 Volts.
In my example I use the following board...
Or you can made it by yourself from a copuple of parts, here is the drawing...

Step 2 - Connect emitter to your razberry
Power off the board. :!:
Power 3.3V, Ground, GPIO pin No.25
In my case it looks like
IMG_0212s.JPG
IMG_0212s.JPG (137 KiB) Viewed 11538 times
Step 3 - Install and configure lircd
If you not already done that, follow Steps 3,5,6 from previous post in order to install all needed software and learn codes from your origin IR remote control.

Installtion is done!


How to use it
You can send any IR codes that you learned before directly from your scripts.
So that will allow you to control your electronic equipment (ex. control your TV, DVD or conditioning unit)
in order to send IR code you should emit an event like this

Code: Select all

controller.emit('lircd.send',{data:'SEND_ONCE vixter KEY_1'})
Here is:
SEND_ONCE mean send IR code only once (you can use also SEND_START or SEND_STOP for continious transmission)
vixter - name of your remote control (that was generated duiring learning, you can check it in '/etc/lirc/lircd.conf' in name field (that will allow you to emulate several remotes)
KEY_1 - name of your pressed key that you entered duiring the remote learning.

To send codes from eazyLogic module

Code: Select all

_z().remoteSendKey('KEY_3', 'vixter')
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test

pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: [userMODULE] Lircd - Razberry IR control - Reciever

Post by pz1 » 20 Apr 2015 17:24

Shouldn't the title of your second post be : Lircd - Razberry IR control - Send ??

Nice work again!

dolpheen
Posts: 119
Joined: 10 Feb 2015 00:38

Re: [userMODULE] Lircd - Razberry IR control

Post by dolpheen » 20 Apr 2015 17:34

Thank you, pz1!
The topic name is changed.
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test

bino29
Posts: 14
Joined: 15 Dec 2015 21:42

Re: [userMODULE] Lircd - Razberry IR control

Post by bino29 » 05 Jan 2016 12:49

Hi together,
is it possible to run the module on v.2.2.0?

Thanks in advance.

Post Reply