Intro
This is a series of posts on how to make an universal remote controller out of a Raspberry Pi and use it with a node API.
- Setting up LIRC
- Setting up IR Receiver and storing the codes
- Setting up IR Leds and using LIRC
- Create the Node API
Setting up the IR Receiver
After setting up LIRC, I need to get the codes of the remote controllers I want to use. LIRC will help a lot with this, but first I need to attach an IR sensor to the Pi for that.
I'm using a sensor I get from this pack: https://www.amazon.com/gp/product/B017YKHSAI/ref=oh_aui_detailpage_o01_s01?ie=UTF8&psc=1 but pretty much any IR sensor would do the job.
The sensor has 3 legs (S, GND, VCC), the wiring is like this:
If you're using the same sensor as I am, you should be able to just point any remote control to it, push any button and a little led in the sensor board will blink.
Back to the Pi, I need to check if LIRC is getting the codes, so I run these commands:
> sudo /etc/init.d/lirc stop > mode2 -d /dev/lirc0
Now, I can point my remote to the sensor and press any key, and it shows something like this:
space 23224 pulse 85 space 44506 pulse 43 space 55634 pulse 55
If you see something like that, it's working!
Getting the Codes
LIRC uses a config file to know the codes it need to send for each remote. If you're lucky enough, you'll find a config file for your remote here: link
If not, you'll have to create one. But fear not! LIRC has a pretty straight forward method to do it:
#Stop lirc service > sudo /etc/init.d/lirc stop #Create a new config file named remote1.conf > irrecord -d /dev/lirc0 ~/remote1.conf
You'll be asked to press several buttons, and a few more steps to detect your remote. Then you'll be asked to record every independent key you want. You'll need this list for naming the keys. Or you can run irrecord with the -n option to name the keys whatever you want.
Side note: If you want to record an AC remote controller, have in mind that those remotes send the full status, so you can't save the independent keys. The path I took for recording the AC remote was to record every state I wanted as an independent key. For example, to set the AC for HOT 24°, I set that in the AC remote in off mode, then I recorded the key when pressing the Power On button. That would be recording the status: ON with HOT air at 24°. So I saved that as a key with name: HOT_24. And repeated that step for every status I wanted to set.
After finishing the recording, open the newly created file:
> nano ~/remote1.conf
And change the name line to whatever the name of the remote you want, like this:
begin remote
name /home/pi/lircdCable.conf
flags RAW_CODES
eps 30
aeps 100
...
To:
begin remote
name cable
flags RAW_CODES
eps 30
aeps 100
Then, you'll have to copy the content of that file to /etc/lirc/lircd.conf
You'll have to repeat this steps for every remote you need.
Here's an example of my lircd.conf:
#UNCONFIGURED
#
# To find out how to get a proper configuration file please read:
#
# /usr/share/doc/lirc/README.Debian
begin remote
name tv
bits 16
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 4563 4453
one 605 1637
zero 605 516
ptrail 607
pre_data_bits 16
pre_data 0xE0E0
gap 108077
toggle_bit_mask 0x0
begin codes
BTN_BACK 0xA659
KEY_POWER 0x40BF
KEY_MENU 0x58A7
end codes
end remote
begin remote
name denon
bits 24
flags SPACE_ENC
eps 30
aeps 100
header 3378 1673
one 466 1215
zero 466 374
ptrail 470
pre_data_bits 24
pre_data 0x2A4C02
gap 74648
min_repeat 1
# suppress_repeat 1 uncomment to suppress unwanted repeats
toggle_bit_mask 0x0
begin codes
KEY_POWER 0x8A0088
KEY_VOLUMEUP 0x80E86A
KEY_VOLUMEDOWN 0x88E862
end codes
end remote
Now that I have saved the remote's codes I need to build the circuit for the IR leds in the next post.



No hay comentarios:
Publicar un comentario