Open tripleaarnold opened 3 years ago
HI,
I used the ESP8266 for this and of course you then need ot install the IRremoteESP8266 package. Please give me more information on what processor you are using and what environment e.g. Arduino IDE or Platform IO
Tobie
I am using an esp 32 and Arduino IDE. The issue is copping this code directly to the ide with all dependant libraries already installed it still gives an error message saying No matching function for call to 'IRsend:sendRaw(unsigned Int*&, int, int&)' I reside in Africa and was trying to automate my DStv remote control tho not explora . I just wanted to me able to send it's raw data as captured cos I can't seem to decode it's protocol . Pls advice me
Post your code pls
/*
#include <ESP8266WiFi.h>
#include <WiFi.h>
uint16_t RECV_PIN = 14; //Pin you wish receive IR on IRrecv irrecv(RECV_PIN);
decode_results results;
const uint16_t kIrLed = 2 ; //Pin you wish to send IR on IRsend irsend(kIrLed);
bool tvPowerState; unsigned int tvVolume; unsigned int tvChannel; bool tvMuted;
// channelNames used to convert channelNumber into channelName // please put in your TV channel names // channel numbers starts counting from 0 (Netflix is 0 in example below)! // For channel names, this can be trial and error as amazon are yet to explicitedly publish the supported channels. The following is a list supported on Fire Tv, i would imagine that these should work: https://developer.amazon.com/docs/video-skills-fire-tv-apps/channels-list.html const char* channelNames[] = { "netflix vic", //(Alexa only reconises Netflix written like this, i believe its a Virgin Media thing. However saying "Change channel to Netflix on TV" works fine) "BBC 1", "BBC 2", "ITV", "channel 4", "dave", "bbc four", "", "rtl", "RTL II", "SUPER RTL", "KiKA" };
// map channelNumbers used to convert channelName into channelNumber // This map is initialized in "setupChannelNumbers()" function by using the "channelNames" array std::map<String, unsigned int> channelNumbers;
void setupChannelNumbers() { for (unsigned int i=0; i < MAX_CHANNELS; i++) { channelNumbers[channelNames[i]] = i; } }
// TV device callbacks
bool onAdjustVolume(const String &deviceId, int &volumeDelta, bool volumeDefault) { if (volumeDelta > 0) {irsend.sendNEC(0xFD22DD, 32);irsend.sendNEC(0xFD22DD, 32);irsend.sendNEC(0xFD22DD, 32);irsend.sendNEC(0xFD22DD, 32);irsend.sendNEC(0xFD22DD, 32);} //Insert IR for Volume Up here. if (volumeDelta < 0) {irsend.sendNEC(0xFDC23D, 32);irsend.sendNEC(0xFDC23D, 32);irsend.sendNEC(0xFDC23D, 32);irsend.sendNEC(0xFDC23D, 32);irsend.sendNEC(0xFDC23D, 32);} //Insert IR for Volume Down here. tvVolume += volumeDelta; // calcualte new absolute volume Serial.printf("Volume changed about %i to %i\r\n", volumeDelta, tvVolume); volumeDelta = tvVolume; // return new absolute volume return true; }
bool onChangeChannel(const String &deviceId, String &channel) { tvChannel = channelNumbers[channel]; // save new channelNumber in tvChannel variable Serial.printf("Change channel blah to \"%s\" (channel number %d)\r\n", channel.c_str(), tvChannel); if (channel == "BBC 2") {irsend.sendNEC(0XFD807F, 32); delay (250); irsend.sendNEC(0xFD00FF, 32); delay (250); irsend.sendNEC(0xFD40BF, 32);} //Change IR sequence inside of {} for each channel. if (channel == "BBC 1") {irsend.sendNEC(0XFD807F, 32); delay (250); irsend.sendNEC(0xFD00FF, 32); delay (250); irsend.sendNEC(0XFD807F, 32);} if (channel == "netflix vic") {irsend.sendNEC(0xFDE21D, 32); delay (10000); irsend.sendNEC(0xFDA857, 32); delay (500); irsend.sendNEC(0xFD15EA, 32);}
return true; }
bool onChangeChannelNumber(const String& deviceId, int channelNumber, String& channelName) { tvChannel = channelNumber; // update tvChannel to new channel number
if (tvChannel < 0) tvChannel = 0; if (tvChannel > MAX_CHANNELS-1) tvChannel = MAX_CHANNELS-1;
delay(250);
channelName = channelNames[tvChannel]; // return the channelName
Serial.printf("Change to channel to %d (channel name \"%s\")\r\n", tvChannel, channelName.c_str());
return true; }
bool onMediaControl(const String &deviceId, String &control) {
Serial.printf("MediaControl: %s\r\n", control.c_str()); //Change and/or insert IR code inbetween {}
if (control == "Play") {irsend.sendNEC(0xFD15EA, 32);}
if (control == "Pause") {irsend.sendNEC(0xFD956A, 32);}
if (control == "Stop") {irsend.sendNEC(0xFD5AA5, 32);}
if (control == "StartOver") {irsend.sendNEC(0xFD5AA5, 32); irsend.sendNEC(0xFD15EA, 32);}
if (control == "Previous") {}
if (control == "Next") {}
if (control == "Rewind") {irsend.sendNEC(0xFD1AE5, 32);}
if (control == "FastForward") {irsend.sendNEC(0xFD9A65, 32);}
return true;
}
bool onMute(const String &deviceId, bool &mute) { if(deviceId=="TV_ID"){
Serial.printf("TV volume is %s\r\n", mute?"muted":"unmuted"); tvMuted = mute; // set tvMuted state if(mute){
irsend.sendNEC(0xFD18E7, 32); //Insert Mute button IR for Mute
}
else{
irsend.sendNEC(0xFD708F, 32); //Insert Mute button IR for unmute (Normally the same as above)
}
} else if(deviceId==TV_ID_2){ Serial.printf("TV volume is %s\r\n", mute?"muted":"unmuted"); tvMuted = mute; // set tvMuted state if(mute){
irsend.sendSony(0x140A, 15); //Insert Mute button IR for Mute
}
else{
irsend.sendSony(0x140A, 15); //Insert Mute button IR for unmute (Normally the same as above)
}
}
return true; }
bool onPowerState(const String &deviceId, bool &state) { irrecv.enableIRIn();
if(deviceId==TV_ID){ Serial.printf("TV turned %s\r\n", state?"on":"off"); tvPowerState = state; if(state){
irsend.sendSony(0x540A, 15); //Power On IR
}
else{
irsend.sendSony(0x540A, 15); //Power Off IR
}// set powerState
}
else if(deviceId==TV_ID_2){ Serial.printf("TV turned %s\r\n", state?"on":"off"); tvPowerState = state; if(state){
irsend.sendNEC(0xFDB04F, 32); //Power On IR
}
else{
irsend.sendNEC(0xFDB04F, 32); //Power Off IR
}// set powerState
} return true; }
bool onSelectInput(const String &deviceId, String &input) {
Serial.printf("Input changed to %s\r\n", input.c_str()); if (input = "HDMI 1") {irsend.sendNEC(0xFD48B7, 32); delay (250); irsend.sendNEC(0xFD18E7, 32); delay (250); irsend.sendNEC(0xFDA857, 32);} //Set your IR sequence to change Input on TV
return true; }
bool onSetVolume(const String &deviceId, int &volume) { Serial.printf("Volume set to: %i\r\n", volume); tvVolume = volume; // update tvVolume return true; }
bool onSkipChannels(const String &deviceId, const int channelCount, String &channelName) { tvChannel += channelCount; // calculate new channel number if (tvChannel < 0) tvChannel = 0; if (tvChannel > MAX_CHANNELS-1) tvChannel = MAX_CHANNELS-1; channelName = String(channelNames[tvChannel]); // return channel name
Serial.printf("Skip channel: %i (number: %i / name: \"%s\")\r\n", channelCount, tvChannel, channelName.c_str());
return true; }
// setup function for WiFi connection void setupWiFi() { irsend.begin();
Serial.printf("\r\n[Wifi]: Connecting"); WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) { Serial.printf("."); delay(250); } IPAddress localIP = WiFi.localIP(); Serial.printf("connected!\r\n[WiFi]: IP-Address is %d.%d.%d.%d\r\n", localIP[0], localIP[1], localIP[2], localIP[3]); irrecv.enableIRIn(); }
void dump(decode_results *results) { // Dumps out the decode_results structure. // Call this after IRrecv::decode() uint16_t count = results->rawlen; if (results->decode_type == UNKNOWN) { Serial.print("Unknown encoding: "); } else if (results->decode_type == NEC) { Serial.print("Decoded NEC: "); } else if (results->decode_type == SONY) { Serial.print("Decoded SONY: "); } else if (results->decode_type == RC5) { Serial.print("Decoded RC5: "); } else if (results->decode_type == RC5X) { Serial.print("Decoded RC5X: "); } else if (results->decode_type == RC6) { Serial.print("Decoded RC6: "); } else if (results->decode_type == RCMM) { Serial.print("Decoded RCMM: "); } else if (results->decode_type == PANASONIC) { Serial.print("Decoded PANASONIC - Address: "); Serial.print(results->address, HEX); Serial.print(" Value: "); } else if (results->decode_type == LG) { Serial.print("Decoded LG: "); } else if (results->decode_type == JVC) { Serial.print("Decoded JVC: "); } else if (results->decode_type == AIWA_RC_T501) { Serial.print("Decoded AIWA RC T501: "); } else if (results->decode_type == WHYNTER) { Serial.print("Decoded Whynter: "); } else if (results->decode_type == NIKAI) { Serial.print("Decoded Nikai: "); } serialPrintUint64(results->value, 16); Serial.print(" ("); Serial.print(results->bits, DEC); Serial.println(" bits)"); Serial.print("Raw ("); Serial.print(count, DEC); Serial.print("): {");
for (uint16_t i = 1; i < count; i++) { if (i % 100 == 0) yield(); // Preemptive yield every 100th entry to feed the WDT. if (i & 1) { Serial.print(results->rawbuf[i] kRawTick, DEC); } else { Serial.print(", "); Serial.print((uint32_t) results->rawbuf[i] kRawTick, DEC); } } Serial.println("};"); }
// setup function for SinricPro void setupSinricPro() { // add device to SinricPro SinricProTV& myTV = SinricPro[TV_ID]; SinricProTV& myTV2 = SinricPro[TV_ID_2]; //add second device
// set callback functions to device myTV.onAdjustVolume(onAdjustVolume); myTV.onChangeChannel(onChangeChannel); myTV.onChangeChannelNumber(onChangeChannelNumber); myTV.onMediaControl(onMediaControl); myTV.onMute(onMute); myTV.onPowerState(onPowerState); myTV.onSelectInput(onSelectInput); myTV.onSetVolume(onSetVolume); myTV.onSkipChannels(onSkipChannels);
myTV2.onPowerState(onPowerState); //Specify what Second Device Functions you'd like myTV2.onMute(onMute); myTV2.onAdjustVolume(onAdjustVolume);
// setup SinricPro SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); }); SinricPro.begin(APP_KEY, APP_SECRET); }
// main setup function void setup() { Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n"); Serial.printf("%d channels configured\r\n", MAX_CHANNELS);
irrecv.enableIRIn();
setupWiFi(); setupSinricPro(); setupChannelNumbers(); }
void loop() { SinricPro.handle(); if (irrecv.decode(&results)) { dump(&results); Serial.println("DEPRECATED: Please use IRrecvDumpV2.ino instead!"); irrecv.resume(); // Receive the next value } }
I am looking to integrate your code into this. But downloading your code and compiling it without changing anything gives the error I stated above
I see i made this note at the time
//pio lib install 1089 - Wont Compile - download directly from github
also see this post https://forum.arduino.cc/t/irsend-does-not-name-a-type/292030
and this one https://github.com/arduino/Arduino/issues/6071
i think it is a matter of depenancies clashing. I remember I had to install the lib directly into the folder and not download cia package manager. but it was so long a ago
Ok , thanks sir for finding time to reply me. Am grateful
i tried duplicating this project but get this error everytime i compile . pls help