How to wire for IrDA ?

User avatar
DataDigger
Posts: 13
Joined: Sun Aug 20, 2017 1:58 am

How to wire for IrDA ?

Postby DataDigger » Sun Aug 20, 2017 2:33 am

The awesome ESP32 has IrDA support, but how to wire it ? (I can't find any Docs nor further Information about that)

Does it need an "Infrared Encoder/Decoder" (like an MCP2120 with additional Crystal) and a "Infrared Transceiver Module" ?

Or can the ESP32 directly generate the IRTX and decode the IRRX so just a IR-LED and a IR-Phototransistor is needed ?

User avatar
DataDigger
Posts: 13
Joined: Sun Aug 20, 2017 1:58 am

Re: How to wire for IrDA ?

Postby DataDigger » Sat Nov 04, 2017 11:54 pm

Yes! I figured it out, it's working with just a few additional parts and only 2 Bits to set.

I have a "WEMOS LOLIN32" Board, others are similar but Pin numbers may vary.

For "send only" with Arduino IDE:

Code: Select all

//HardwareSerial Serial1(1);
HardwareSerial Serial2(2); // GPIO 17: TXD U2  +  GPIO 16: RXD U2

void setup() {
    Serial.begin (115200); // (USB + TX/RX) to check
    Serial2.begin(115200); // GPIO 17: TXD U2  +  GPIO 16: RXD U2

    //UART_CONF0_REG  Configuration register 0
    //UART0: 0x3FF40020
    //UART1: 0x3FF50020
    //UART2: 0x3FF6E020

    WRITE_PERI_REG( 0x3FF6E020 , READ_PERI_REG(0x3FF6E020) | (1<<16 ) | (1<<10 ) );  //UART_IRDA_EN + UART_IRDA_TX_EN  "Let there be light"
    //Serial.print("Reg: "); Serial.println(READ_PERI_REG(0x3FF6E020),BIN);  //For Debug only
}//setup

void loop() {
    Serial.println("Hello");
    Serial2.println("Hello");
    delay(1000);
} //loop
And just a Infrared-LED and a Resistor ! That's it !



For receive:

Code: Select all

//HardwareSerial Serial1(1);
HardwareSerial Serial2(2); // GPIO 17: TXD U2  +  GPIO 16: RXD U2

void setup() {
    Serial.begin (115200); // (USB + TX/RX) to check
    Serial2.begin(115200); // GPIO 17: TXD U2  +  GPIO 16: RXD U2

    //UART_CONF0_REG  Configuration register 0
    //UART0: 0x3FF40020
    //UART1: 0x3FF50020
    //UART2: 0x3FF6E020

    WRITE_PERI_REG( 0x3FF6E020 , READ_PERI_REG(0x3FF6E020) | (1<<16 ) | (1<<9 ) );  //UART_IRDA_EN + UART_IRDA_DPLX  "Let there be light"
    //Serial.print("Reg: "); Serial.println(READ_PERI_REG(0x3FF6E020),BIN);  //For Debug only
}//setup

void loop() {
    while (Serial2.available()) {
        Serial.print( (char) Serial2.read() );
        delay(2);
    } //while
} //loop
It works with just a Phototransistor and a Resistor !
But use a "Infrared Transceiver Module" (like TFDU4101), that contains a Amplifier, Comparator, some Logic and a Driver for better results.
ESP32-IrDA-Send-Receive.jpg
ESP32-IrDA-Send-Receive.jpg (64.71 KiB) Viewed 18598 times
ESP32-IrDA.jpg
ESP32-IrDA.jpg (33.65 KiB) Viewed 16884 times
Last edited by DataDigger on Sun Dec 09, 2018 2:10 am, edited 1 time in total.

fullstackfool
Posts: 2
Joined: Mon Mar 19, 2018 6:51 am

Re: How to wire for IrDA ?

Postby fullstackfool » Mon Mar 19, 2018 6:54 am

Hi there,

I'm trying to get exactly this working with the Sparkfun esp32 Thing, but getting nowhere. It's sending the burst out from the IR, but it's junk data - i'm not sure the 38kHz carrier is being added. I know this is a little vague but have you any advice?

User avatar
DataDigger
Posts: 13
Joined: Sun Aug 20, 2017 1:58 am

Re: How to wire for IrDA ?

Postby DataDigger » Tue Mar 20, 2018 10:26 pm

Infrared has two complete different Modes:
IrDA for Datatransfer in both directions
and TV Remotes, one-way with a modulation of 35 or 38 kHz.

For the TV Remote, just switch the IR-LED on and off that it build the 38 kHz Packet (use delays or a PWM Output).

Use an Oscilloscope (borrow one or ask your local FabLab) with an Phototransistor and (Dummy-) Load Resistor to see what is being sent or to copy the Signals of your TV Remote.

If there is still junk date, check the Resistors, for an IR-LED it's way lower than an usual LED (just 100 Ohm and lower, depends on the Datasheet)
also check the Resistor of the Phototransistor, if the value ist too low, Data High Pulses can't reach full voltage - is it to high, the High potentials can't flush fast enough and jam the Datastream, I got best results with an potentiometer and some Try&Error :mrgreen:

BobMorane
Posts: 1
Joined: Wed Aug 01, 2018 3:26 pm

Re: How to wire for IrDA ?

Postby BobMorane » Sat Sep 01, 2018 7:02 am

hello,
i tried the same setup and i didnt get anywhere.
it looks like there is a problem with uart2 in the board.

did you actually get it running like you describe it only with the IR leds?
maybe the bug only accurs to newer boards.

what resistors did you use?

thanks in advice

Bob

User avatar
DataDigger
Posts: 13
Joined: Sun Aug 20, 2017 1:58 am

Re: How to wire for IrDA ?

Postby DataDigger » Sun Sep 02, 2018 7:07 pm

Hello Bob,

I tried it first without any IrDA Code, just a wired serial connection with 5V TTL Levels. (Cross Rx->Tx and vice versa)

As that worked, I set it up with a normal LED to see if there is some activity, then I checked it with an Oscilloscope.

Then I set up the IR-LED with R1 = 100 Ohm and R2 = 4.9 k Potentiometer and connected the Oscilloscope to RXD2 and turned the Poti till I got a good signal and then the Data came through over IR :-)

