Serial TX over infrared LED modulated 38KHz

Hello all,

I have a Leonardo board and would like to send serial data over an IR led modulated at 38KHz connected to one of my TX pins.

Do you know if there is a library that allows this?

All the ones I found only allow to send signals according to a specific protocol (NEC, Sony, etc.). What I need is to send the serial output as is, preferably at 4800 bps.

I guess the issue is to combine the serial communication signal with the modulation frequency.

If this is not possible then probably the solution is to buy an infrared emitter like this one:


As far as I understand the NE555 takes care of the 38KHz and I could connect it directly to serial. Am I correct?

Thank you very much.

As you know bandwidth and data rate are related by the modulation format. Different modulation formats will require different bandwidths for the same data rate. In FSK, the bandwidth is approximately Δf + r where Δf is the separation between the two frequencies and r is the bit rate. What modulation format are you planning on using to support your 4.8K baud? What are you planning on using for a detector? Try reading or watching a few tutorials on basic electronics.

Hello Gil,

Thank you for your answer.

I want to use the Vishay TSDP34138 IR receiver which there isn't any information on the web besides the official datasheets:

The demodulated output can be directly connected to a UART or a microprocessor. The TSDP34138 may be used for continuous reception of data according to RS-232 at 4800 bps in noise free environments.

This receiver is specifically designed for continuous data transfer. Most of the information I found relates to the other TSOPs which are designed for codes like AC.

So I guess I am using ASK and not FSK.

I don't plan to send data constantly in my application, more like in occasional bursts, but I want to transfer it over standard serial protocols.

Best regards.

What you want to do definitely doable since I've done it many times.

First you need to generate the carrier frequency you want. This can usually be done using a PWM peripheral or an oscillator of some sort. Then use on-off keying by switching the carrier frequency on when the datasignal is low, and switching the carrier frequency off when the datasignal is high. You can probably achieve this by modifying the source of the softwareserial library.

Unfortunately I don't have any examples for you since my implementations have been on the PIC16F153xx series of microcontrollers using dedicated peripherals.

Everybody thanks for all those awesome answers.

I am thinking that for me it would be too much of a hassle to tweak the code of the library.

On the other hand, if you are using a PWM peripheral (like the one of my first image), can't you just hook it up to the hardware serial as is?

I am not sure 100% but if you drive low its input it is going to switch the carrier frequency on, right? Then it is "just serial" as usual.

FYI I found a "dirty solution" for this ;D ;D:

https://forum.arduino.cc/index.php?topic=14748.msg108390#msg108390

I will try it.

Hello all,

Last update, I am extremely happy, after many hours of frustrations it worked!!

I managed to transmit strings from my Arduino Leonardo to a Raspberry Pi Zero with Node-red.

On the Leonardo I connected an IR led with a resistor to pins 9 and 1 (anode + goes to pin 9, cathode - goes to TX pin). On pin 9 I applied the tone function and pin 1 is just the TX of the UART.

The code is extremely simple (it does not mean I got it at the first attempt :sweat_smile:):

//TX function.

void setup() {
    Serial1.begin(4800); 
    tone(9, 38400); Create on pin 9 the carrier frequency 38,4KHz
}

void loop() {
    Serial1.print("hola");
    delay(250);
}

On the raspberry pi I connected the receiver and with Node-Red had to open a serial in node (very very important is to split the input correctly otherwise you won't get the messages).

As a side note, I have to say that this IR receiver TSDP34138 works flawlessly (apparently according to the datasheet its purpose is serial comms). I could point the led backwards against the wall from under the table and still could get by reflection 99% of the messages without gibberish.

On the contrary I also tried a VS1838B and as soon as I turned the LED from its line of sight it started with random messages before being interrupted completely.

I want to thank you all again and I hope this post will be useful for the next to come.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.