Control with IR my Thermopump


I am new in arduino but I’ve already sucessfully make work test project using IR such as reading the code of my samsung tv remote with
or command my tv using an ir led.
So I tried the next level for me which is: command my thermopump using IR. I have a fan I can command with a remote (YAN1F1F model).
Using the same sensor I can read code from the remote: according to IRremote lib it is a nec protocol and according to IRLib it is unknown.

Also the lib give me different reading results.
In one library, it seems there are 2 code sent by the remote and 2nd code is FFFFFFFF (repeat code if I understand well). But with the otherone it can be 2 codes such :
3259160A then 32591606 or
3259160A and FFFFFFFF then 32591606 and FFFFFFFF

I tried to send these code using my IR led but it is not working. I tried different code I found on the net but my fan does not seem to receive the code.
I check the ir led with a camera and it is blinink the the code is sent.

Finally i tried the following code which is supposed to record the raw code when I press a button and send it in a loop. So I record the remote in one room then I bring my arduino in the other room so it can send the signal. But it is still not working.

/* Example program for from IRLib - an Arduino library for infrared encoding and decoding
 * Version 1.5  June 2014
 * Copyright 2014 by Chris Young
 * Based on original example sketch for IRremote library 
 * Version 0.11 September, 2009
 * Copyright 2009 Ken Shirriff
 * IRrecord: record and play back IR signals 
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * An IR LED must be connected to the appropriate pin.(See IRLibTimer.h) for your 
 * machine's timers and erupts.
 * Record a value by pointing your remote at the device then send any character
 * from the serial monitor to send the recorded value.
 * Also demonstrates how to use toggle bits which must be controlled outside
 * the library routines.
 * The logic is:
 * If an IR code is received, record it.
 * If a serial character is received, send the IR code.

#include <IRLib.h>

int RECV_PIN = 11;

IRrecv My_Receiver(RECV_PIN);
IRdecode My_Decoder;
IRsend My_Sender;
 * Because this version of the library separated the receiver from the decoder,
 * technically you would not need to "store" the code outside the decoder object
 * for this overly simple example. All of the details would remain in the object.
 * However we are going to go ahead and store them just to show you how.
// Storage for the recorded code
IRTYPES codeType;          // The type of code
unsigned long codeValue;   // The data bits if type is not raw
int codeBits;              // The length of the code in bits

// These values are only stored if it's an unknown type and we are going to use
// raw codes to resend the information.
unsigned int rawCodes[RAWBUF]; // The durations if raw
int rawCount;                   //The number of interval samples

bool GotOne, GotNew; 

void setup()
  GotOne=false; GotNew=false;
  delay(2000);while(!Serial);//delay for Leonardo
  Serial.println(F("Send a code from your remote and we will record it."));
  Serial.println(F("Type any character and press enter. We will send the recorded code."));
  My_Receiver.enableIRIn(); // Start the receiver

// Stores the code for later playback
void storeCode(void) {
  codeType = My_Decoder.decode_type;
  if (codeType == UNKNOWN) {
    Serial.println("Received unknown code, saving as raw");
    // To store raw codes:
    // Drop first value (gap)
    // As of v1.3 of IRLib global values are already in microseconds rather than ticks
    // They have also been adjusted for overreporting/underreporting of marks and spaces
    rawCount = My_Decoder.rawlen-1;
    for (int i = 1; i <=rawCount; i++) {
      rawCodes[i - 1] = My_Decoder.rawbuf[i];
  else {
    Serial.print(F("Received "));
    if (My_Decoder.value == REPEAT) {
      // Don't record a NEC repeat value as that's useless.
      Serial.println(F("repeat; ignoring."));
     else {
       codeValue = My_Decoder.value;
       codeBits = My_Decoder.bits;
     Serial.print(F(" Value:0x"));
     Serial.println(My_Decoder.value, HEX);
void sendCode(int repeat) {
  if(codeType== UNKNOWN) {
    // Assume 38 KHz
    Serial.println(F("Sent raw"));
  if( !GotNew ) {//We've already sent this so handle toggle bits
    if (codeType == RC5) {
      codeValue ^= 0x0800;
    else if (codeType == RC6) {
      codeValue ^= 0x10000;
  Serial.print(F("Sent "));
  Serial.print(F(" Value:0x"));
  Serial.println(codeValue, HEX);

void loop() {
//  if ( != -1) {
    if(GotOne) {
      My_Receiver.enableIRIn(); // Re-enable receiver
//  } 
  else if (My_Receiver.GetResults(&My_Decoder)) {

If anyone has an idea to help me or tell me what I am missing.


If you have an existing remote you could look at it's transmitted codes witha phototransistor and a scope..

or get the protocol from somewhere




I did not find anything about the protocol of the remote :( What can I do with a phototransistor and a scope about the transmitted code ? The phototransistor is it the same as an Ir receiver that I am using TSOP4838 or is it something else ?

Thanks for your help

connect the scope to the photo transistor or diode, point the remote at it ( very close) and capture the waveform.

It'll be a series of 38-ish kHz pulses representing 0's and 1's.

Compare that with the pulses your arduino-based IR transmitter sends . How are they different?

Then figure how can you get the arduino to send the same pulse sequence...



The IRremote library is very reliable. You can use a second Arduino to verify that the first one sends the requested code.