I bought all Boards at once from the same Version and still use them, so I don't know any changes.

Hope that helps !
DD

quangan
Posts: 3
Joined: Fri Feb 01, 2019 9:11 am

Re: How to wire for IrDA ?

Postby quangan » Fri Feb 01, 2019 9:18 am

DD,

I searched all over the internet and your post is the closest thing I've found to the IrDA enablement!

I'm using the Arduino IDE to program the m5stack (ESP32 chip) and cannot seem to find any info on how to enable the IrDA without typing the explicit register setting code that you have. Is this the only way to enable those bits? I found the definitions for uart_set_mode(UART_NUM_2, UART_MODE_IRDA) under the ESP32 SDK but cannot get Arduino IDE to locate the library.

What distance have you been able to get the reception to work at 115kbaud?

Thanks!
Q

User avatar
DataDigger
Posts: 13
Joined: Sun Aug 20, 2017 1:58 am

Re: How to wire for IrDA ?

Postby DataDigger » Sat Feb 02, 2019 5:12 am

Hello Q

I guess yes, because I also didn't find anything else.
There is no Library, it's all in Hardware. A Hardware UART that can switch into IrDA Mode by activate the Bit's in the Register.

Got it to work from 5mm up to 3 m with 3.3 Volt and up to 4 m with 5 Volt on the TFDU4101.

Hope that helps.
DD

quangan
Posts: 3
Joined: Fri Feb 01, 2019 9:11 am

Re: How to wire for IrDA ?

Postby quangan » Sun Feb 03, 2019 11:03 pm

This is really promising info. I've been looking for a way to transmit using IR at 1-3m but with faster speed than 2400 baud modulating at 38KHz. Your example is exactly what I'm looking for.
I understand that in the consumer IR, with 38KHz, the receiver does quite a bit of filtering to make sure the data coming through is clean... with your simple circuit, do you find a lot of random noise coming in and corrupting the bits? Are you implementing any type of error correction or checksum in your transmission?

Thank you!
Q

quangan
Posts: 3
Joined: Fri Feb 01, 2019 9:11 am

Re: How to wire for IrDA ?

Postby quangan » Sun Feb 10, 2019 2:01 pm

one more question, what distance were you able to get with the raw components?

Who is online

Users browsing this forum: Baidu [Spider] and 105 guests