IR-Remote-Receiver-Python-Module icon indicating copy to clipboard operation
IR-Remote-Receiver-Python-Module copied to clipboard

Can't understand the output

Open calania opened this issue 5 years ago • 6 comments

Hello, I have for a while now wanted to move an Arduino program that is controlled by an IR remote over to the raspberry pi. But it has been harder than I expected to find a python package that made decoding ir remotes easy. I found this package and got the example program working to some extent. The thing is that I don't understand what the output means. I am expecting that when I press a button on my remote that I should get a hex value printed. Instead, I get, what to me is a random number.

Starting IR remote sensing using DECODE function and verbose setting equal True Use ctrl-c to exit program Turning off verbose setting and setting up callback 45.14718055725098 72 . 94.50411796569824 72 .

I am guessing that there is some setting that I should change but I can't figure out which. I forexample know that one of my hexcodes are C81 so I have changed in the exaple file so that it is

elif code == 0xC81: print('D')

But I still only get a dot in the shell. I tried changing

else: print('.') # unknown code

to

else: print(code) # unknown code

But then it only prints either a 0 or -1. Does somebody have any idea what is happening?

calania avatar Apr 06 '20 08:04 calania

I have the same issue. A temporary solution I found is commenting from line 131 to 143 in IRModule.py. I think the problem is that the code here is only considering start signals from a SparkFun remote, but no other remote.

Maybe @owainm713 could have a solution for us ?

EDIT : after having a look, the real problem is from lines 139 to 143:

    if (pList[sIndex]<4 or pList[sIndex]>11):
        return -1

    if (pList[sIndex+1]<2 or pList[sIndex+1]>6):
        return -1

For example, my remote has these values: 0.6 < pList[sIndex] < 0.8 and 0.15 < pList[sIndex+1] < 0.3. Of course the boundaries are different of those in the conditions. So one solution is to edit the boundaries, another to comment these lines.

I think that the original code works perfectly with a TV remote for example (working for me), but needs to be modified for some other remotes (my HIFI system for example). My HIFI system sends 16 bits values, while yours sends 12 and SparkFun's sends 32 bits.

Balth-D avatar Apr 06 '20 15:04 Balth-D

Hi, this code is for NEC format IR remotes, so that start condition it is looking for is not specific to the Sparkfun remote (I have other NEC format remotes that it reads ok) so that is the first thing to confirm with the remotes you are working with.

owainm713 avatar Apr 06 '20 16:04 owainm713

I set up my IR receiver and ran the example program. The two numbers you are seeing e.g. 45.14718055725098 72 . are the IR signal total length in ms and the # of pulses recorded in that signal. There are couple print lines in the main module I forgot to comment out....oops.

To help debug/decode your signal in the example program if you comment out the following lines (79-81) and you will have more time to try decoding/debugging

#print('Turning off verbose setting and setting up callback') #ir.set_verbose(False) #ir.set_callback(remote_callback)

owainm713 avatar Apr 06 '20 19:04 owainm713

I'm not very familiar with the different IR protocols; I suppose my remote uses Sharp protocol, as it's a Sharp audio system remote. My data is sent on 16 bits by the way.

Balth-D avatar Apr 07 '20 08:04 Balth-D

Action for the single button at single press gives me 2 values thrice in 5 times. Delay in reading and printing the value. Pulse_check runs twice and remote call back prints twice.

Output:

Pulse
118.95608901977539 71
Pulse
Down Arrow
Down Arrow
Pulse
118.96109580993652 71
Down Arrow

Ashleymerwinraj avatar Mar 13 '21 06:03 Ashleymerwinraj

The sensor may be picking up a repeat code (i.e. if the button is held down). Try turning the repeat code functionality off and see if it still happens. Use the set_repeat(False) function.

owainm713 avatar Mar 14 '21 23:03 owainm713