How to wire for IrDA ?

User avatar
DataDigger
Posts: 3
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: 3
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 932 times


ESP32-IrDA.jpg
ESP32-IrDA.jpg (26.68 KiB) Viewed 932 times

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: 3
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:

Who is online

Users browsing this forum: fhng11214 and 7 guests