红外接收 LG 逆变器控制代码并用红外发射器发送

时间:2021-01-13 17:30:27

标签: arduino arduino-uno esp32 infrared arduino-c++

我正在尝试从我的 LG 逆变器多分离式控制器和红外接收器获取命令。我希望能够使用 IR 发射器创建一个项目来打开、关闭、升温/降温、摆动等逆变器。我正在使用 IrRemote 库:https://github.com/Arduino-IRremote/Arduino-IRremote 以及 IRreceiveDemo 和 IRsend 来接收和发送数据。
我正在努力处理从接收草图接收的数据以及插入数据的位置我收到了。

我目前正在通过打开和关闭按钮(同一个按钮)获取这些数据:


Protocol=LG Address=0x88 Command=0x88C Raw-Data=0x88C0051 (28 bits)

Protocol=LG Address=0x88 Command=0x880 Raw-Data=0x880059E (28 bits)

Protocol=LG Address=0x88 Command=0x88C Raw-Data=0x88C0051 (28 bits)

为什么我从同一个按钮(提高音量和打开/关闭)获取两个原始数据

我应该在 sAddress 中插入 Rawd-Data 吗?:

// Some protocols have 5, some 8 and some 16 bit Address
uint16_t sAddress = 0x880059E;
uint8_t sCommand = 0x28;
uint8_t sRepeats = 0;

这是发送的完整代码:

#include <IRremote.h>
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)
#include "ATtinySerialOut.h"
#endif

IRsend IrSender;

// On the Zero and others we switch explicitly to SerialUSB
#if defined(ARDUINO_ARCH_SAMD)
#define Serial SerialUSB
#endif

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);

    Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
    delay(2000); // To be able to connect Serial monitor after reset and before first printout
#endif
    // Just to know which program is running on my Arduino
    Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
    Serial.print(F("Ready to send IR signals at pin "));
    Serial.println(IR_SEND_PIN);
    Serial.println(F("Send with standard protocol encoders"));
}

// Some protocols have 5, some 8 and some 16 bit Address
uint16_t sAddress = 0x0102;
uint8_t sCommand = 0x34;
uint8_t sRepeats = 0;

void loop() {
    /*
     * Print values
     */
    Serial.println();
    Serial.print(F("address=0x"));
    Serial.print(sAddress, HEX);
    Serial.print(F(" command=0x"));
    Serial.print(sCommand, HEX);
    Serial.print(F(" repeats="));
    Serial.print(sRepeats);
    Serial.println();

    Serial.println(F("Send NEC with 8 bit address"));
    IrSender.sendNECStandard(sAddress, sCommand, false, sRepeats);
    delay(2000);

    Serial.println(F("Send NEC with 16 bit address"));
    IrSender.sendNECStandard(sAddress, sCommand, true, sRepeats);
    delay(2000);

    Serial.println(F("Send Panasonic"));
    IrSender.sendPanasonicStandard(sAddress, sCommand, sRepeats);
    delay(2000);

    Serial.println(F("Send Kaseikyo with 0x4711 as Vendor ID"));
    IrSender.sendKaseikyoStandard(sAddress, sCommand, 0x4711, sRepeats);
    delay(2000);

    Serial.println(F("Send Denon"));
    IrSender.sendDenonStandard(sAddress, sCommand, false, sRepeats);
    delay(2000);

    Serial.println(F("Send Denon/Sharp variant"));
    IrSender.sendSharpStandard(sAddress, sCommand, sRepeats);
    delay(2000);

    Serial.println(F("Send Sony/SIRCS with 7 command and 5 address bits"));
    IrSender.sendSonyStandard(sAddress, sCommand, false, sRepeats);
    delay(2000);

    Serial.println(F("Send Sony/SIRCS with 7 command and 13 address bits"));
    IrSender.sendSonyStandard(sAddress, sCommand, true, sRepeats);
    delay(2000);

    Serial.println(F("Send Samsung"));
    IrSender.sendSamsungStandard(sAddress, sCommand, sRepeats);
    delay(2000);

    Serial.println(F("Send JVC"));
    IrSender.sendJVCStandard(sAddress, sCommand, sRepeats);
    delay(2000);

    Serial.println(F("Send LG"));
    IrSender.sendLGStandard(sAddress, sCommand, sRepeats);
    delay(2000);

    Serial.println(F("Send Bosewave with 8 command bits"));
    IrSender.sendBoseWaveStandard(sCommand, sRepeats);
    delay(2000);

    /*
     * !!LEGO is difficult to receive because of its short marks and spaces!!!
     */
    Serial.println(F("Send Lego with 2 channel and with 4 command bits"));
    IrSender.sendLegoPowerFunctions(sAddress, LEGO_MODE_COMBO, sCommand, true);
    delay(2000);

    /*
     * Increment values
     */
    sAddress += 0x0101;
    sCommand += 0x11;
    sRepeats++;
    // clip repeats at 3
    if (sRepeats > 3) {
        sRepeats = 3;
    }

    delay(5000); //  second additional delay between each values
}

开启命令会起作用,但关闭、摆动、温度不会有任何影响。

0 个答案:

没有答案