Once again I need Your guidance.
I've tried to operate hood by 433 MHz transmitter and everything Works fine with this Code (it Just sends Command every second):
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
// Transmitter is connected to Arduino Pin #10
mySwitch.enableTransmit(10);
// Optional set pulse length.
mySwitch.setPulseLength(400);
// set protocol (default is 1, will work for most outlets)
mySwitch.setProtocol(11);
// Optional set number of transmission repetitions.
//mySwitch.setRepeatTransmit(20);
pinMode(13,OUTPUT);
}
void loop() {
mySwitch.send("0111111110111011");
Serial.println("LIGHT: ON");
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(1000);
mySwitch.send("0111111100111011");
Serial.println("VENTILATION: 1");
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(1000);
mySwitch.send("0111111010111011");
Serial.println("VENTILATION: 2");
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(1000);
mySwitch.send("0111111000111011");
Serial.println("VENTILATION: 3");
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(1000);
mySwitch.send("0111110110111011");
Serial.println("VENTILATION: 4");
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(1000);
mySwitch.send("0111111110111011");
Serial.println("VENTILATION: OFF");
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(1000);
mySwitch.send("0111111111111011");
Serial.println("LIGHT: OFF");
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(1000);
}
Next thing should be easy, Just modify my Code to send the RF Command instead of relay pulse after receiving IR Signal from hob:
#include <IRremote.h>
#include <RCSwitch.h>
/*
IR commands from hob device
VENTILATION SPEED 1 = 0xE3C01BE2;
VENTILATION SPEED 2 = 0xD051C301;
VENTILATION SPEED 3 = 0xC22FFFD7;
VENTILATION SPEED 4 = 0xB9121B29;
VENTILATION OFF = 0x55303A3;
LIGHT ON = 0xE208293C;
LIGHT OFF = 0x24ACF947;
RF Commands to hood device:
VENT: OFF
Decimal: 32763 (16Bit)
Binary: 0111111110111011
Tri-State: not applicable
PulseLength: 395 microseconds
Protocol: 11
Raw data: 14220,560,92,624,664,304,664,304,664,304,664,304,668,300,668,300,668,300,668,300,280,36,272,64,48,164,144,704,252,76,224,144,136,
VENT: 1
Decimal: 32635 (16Bit)
Binary: 0111111100111011
Tri-State: not applicable
PulseLength: 392 microseconds
Protocol: 11
Raw data: 14228,556,92,624,668,304,660,308,660,304,664,304,476,68,488,16,200,468,36,360,428,92,152,16,160,304,44,288,244,116,200,172,76,
VENT: 2
Decimal: 32507 (16Bit)
Binary: 0111111010111011
Tri-State: not applicable
PulseLength: 395 microseconds
Protocol: 11
Raw data: 14224,312,336,28,568,28,424,16,1080,52,92,456,52,112,484,52,188,568,40,492,72,140,1028,44,248,884,140,644,108,124,56,20,436,
VENT: 3
Decimal: 32379 (16Bit)
Binary: 0111111000111011
Tri-State: not applicable
PulseLength: 395 microseconds
Protocol: 11
Raw data: 14224,312,340,624,2088,56,576,112,176,244,96,96,36,68,216,108,20,432,16,184,420,96,180,36,84,232,40,16,48,28,204,108,732,
VENT : 4
Decimal: 32251 (16Bit)
Binary: 0111110110111011
Tri-State: not applicable
PulseLength: 395 microseconds
Protocol: 11
Raw data: 14224,312,340,48,228,32,480,24,20,240,32,40,16,56,164,148,408,108,44,552,80,16,52,28,896,120,904,268,32,664,68,28,264,
LIGHT: ON
Decimal: 32187 (16Bit)
Binary: 0111111110111011
Tri-State: not applicable
PulseLength: 395 microseconds
Protocol: 11
Raw data: 14228,556,92,628,660,308,664,308,660,312,656,304,668,304,344,616,668,300,672,296,352,616,672,296,672,296,672,296,352,44,16,24,40,
LIGHT: OFF
Decimal: 32251 (16Bit)
Binary: 0111111111111011
Tri-State: not applicable
PulseLength: 395 microseconds
Protocol: 11
Raw data: 14224,556,92,628,660,308,664,308,664,304,660,304,664,308,344,620,668,300,668,296,668,128,196,124,252,700,136,124,244,32,224,264,56,
*/
// IR Receiver PIN
const int PIN_IR_RECEIVER = 2;
RCSwitch mySwitch = RCSwitch();
IRrecv irrecv(PIN_IR_RECEIVER); // create instance of 'irrecv'
decode_results results;
void setup() {
Serial.begin(9600);
Serial.println("Hob2Hood ready ...");
mySwitch.enableTransmit(10);
mySwitch.setPulseLength(400);
mySwitch.setProtocol(11);
mySwitch.setRepeatTransmit(15);
pinMode(13, OUTPUT);
irrecv.enableIRIn();
}
void loop() {
// have we received an IR signal?
if (irrecv.decode(&results)) {
Serial.println("Received IR command: ");
Serial.println(results.value, HEX); // display it on serial monitor in hexadecimal
switch (results.value) {
case 0xE208293C:
mySwitch.send("0111111110111011");
Serial.println("SEND RF: LIGHT ON");
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(1000);
break;
case 0x24ACF947:
mySwitch.send("0111111111111011");
Serial.println("SEND RF: LIGHT OFF");
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(1000);
break;
case 0xE3C01BE2:
mySwitch.send("0111111100111011");
Serial.println("SEND RF: VENTILATION 1");
digitalWrite(13,HIGH);
digitalWrite(13,LOW);
break;
case 0xD051C301:
mySwitch.send("0111111010111011");
Serial.println("SEND RF: VENTILATION 2");
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(1000);
break;
case 0xC22FFFD7:
mySwitch.send("0111111000111011");
Serial.println("SEND RF: VENTILATION 3");
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(1000);
break;
case 0xB9121B29:
mySwitch.send("0111110110111011");
Serial.println("SEND RF: VENTILATION 4");
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(1000);
break;
case 0x55303A3:
mySwitch.send("0111111110111011");
Serial.println("SEND RF: VENTILATION OFF");
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(1000);
break;
}
irrecv.resume(); // receive the next value
}
}
BUT
suddenly the hood is not reacting to the RF COMMANDS and I have no idea why. I've Just copied them from previous, working Code.
With previous Code where Arduino is sending commands every 1 second, it works for 100%.
Please advice me.