Hello everyone, new programmer here, I hv a probleme with IRsend command interfering with dht temp reading,
I want to set a delay to IR transmitter to turn off/on AC unit, and since the unit have a buzzer, everytime it turns off or on it makes this annoying sound, so i decided to set the IRsend command once every 10minutes, allowing the temperature to increase or decrease.
The problem is that this delay interfere with th DHT temp reading, so the reading restart only once the 10 min delay is over.
I'm sure one of you guys know how to set delay to IRtransmitter without interfering with DHT readings.
PS: I dont want to have to remove the buzzer from the unit.
I dont want the the IR to keep sending commands, it may damage the AC unit programmer, plus it will keep draigning the batterie.
Here is the code:
#include <IRLibSendBase.h> //We need the base code
#include <IRLib_HashRaw.h> //Only use raw sender
#include <dht.h>
#define dht_apin A0 // Analog Pin sensor is connected to
dht DHT;
IRsendRaw mySender;
void setup() {
Serial.begin(115200);
delay(2000);
while (!Serial); //delay for Leonardo
Serial.println(F("DHT11 Humidity & temperature Sensor\n\n"));
}
/* Cut and paste the output from "rawRecv.ino" below here. It will
* consist of a #define RAW_DATA_LEN statement and an array definition
* beginning with "uint16_t rawData[RAW_DATA_LEN]= {…" and concludes
* with "…,1000};"
*/
#define RAW_DATA_LEN 230
uint16_t rawDataOff[RAW_DATA_LEN]={
3086, 290, 30, 1354, 546, 1006, 546, 1010,
546, 318, 546, 274, 590, 318, 546, 1010,
546, 318, 546, 322, 546, 1010, 546, 1006,
550, 262, 598, 1010, 546, 314, 550, 314,
550, 1006, 546, 1014, 546, 318, 546, 1006,
550, 1006, 546, 226, 638, 318, 546, 1010,
546, 318, 546, 322, 546, 1010, 546, 318,
546, 318, 550, 318, 546, 318, 546, 318,
546, 318, 546, 326, 546, 318, 546, 318,
550, 318, 546, 318, 546, 318, 546, 318,
546, 318, 550, 326, 546, 318, 546, 318,
546, 318, 546, 318, 546, 318, 546, 1010,
546, 318, 546, 322, 550, 1006, 546, 1006,
550, 318, 546, 318, 522, 342, 522, 342,
522, 342, 526, 346, 546, 1006, 522, 1034,
522, 342, 518, 1034, 522, 346, 518, 346,
518, 346, 518, 354, 518, 346, 518, 1034,
522, 342, 522, 346, 518, 346, 518, 346,
518, 346, 522, 350, 522, 346, 518, 346,
518, 346, 518, 346, 518, 350, 514, 370,
498, 366, 498, 374, 498, 370, 494, 374,
490, 374, 490, 374, 490, 378, 486, 378,
486, 378, 486, 386, 486, 378, 486, 378,
486, 382, 486, 378, 486, 378, 486, 402,
462, 382, 486, 406, 466, 402, 462, 402,
462, 402, 486, 378, 486, 382, 486, 378,
478, 386, 486, 382, 490, 1066, 486, 378,
486, 1070, 486, 378, 486, 378, 486, 378,
486, 1066, 490, 378, 490, 1000};
#define RAW_DATA_LEN 228
uint16_t rawDataOn[RAW_DATA_LEN]={
3086, 1702, 522, 1034, 518, 1034, 518, 362,
498, 366, 498, 362, 498, 1038, 518, 366,
498, 350, 518, 1034, 518, 1034, 518, 342,
514, 1038, 518, 350, 502, 358, 494, 1062,
494, 1066, 518, 342, 518, 1034, 518, 1038,
494, 370, 494, 366, 490, 1066, 490, 374,
494, 378, 490, 1058, 494, 370, 490, 374,
490, 370, 494, 370, 494, 370, 490, 374,
490, 378, 490, 374, 490, 374, 490, 370,
490, 374, 494, 370, 490, 374, 490, 370,
490, 382, 490, 378, 490, 370, 490, 1086,
470, 374, 490, 374, 490, 1086, 466, 378,
486, 406, 466, 1082, 466, 1086, 466, 398,
462, 402, 462, 402, 462, 402, 462, 398,
462, 410, 462, 1090, 462, 1094, 462, 402,
458, 1094, 462, 402, 462, 406, 458, 398,
462, 410, 470, 394, 462, 1094, 478, 382,
486, 378, 486, 378, 482, 382, 474, 386,
486, 386, 486, 378, 486, 382, 486, 378,
486, 374, 486, 382, 482, 378, 486, 378,
486, 382, 486, 378, 486, 378, 486, 374,
486, 382, 482, 378, 486, 378, 462, 402,
470, 402, 458, 406, 462, 402, 462, 402,
462, 402, 458, 406, 462, 398, 462, 406,
458, 410, 458, 402, 462, 402, 462, 422,
438, 430, 438, 422, 438, 426, 438, 426,
438, 430, 438, 1118, 438, 426, 438, 422,
438, 1118, 438, 426, 438, 426, 434, 1122,
434, 434, 434, 1000};
/*
* Cut-and-paste into the area above.
*/
void loop() {
DHT.read11(dht_apin);
int temp = DHT.temperature;
{Serial.print(F("temperature = "));
Serial.print(temp);
Serial.println(F(" C"));
delay(2000);
}
if (temp > 27) {
mySender.send(rawDataOn,RAW_DATA_LEN,36);//Pass the buffer,length, optionally frequency
Serial.println(F("AC Switched On"));
if (rawDataOn,RAW_DATA_LEN,36) {
delay (10000);
}
}
else if (temp < 24) {
mySender.send(rawDataOff,RAW_DATA_LEN,36);//Pass the buffer,length, optionally frequency
Serial.println(F("AC Switched Off"));
if (rawDataOn,RAW_DATA_LEN,36) {
delay (10000);
}
}
}