crankyoldgit / IRremoteESP8266

Infrared remote library for ESP8266/ESP32: send and receive infrared signals with multiple protocols. Based on: https://github.com/shirriff/Arduino-IRremote/
GNU Lesser General Public License v2.1
2.98k stars 832 forks source link

Fujitsu A/C Remote AR-REB1E #573

Closed sidwin9 closed 5 years ago

sidwin9 commented 5 years ago

Is there a hope to have an evolution to integrate the code of the remote control AR-REB1E for Futjisu air conditioner?

crankyoldgit commented 5 years ago

See the FAQ item on this general topic area.: https://github.com/markszabo/IRremoteESP8266/wiki/Frequently-Asked-Questions#The_libraryexample_code_doesnt_understand_my_Air_Conditioner_remote_

With out someone with a remote (i.e. you) doing the leg work of collecting samples and doing some analysis or pointing to existing working code elsewhere, it isn't going to happen.

It's a lot of effort from all parties. i.e. See #509

As we do have some Fujitsu A/C code implemented, it may be an easier task depending on your results.

sidwin9 commented 5 years ago

Hello, Here is a code for Arduino that works for an AR-RBE1 remote controlDespite an adaptation attempt for ESP8266 it does not work. The code contains all the information on the frames emitted by the remote control. Thanks for your help.

include

include

include "nRF24L01.h"

include "RF24.h"

include "printf.h"

include "IRremote.h"

define WORD_TEMP 9

define WORD_MODE 10

define WORD_FAN 11

define WORD_CHECKSUM 16

define MODE_AUTO 0

define MODE_COOL 1

define MODE_DRY 2

define MODE_FAN 3

define MODE_HEAT 4

define FAN_AUTO 0

define FAN_HIGH 1

define FAN_MEDIUM 2

define FAN_LOW 3

define FAN_QUIET 4

define FIRST_SPACE 3200

define FIRST_MARK 1600

define ONE_IN_MS 1183

define ZERO_IN_MS 350

define SPACE_IN_MS 445

//---------------

IRsend irsend; unsigned char currentTemp; unsigned char currentMode; unsigned char currentFan;

unsigned char mode; unsigned char temp; unsigned char fan;

unsigned char trame[16] = {0x28, 0xc6, 0x0, 0x8, 0x8, 0x7f, 0x90, 0xc, 0x7, 0x20, 0x40, 0x0, 0x0, 0x0, 0x4, 0x53}; unsigned char trameOFF[7] = {0x28, 0xc6, 0x00, 0x08, 0x08, 0x40, 0xbf};

unsigned int times[259] = {FIRST_SPACE, FIRST_MARK, SPACE_IN_MS}; //259 = 16 words (8 bytes + 8 spaces) + first space + first mark + 1 space in ms unsigned int timesOFF[115] = {FIRST_SPACE, FIRST_MARK, SPACE_IN_MS}; // 115 = 7 words (8 bytes + 8 spaces) + first space + first mark + 1 space in ms

uint32_t timer;

// Radio Hardware configuration // Set up nRF24L01 radio on SPI bus plus pins 9 & 10

RF24 radio(9,10);

// Radio pipe addresses for the 2 nodes to communicate. const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2 //Temperature chip i/o OneWire ds(DS18S20_Pin); // on digital pin 2

unsigned long timerTempCheck = 0; unsigned int roomTemp;

void setup() {

pinMode(13, OUTPUT);
Serial.begin(9600);

printf_begin(); printf("\n\r INIT \n\r");

// Setup and configure rf radio

radio.begin();

// optionally, increase the delay between retries & # of retries radio.setRetries(20,50);

radio.setPayloadSize(sizeof(unsigned int));

radio.openWritingPipe(pipes[1]); radio.openReadingPipe(1,pipes[0]);

radio.startListening();

radio.printDetails();

}

//// //// //*****//

