viernes, 23 de septiembre de 2016

Raspberry PI Universal Controller - Setting up IR Leds and using LIRC (Part 3)

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.
  1. Setting up LIRC
  2. Setting up IR Receiver and storing the codes
  3. Setting up IR Leds and using LIRC
  4. Create the Node API

The schematics

Now that I have the codes to emit, I need something to send them to the TV, Cable Box, whatever... Since I need to control devices that are apart from each other, I'll set up this with 3 IR leds to have a wide angle of action. 
I don't have the exact model of the IR leds (I dissemble a few remotes I had) but any cheap IR Led should do the work.
And I'll use a P2N2222AG NPN Amplifier Transistor to control the IR led from the GPIO pin.

The schematics looks like this:




In case you need a different amount of leds, you should calculate the R1. You can use this calculator: link. Using this values (not sure about this, this is my weakest point, please comment if you disagree)

Volts: 5 (output from the Pi)
Voltage Drop Across LED: 1.5 (avg. for most of the IR leds)
Desired LED Current: 20 (avg. for most of the IR leds)
How many leds connected: Set the number here


Using LIRC to send commands

Ok, we have the remote's codes in our LIRC config and we have the IR leds ready, let's test them!
Let's assume you set up a remote with the name: TV and you have a KEY_POWER in your config. Then you should be able to execute this:
>irsend send_once tv key_power
If you get this error:
irsend: could not connect to socket
irsend: No such file or directory
You'll need this first (got this from here):
>sudo lircd -d /dev/lirc0
then try again:
>irsend send_once tv key_power

If you don't see smoke coming out the Pi, we're good :). You can check if the led is working with your cellphone camera, the IR light is invisible for the naked eye, but you can see it through a cellphone camera. Also you can compare the strength of your leds light against the strength of any other remote. At first I was using a 220 resistor as R1 and 10K as R2. This was limiting the strength of the leds. 

Using 220 and 10K


Using 22 and 3.3K


At this point, you should be able to point the leds to your TV and send:
>irsend send_once tv key_power
To power it on/off ... yay!!!

Next, we'll set up a node API to get the orders and execute the commands we need.

No hay comentarios:

Publicar un comentario