-->
Page 1 of 2

ESP8266 BASIC Universal learning IR Remote.

PostPosted: Sun Oct 02, 2016 7:47 pm
by Mmiscool
Hello,

Here is an example of how to create a universal learning ir remote.

Codes and button text are stored persistently in flash memory so that they are remembered after reboot.

This could be extended to be prettier with css or to add more buttons.

Works with NEC or SONY ir codes only.

IR receiver is hood to gpio 5 and the ir led is hood to gpio 4.

Will only work with latest version.

Code: Select alldim irButtons(6) as string
dim irCodes(6) as string
x = 0

ir.recv.setup(5) 
ir.send.setup(4) 
IRBRANCH [received]

for x = 1 to 6
    irButtons(x) = read("irbut" & str(x))
    irCodes(x)   = read("ircode" & str(x))
    if irButtons(x) = "" then irButtons(x) = "UNUSED"
next x

[top]
cls
Print "ESP8266 Basic Learning IR remote"
print "Last IR recvd"
textbox ircode
print "Text for button"
textbox newtxt
print "Button number"
dropdown x, "1,2,3,4,5,6"
Button "Program Code to button", [program]
print

button irButtons(1), [bu1]
button irButtons(2), [bu2]
button irButtons(3), [bu3]
print
button irButtons(4), [bu4]
button irButtons(5), [bu5]
button irButtons(6), [bu6]

IRBRANCH [received]
wait

[received]
ircode = ir.recv.full()
return


[bu1]
ir.send(irCodes(1))
x = 1
wait

[bu2]
ir.send(irCodes(2))
x = 2
wait

[bu3]
ir.send(irCodes(3))
x = 3
wait

[bu4]
ir.send(irCodes(4))
x = 4
wait

[bu5]
ir.send(irCodes(5))
x = 5
wait

[bu6]
ir.send(irCodes(6))
x = 6
wait

[program] 
irButtons(x) = newtxt
irCodes(x)  =  ircode
write("irbut" & str(x),irButtons(x) )
write("ircode" & str(x),irCodes(x))
goto [top]



Re: ESP8266 BASIC Universal learning IR Remote.

PostPosted: Thu Oct 20, 2016 3:38 am
by ardhuru
I tried the above (just the reception), and it works very well with RC6. But with another remote (NEC), it just identifies the protocol as NEC, but for any key it displays the same "ffffffff:NEC:0"

Has anyone had the same problem??

Also, when sending Sony or NEC codes, is the signal already modulated at around 38khz, or is it just raw data?

Thanks and Regards,

Anand

Re: ESP8266 BASIC Universal learning IR Remote.

PostPosted: Thu Oct 20, 2016 1:00 pm
by bugs
The signal is modulated - just connect the IR led and resistor for (very) short range or use a transistor driver for across the room.
The NEC receive program uses $FFFF as a sign that the previous key has been held down. It is a special NEC function code. If you stab the button quickly you should see the correct code.

Re: ESP8266 BASIC Universal learning IR Remote.

PostPosted: Tue Oct 25, 2016 2:23 am
by ardhuru
Hi Bugs, thanks for that information. I was waiting for my Saleae logic analyzer clone to arrive to reply meanigfully.

So, my new logic analyzer shows that all NEC commands are followed by a gap of 40 ms, in turn followed by a small frame of a few bits that is constant, regardless of which key is pressed. Things make much more sense now, I should be able to even bit-bang RC6 outputs, which are not supported in IR transmit.

Best $7 I have spent in recent times, its a delight to use this analyzer. http://www.ebay.com/itm/USB-Logic-Analy ... Swl9BWIMdL


Thanks.