0

I have a led receiver KY-022 and led emitter KY-005, I also have a PL2303 (USB-TTL). This is the code of the issuing LED:

#include <IRremote.h>
IRsend irsend;

void setup()
{
 Serial.begin(9600);
}

void loop() 
{
   for (int i = 0; i < 50; i++) { 
     irsend.sendSony(0xa90, 12); // Sony TV power code
     //Serial.print(0xa90,HEX);
     delay(40);
   }
}

The following is the connection scheme: enter image description here

The output of the KY-022 I have connected to the pin RXD of the PL2303 which has a led that indicates that it receives data, however when using the HyperTerminal program to see the data I receive nothing appears.

I found similar information but they use another LED model, however I think it should work the same. What can I do?

I'm also testing with node js using the node js package, but in the console I only get non-readable characters, or something like this Buffer 00 e0 e0 e0 e0 if I do not apply toString () to the data.

This is my code in node JS.

var SerialPort = require('serialport');
var io = require('socket.io').listen(3000);

var serialPort = new SerialPort("COM9", {
    baudRate: 9600,
    parser: new SerialPort.parsers.Readline("\n")
});

io.sockets.on('connection', function(socket){
    socket.on('message', function(msg){
        console.log(msg);
    });

    socket.on('disconnected', function(){
        console.log('disconnected');
    });
});

var clearData = "";
var readData = "";

serialPort.on('open',function(){
    console.log('open');
    serialPort.on('data', function(data){
        console.log(data);
        readData += data.toString();
        io.sockets.emit('message',data);
    });
});
  • please post the code that you are using for receiving the IR data – jsotola May 20 '18 at 3:23
  • I have no code for the KY-022, it is directly connected to PL2303. I only have the node code js with which I read what enters the RX pin. – FrEqDe May 20 '18 at 3:34
  • You don't have much of a clue about how IR communication works, do you? IR != serial. You need something between the receiver and your computer that decodes the incoming IR signal and converts it into something more meaningful. At the moment you're pointing a TV remote control at a fish and expecting it to bark. – Majenko May 20 '18 at 9:52
3

You are transmitting data by encoding it using one of probably many Sony Consumer Remote Control formats and expecting to decode it using one of many possible RS232 like formats. You will likely get something between nothing and random values.

Instead, consider sending data using only the RS232 protocols. This is what is done in this tutorial. It is recommended you replicate the tutorial before moving on to using a TTL to USB dongle and a computer. This should validate the transmitter is working. Note in the tutorial transmitter code example no IR remote control library is used. Only the common serial libraries.

A word regarding the tutorial. Consider using the second of the two examples in the tutorial. The first does not modulate the IR transmitter and will not work with commonly available IR receivers. The second does modulate the IR transmitter and discusses how to alter the modulation to accommodate different IR receivers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.