B4R Library IR send and receive

rIRremote (Arduino) is based on IRremote open source project: https://github.com/z3t0/Arduino-IRremote
rIRremoteESP8266 (ESP8266) is based on IRremoteESP8266 open source project: https://github.com/markszabo/IRremoteESP8266

These libraries allow receiving IR signals with a IR receiver module and transmitting signals with an IR led.

The two libraries are mostly identical.

Receiving signals:
B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Private ir As IrReceive
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   ir.Initialize(6, "ir_Decoded") 'receiver is connected to pin 6, GND and 5v (or 3.3v on ESP8266)
   ir.Enable
End Sub


Private Sub ir_Decoded (Result As IrResult)
   Log("result: ", Result.DecodeType, ", ", Result.Value)
End Sub

Sending signals:
B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Private irsend As IrSend
   Private timer1 As Timer
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   irsend.Enable(38) 'frequency = 38khz
   timer1.Initialize("timer1_Tick", 500)
   timer1.Enabled = True
End Sub

Sub Timer1_Tick
   Dim m As UInt = Bit.And(Millis, 0xfff) 'get 12 bits
   Log("sending: ", m)
   irsend.SendRC5(m, 12)
End Sub

On ESP8266 the Enable method includes another parameter for the pin number.
On Arduino the pin is set in the library:
Arduino Mega 9 and 3 on other Arduino models.

The transmitting led should be connected with a 100 ohm resistor.

I'm not sure why, but in my tests the transmitting led range was very short (a few centimeters).
 

Attachments

  • rIRremote.zip
    98.6 KB · Views: 906
Last edited:

bdunkleysmith

Active Member
Licensed User
Longtime User
Here it shows the rIRremoteESP8266 library as v1.12, but when I install the library from the zip attached to the first post, it shows as Version 1.00 in the IDE.

Is there an updated zip containing v1.12 of the rIRremoteESP8266 library or is it a user error on my part?

PS I found the V1.12 .h & .cpp files in the GitHub repository and so created my own .xml file so I had v1.12, but in the process I added code to support sendFox, which I'm using in my current project and may be of interest to others who wish to use an ESP8266 in conjunction with a Foxtel cable/satellite TV box in Australia. I've now done the same for the rIRremote library.

What's the formal method to have such an update incorporated into the 'official' library?
 
Last edited:

bdunkleysmith

Active Member
Licensed User
Longtime User
Attached are updated libraries rIRremote v1.01 and rIRremoteESP8266 v1.13 which now provide IR support for Foxtel cable/satellite TV boxes in Australia.

As per comments included in the source files, the update was based on information at http://sikkits.com/uncategorized/android-phone-bluetooth-tv-remote/, however this is now dead and so Ken Shirriff's library referenced here may help those interested in more details.

The updates add the IrSend member sendFox(data As Byte) As void where data is mapped to the supplied IR remote control as follows:

B4X:
Key           data
0             0x00
1             0x01
2             0x02
3             0x03
4             0x04
5             0x05
6             0x06
7             0x07
8             0x08
9             0x09
Power         0x0C
Mute          0x0D
Info          0x0F
Vol+          0x10
Vol-          0x11
Chn+          0x20
Chn-          0x21
Fwd           0x28
Rew           0x29
Play          0x2C
Pause         0x30
Stop          0x31
Record        0x37
AV            0x38
Foxtel        0x4E
Setup         0x54
Up            0x58
Down          0x59
Left          0x5A
Right         0x5B
Select        0x5C
Red           0x6D
Green         0x6E
Yellow        0x6F
Blue          0x70
Help          0x81
Back          0x83
TV Guide      0xCC
Box Office    0xD5
Planner       0xF4
Active        0xFD

These codes were identified from this reference.

Note that even for the Foxtel IQ3 and IQ4 boxes which are supplied with a Bluetooth remote control, the boxes contain an IR receiver and so IR control can be used for all critical functions.
 

Attachments

  • rIRremote.zip
    65.4 KB · Views: 557
Last edited:

Roger C

Active Member
Licensed User
Longtime User
Hi,
This library is rather old now. On Github there's been updates and bugfixes just a few days ago.
I realize that I don't have the knowledge needed to update anything.
The XML-creator don't work with this so it needs a wrapper...
Maybe it's so easy to just exchange the supplied .h and .cpp-files. I don't know.

I've been working with C++ in arduino and trying to send IR-data from a database but got stuck with datatypes and conversions. After a week I'm free of errors but the TV still don't get it... The hardware works and sending the HEX-code directly works, but not when converted from a char array to uint_64t.
Thought I'd give B4R a try to see if it works better.
But I feel that this is too old to build a new projekt around.

Anyone who's made an updated library or could help with this?
I really want to learn how to wrap a library but right now is not the best time.

And regarding the distance, you need to use a transistor to get more power to the LED.
I have more than 20m range from my set up. When there's no sun and no obstacles in the way.
Here you'll get 100mA to the LED. Of course you need to check that it can handle that.

DIM0T.png
 

Star-Dust

Expert
Licensed User
Longtime User
I have an ESP32 WROOM-32 and I compiled this project. It gives me an error, user_interface.h is missing.
I downloaded user_interface.h from a site but then it tells me that other libraries are missing...
What am I missing and what am I doing wrong?
 
Top