void loop(void) {

// obtenir la température ambiante toutes les 35 secondes if (millis() > timer) { timer = millis() + 35000; roomTemp = getTemp(); }

// s'il y a des données prêtes if ( radio.available() ) { // Décharger les charges jusqu'à ce que nous ayons tout obtenu unsigned int dataCommand; bool done = false; while (!done) { // Récupérez la charge utile et voyez si c'était la dernière. done = radio.read( &dataCommand, sizeof(unsigned int) );

  // Spew le
  printf("Got payload %i...",dataCommand);

  // Retardez juste un peu pour laisser l'autre unité
  // faire la transition au récepteur
  delay(30);     

  // Tout d’abord, arrêtez d’écouter pour pouvoir parler
  radio.stopListening();

  switch(dataCommand){
    case 0:
        sendOff();
        Serial.println("Received OFF command");
    break;

    case 9999:
        //Serial.println("Ask for temp");
        radio.write(&roomTemp, sizeof(unsigned int) );
    break;

    default:

        radio.write(&dataCommand, sizeof(unsigned int) );

        Serial.println("default command");
        mode = dataCommand / 1000;
        temp = (dataCommand / 10) % (mode*100);
        fan = dataCommand - ((mode * 1000) + (temp * 10));

        Serial.println(dataCommand);
        Serial.println("Mode:");
        Serial.println(mode);
        Serial.println("Temp:");
        Serial.println(temp);
        Serial.println("Fan:");
        Serial.println(fan); 

        setMode(mode);
        setTemp(temp);
        setFan(fan);
        check();
        checksum();
        trameToTime();
        sendIR();

    break;
   }
}

// Maintenant, reprenez l’écoute pour attraper les prochains paquets.
radio.startListening();

}

if(timerTempCheck < millis()){

roomTemp = getTemp();
timerTempCheck = millis() + (1000 * 10);
    Serial.println("Room Temp:");
    Serial.println(roomTemp);

} }

void sendOff(){

unsigned char mask; unsigned char value;
int i,j; unsigned int index=3;

for(i=0; i<7; i++){ mask = 0x80; //10000000 for(j=0; j<8; j++){

  value = trameOFF[i];

  if(value & mask){
    timesOFF[index++] = ONE_IN_MS;
  }else{
    timesOFF[index++] = ZERO_IN_MS;
  }
  timesOFF[index++] = SPACE_IN_MS;
  mask = mask >> 1;
}

}

irsend.sendRaw(timesOFF,115,38); //38khz

}

void sendCommand(unsigned char mode, unsigned char temp, unsigned char fan){

}

void sendIR(){ irsend.sendRaw(times,259,38); //38khz }

void setFan(unsigned char value) { if(!(value == FAN_AUTO || value == FAN_HIGH || value == FAN_MEDIUM || value == FAN_LOW || value == FAN_QUIET)) { Serial.println("Error setFan: unknown value"); return;
}

currentFan = value;

value = Bit_Reverse(value); trame[WORD_FAN-1] = value;

}

void setMode(unsigned char value) { if(!(value == MODE_AUTO || value == MODE_COOL || value == MODE_DRY || value == MODE_FAN || value == MODE_HEAT)) { Serial.println("Error setMode: unknown value"); return;
}

currentMode = value;

value = Bit_Reverse(value); trame[WORD_MODE-1] = value; }

void setTemp(unsigned char value) {

if(value<60 || value>88){ Serial.println("Error setTemp: Temp not in range (60 to 88)"); return; }

if ( (value & 0x01) != 0) { Serial.println("Error setTemp: Temp value must be even"); return; }

currentTemp = value;

//60F = 0 61F = 1 ... 88F = 14 value = (value - 60)/2;

value = value << 4; value = value & 0xFF; value = Bit_Reverse(value);

value = value | 0x80; //mettre le premier bit à 1 pour toujours POWER ON

trame[WORD_TEMP-1] = value;

}

char checksum(){

int sum = 0; char value;

for(int i=8; i<=15; i++){ char value = trame[i-1]; value = Bit_Reverse(value); sum+=value; }

value = sum % 0xFF; value = 0X100 - sum; value = Bit_Reverse(value);

trame[WORD_CHECKSUM-1] = value;

}

void check(){

if(currentMode == MODE_DRY && currentFan != FAN_AUTO){ setFan(FAN_AUTO); }

}

void trameToTime() {

unsigned char mask; unsigned char value;
int i,j; unsigned int index=3;

check();

for(i=0; i<16; i++){ mask = 0x80; //10000000 for(j=0; j<8; j++){

  value = trame[i];

  if(value & mask){
    times[index++] = ONE_IN_MS;
  }else{
    times[index++] = ZERO_IN_MS;
  }
  times[index++] = SPACE_IN_MS;
  mask = mask >> 1;
}

}

}

// Inverser l'ordre des bits dans un octet. // I.e. MSB est échangé avec LSB, etc. unsigned char Bit_Reverse( unsigned char x ) { x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); return x;
}

float getTemp(){ //returns the temperature from one DS18S20 in DEG Celsius

//j'ai enlevé le code pour que ca ne soit pas trop long

}

sidwin9 commented 5 years ago

Hello,

Cancel my last post, your library works for an AR-RBE1E remote control for Fujitsu A / C, I used in my circuit an NPN 2222 transistor for my IR LED.

Thanks for your help.

crankyoldgit commented 5 years ago

Okay. Closing this issue as it seems resolved now.