WantToLearn101
Posts: 2
Joined: Sat Dec 01, 2018 11:19 am

Automatically turn on TV using PIR motion sensor and IR emitter

Sat Dec 01, 2018 11:43 am

I'm looking for a solution using a PIR motion sensor and a programmable IR emitter to detect when somebody enters a meeting room and send the same IR signal as the standard TV remote control, to turn the TV on.

I already have a Raspberry Pi, but I have never done any programming. I'm going to be studying the various beginners guides on this forum. I've been looking for a good project to try this out, and this would be really useful for the meeting rooms where I work, if I can get such a solution to work.

I have already bought an IR emitter:
https://cpc.farnell.com/energenie/ener3 ... EML007-005

And a PIR sensor:
https://www.ebay.co.uk/itm/Infrared-PIR ... %7Ciid%3A1

I read about some software called LIRC which I could use to program the IR emitter.

Does anybody have any specific guidance on how to do this? Has anybody already done something similar?

drgeoff
Posts: 9884
Joined: Wed Jan 25, 2012 6:39 pm

Re: Automatically turn on TV using PIR motion sensor and IR emitter

Sat Dec 01, 2018 2:42 pm

There is no single standardised IR protocol for IR remotes and within each of those there is no standardised code for each button on a remote. Unless you can find a library which includes the make and model of TV you will also need to initially use an IR receiver to extract the necessary info from the TV remote.

Each of the two parts of sensing motion and configuring plus using LIRC is well known. Google them separately, implement them separately and then join together.

WantToLearn101
Posts: 2
Joined: Sat Dec 01, 2018 11:19 am

Re: Automatically turn on TV using PIR motion sensor and IR emitter

Sun Dec 02, 2018 11:19 am

Thanks drgeoff,
The IR controller board which I ordered is actually a transceiver, containing both emitter and receiver, so hopefully I should be able to identify the correct signal.
I'm not sure yet how to differentiate between On and Off signals, because most remote controls use the same button for both. I guess there must be a way somehow.
I'm also not sure how easy it will be to connect up both the IR controller board and the PIR motion sensor to the Raspberry Pi at the same time, because the IR controller board will cover up most of the connector pins on the Raspberry Pi. But I'll see how to resolve that when I get to it!
I just purchased the Raspberry Pi User Guide 4th edition, to help get me started......

drgeoff
Posts: 9884
Joined: Wed Jan 25, 2012 6:39 pm

Re: Automatically turn on TV using PIR motion sensor and IR emitter

Sun Dec 02, 2018 11:59 am

Yes, almost all TV remotes have a single on-off button which toggles the TV state. Some TVs do respond to additional separate on and off codes but finding them is difficult as you cannot get them from the TV's remote control.

You may be lucky and find them online - they are commonly called "discrete codes" - or you may need to spend a long time methodically searching the possibilities with a One-for-All brand remote . Once you have one of those working with the TV most of them have a way to make it emit any code.

Andyroo

Re: Automatically turn on TV using PIR motion sensor and IR emitter

Sun Dec 02, 2018 12:26 pm

Have a look and see if you can find a way to record the on/off IR command from your original remote using the board you have.

Some of the 'programmable' remotes have this ability to cope with brands they do not know - may as well copy their idea :lol:

drgeoff
Posts: 9884
Joined: Wed Jan 25, 2012 6:39 pm

Re: Automatically turn on TV using PIR motion sensor and IR emitter

Sun Dec 02, 2018 7:38 pm

Andyroo wrote:
Sun Dec 02, 2018 12:26 pm
Have a look and see if you can find a way to record the on/off IR command from your original remote using the board you have.
@Andyroo.

The OP wrote "I'm not sure yet how to differentiate between On and Off signals, because most remote controls use the same button for both."

Andyroo

Re: Automatically turn on TV using PIR motion sensor and IR emitter

Sun Dec 02, 2018 10:06 pm

drgeoff wrote:
Sun Dec 02, 2018 7:38 pm
Andyroo wrote:
Sun Dec 02, 2018 12:26 pm
Have a look and see if you can find a way to record the on/off IR command from your original remote using the board you have.
@Andyroo.

The OP wrote "I'm not sure yet how to differentiate between On and Off signals, because most remote controls use the same button for both."
You will find it’s a toggle - the remote does not keep track of the TV condition! If you want to test it get in your car during the next set of adverts and drive a mile with the remote and Push the on/off button. Bet you when you get back the tv will still turn to off when you press it and the adverts will still be playing :lol:

Hence the use of the word ‘command’ and not commands.

drgeoff
Posts: 9884
Joined: Wed Jan 25, 2012 6:39 pm

Re: Automatically turn on TV using PIR motion sensor and IR emitter

Sun Dec 02, 2018 10:35 pm

Andyroo wrote:
Sun Dec 02, 2018 10:06 pm
drgeoff wrote:
Sun Dec 02, 2018 7:38 pm
Andyroo wrote:
Sun Dec 02, 2018 12:26 pm
Have a look and see if you can find a way to record the on/off IR command from your original remote using the board you have.
@Andyroo.

The OP wrote "I'm not sure yet how to differentiate between On and Off signals, because most remote controls use the same button for both."
You will find it’s a toggle - the remote does not keep track of the TV condition! If you want to test it get in your car during the next set of adverts and drive a mile with the remote and Push the on/off button. Bet you when you get back the tv will still turn to off when you press it and the adverts will still be playing :lol:

Hence the use of the word ‘command’ and not commands.
@Andyroo

You are not listening!

Both the OP and I know that virtually all TV remote controls only provide a single on-off IR signal which the TV uses to toggle to the opposite state. What you do not appear to comprehend is that the IR control system in some TVs also implements non-toggling on and off commands. That there are not individual on and off buttons on a remote control does not necessarily mean that a TV (or other device) does not have the inbuilt ability to respond appropriately to on and off codes if they are sent to its IR detector.

http://www.remotecentral.com/files/use-ir.htm

HiassofT
Posts: 220
Joined: Fri Jun 30, 2017 10:07 pm
Location: Salzburg, Austria
Contact: Website

Re: Automatically turn on TV using PIR motion sensor and IR emitter

Mon Dec 03, 2018 1:27 pm

You can rather easily send IR commands with ir-ctl. eg use "ir-ctl -S rc5:0x1234" to send a IR signal using the rc5 protocol with address (manufacturer) 0x12 and command 0x34.

BTW: I'd recommend using the latest v4l-utils version (currently 1.16.2), the version shipping with Debian/Raspbian is a bit dated and a bunch of handy features have been added in later versions (like the possibility to specify the gap between IR messages in case you need to transmit multiple messages, simulating a longer button press).

To find out which protocol and scancodes (signals) your TV/remote is using with ir-keytable - eg use "ir-keytable -p all -t". On kernel 4.19 with latest v4l-utils this'll print the protocol as well, on older versions you have to try each protocol manually and see if you get some output.

Once you know the protocol and scancodes you can play around trying to send other scancodes to find "hidden" features.

Search the forum for "ir-ctl" and "ir-keytable" and you'll find a couple of posts from me with more info about it (and how to use the gpio-ir / gpio-ir-tx overlays).

PS: better don't use lircd/irsend, about a year ago we ran into some nasty bugs with sending IR signals (lircd/irsend sometimes locked up) and this bug hasn't been fixed yet.

so long,

Hias

Return to “General discussion”