Issues with the IR Library

Hey Guys,

I'm working on a project with IR and I'm trying to use a pretty extensive, current IR library. It can be found here:
GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols
When I attempt to load an example (I'm still trying to learn the library) I get the following error message:

"Arduino: 1.6.3 (Mac OS X), Board: "Arduino Uno"

Using library Robot IR Remote in folder: /Applications/Arduino.app/Contents/Java/libraries/RobotIRremote 

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Applications/Arduino.app/Contents/Java/libraries/RobotIRremote/src /var/folders/s0/47hcgqc92wl7099m_857kqs40000gn/T/build5578383771192718155.tmp/IRrecord.cpp -o /var/folders/s0/47hcgqc92wl7099m_857kqs40000gn/T/build5578383771192718155.tmp/IRrecord.cpp.o 
IRrecord.ino:25:1: error: 'IRsend' does not name a type
IRrecord.ino: In function 'void sendCode(int)':
IRrecord.ino:103:7: error: 'irsend' was not declared in this scope
IRrecord.ino:107:7: error: 'irsend' was not declared in this scope
IRrecord.ino:113:5: error: 'irsend' was not declared in this scope
IRrecord.ino:128:7: error: 'irsend' was not declared in this scope
IRrecord.ino:131:7: error: 'irsend' was not declared in this scope
IRrecord.ino:138:5: error: 'irsend' was not declared in this scope
Multiple libraries were found for "IRremote.h"
 Used: /Applications/Arduino.app/Contents/Java/libraries/RobotIRremote
 Not used: /Users/Andrew/Documents/Arduino/libraries/Arduino-IRremote-master
Error compiling.

So I realized that there was a conflict with two libraries called by the same name, in different directories. I removed the library from the .app directory, leaving the library I want to use in the /documents/arduino/libraries/IRRemote directory. Now, I get the following error message:

 Arduino: 1.6.3 (Mac OS X), Board: "Arduino Uno"

Using library IRremote in folder: /Users/Andrew/Documents/Arduino/libraries/Arduino-IRremote-master 

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/Andrew/Documents/Arduino/libraries/Arduino-IRremote-master /var/folders/s0/47hcgqc92wl7099m_857kqs40000gn/T/build8084166764060973196.tmp/IRrecord.cpp -o /var/folders/s0/47hcgqc92wl7099m_857kqs40000gn/T/build8084166764060973196.tmp/IRrecord.cpp.o 
IRrecord.ino: In function 'void sendCode(int)':
IRrecord.ino:103:14: error: 'class IRsend' has no member named 'sendNEC'
IRrecord.ino:107:14: error: 'class IRsend' has no member named 'sendNEC'
IRrecord.ino:113:12: error: 'class IRsend' has no member named 'sendSony'
IRrecord.ino:128:14: error: 'class IRsend' has no member named 'sendRC5'
IRrecord.ino:131:14: error: 'class IRsend' has no member named 'sendRC6'
Error compiling.

It's a current library, with its most recent update 7 days ago. Anyone have any idea what these errors reference?

Thanks
Andy

Shameless self-bump...

It says you're either calling functions or referencing members that don't exist in that library.

Post your code.

MonorailOrange:
Shameless self-bump...

Posting the code that is giving you problems is a whole lot more likely to garner responses than bumping a thread that is less than an hour old.

Seems like deja vu.

If the library is installed in the correct place and you have restarted the IDE, maybe show us your code.
Attach the sketch useing the <> icon in the posting menu.

Also what happens if you use the 1.06 IDE.

My apologies. It's a demo code inside the referenced library page from github. I had intended to indicate that I would post the code if requested.

/*
 * IRrecord: record and play back IR signals as a minimal 
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * An IR LED must be connected to the output PWM pin 3.
 * A button must be connected to the input BUTTON_PIN; this is the
 * send button.
 * A visible LED can be connected to STATUS_PIN to provide status.
 *
 * The logic is:
 * If the button is pressed, send the IR code.
 * If an IR code is received, record it.
 *
 * Version 0.11 September, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

int RECV_PIN = 11;
int BUTTON_PIN = 12;
int STATUS_PIN = 13;

IRrecv irrecv(RECV_PIN);
IRsend irsend;

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(BUTTON_PIN, INPUT);
  pinMode(STATUS_PIN, OUTPUT);
}

// Storage for the recorded code
int codeType = -1; // The type of code
unsigned long codeValue; // The code value if not raw
unsigned int rawCodes[RAWBUF]; // The durations if raw
int codeLen; // The length of the code
int toggle = 0; // The RC5/6 toggle state

// Stores the code for later playback
// Most of this code is just logging
void storeCode(decode_results *results) {
  codeType = results->decode_type;
  int count = results->rawlen;
  if (codeType == UNKNOWN) {
    Serial.println("Received unknown code, saving as raw");
    codeLen = results->rawlen - 1;
    // To store raw codes:
    // Drop first value (gap)
    // Convert from ticks to microseconds
    // Tweak marks shorter, and spaces longer to cancel out IR receiver distortion
    for (int i = 1; i <= codeLen; i++) {
      if (i % 2) {
        // Mark
        rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS;
        Serial.print(" m");
      } 
      else {
        // Space
        rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS;
        Serial.print(" s");
      }
      Serial.print(rawCodes[i - 1], DEC);
    }
    Serial.println("");
  }
  else {
    if (codeType == NEC) {
      Serial.print("Received NEC: ");
      if (results->value == REPEAT) {
        // Don't record a NEC repeat value as that's useless.
        Serial.println("repeat; ignoring.");
        return;
      }
    } 
    else if (codeType == SONY) {
      Serial.print("Received SONY: ");
    } 
    else if (codeType == RC5) {
      Serial.print("Received RC5: ");
    } 
    else if (codeType == RC6) {
      Serial.print("Received RC6: ");
    } 
    else {
      Serial.print("Unexpected codeType ");
      Serial.print(codeType, DEC);
      Serial.println("");
    }
    Serial.println(results->value, HEX);
    codeValue = results->value;
    codeLen = results->bits;
  }
}

void sendCode(int repeat) {
  if (codeType == NEC) {
    if (repeat) {
      irsend.sendNEC(REPEAT, codeLen);
      Serial.println("Sent NEC repeat");
    } 
    else {
      irsend.sendNEC(codeValue, codeLen);
      Serial.print("Sent NEC ");
      Serial.println(codeValue, HEX);
    }
  } 
  else if (codeType == SONY) {
    irsend.sendSony(codeValue, codeLen);
    Serial.print("Sent Sony ");
    Serial.println(codeValue, HEX);
  } 
  else if (codeType == RC5 || codeType == RC6) {
    if (!repeat) {
      // Flip the toggle bit for a new button press
      toggle = 1 - toggle;
    }
    // Put the toggle bit into the code to send
    codeValue = codeValue & ~(1 << (codeLen - 1));
    codeValue = codeValue | (toggle << (codeLen - 1));
    if (codeType == RC5) {
      Serial.print("Sent RC5 ");
      Serial.println(codeValue, HEX);
      irsend.sendRC5(codeValue, codeLen);
    } 
    else {
      irsend.sendRC6(codeValue, codeLen);
      Serial.print("Sent RC6 ");
      Serial.println(codeValue, HEX);
    }
  } 
  else if (codeType == UNKNOWN /* i.e. raw */) {
    // Assume 38 KHz
    irsend.sendRaw(rawCodes, codeLen, 38);
    Serial.println("Sent raw");
  }
}

int lastButtonState;

void loop() {
  // If button pressed, send the code.
  int buttonState = digitalRead(BUTTON_PIN);
  if (lastButtonState == HIGH && buttonState == LOW) {
    Serial.println("Released");
    irrecv.enableIRIn(); // Re-enable receiver
  }

  if (buttonState) {
    Serial.println("Pressed, sending");
    digitalWrite(STATUS_PIN, HIGH);
    sendCode(lastButtonState == buttonState);
    digitalWrite(STATUS_PIN, LOW);
    delay(50); // Wait a bit between retransmissions
  } 
  else if (irrecv.decode(&results)) {
    digitalWrite(STATUS_PIN, HIGH);
    storeCode(&results);
    irrecv.resume(); // resume receiver
    digitalWrite(STATUS_PIN, LOW);
  }
  lastButtonState = buttonState;
}

This is the IRrecord.pde from the library file.

MonorailOrange:
I had intended to indicate that I would post the code if requested.

If you want help with a piece of code, nobody should have to ask you to show it to them. It should be pretty obvious that nobody can tell what's wrong with it without being able to see it.

Delta_G:
If you want help with a piece of code, nobody should have to ask you to show it to them. It should be pretty obvious that nobody can tell what's wrong with it without being able to see it.

Understood. However, considering it was indicated as a piece of stock code from the library source, and said source was available, I was worried it would be seen as redundant.

All of those functions are in ifdef blocks.

#ifdef SEND_NEC
void IRsend::sendNEC(unsigned long data, int nbits)
{
  enableIROut(38);
  mark(NEC_HDR_MARK);
  space(NEC_HDR_SPACE);
  for (int i = 0; i < nbits; i++) {
    if (data & TOPBIT) {
      mark(NEC_BIT_MARK);
      space(NEC_ONE_SPACE);
    } 
    else {
      mark(NEC_BIT_MARK);
      space(NEC_ZERO_SPACE);
    }
    data <<= 1;
  }
  mark(NEC_BIT_MARK);
  space(0);
}
#endif

But they don't match with the #defines in the .h file

#define IRsendNEC
#define IRsendSONY
#define IRsendRC5
#define IRsendRC6
#define IRsendDISH
#define IRsendSHARP
#define IRsendPANASONIC
#define IRsendJVC
#define IRsendSANYO
#define IRsendMITSUBISHI
#define IRsendSAMSUNG
#define IRsendRAW

I don't know why it's written that way, but those #ifdef are keeping any of those functions from ever being compiled. Ergo they don't exist.

Delta_G:
All of those functions are in ifdef blocks.

#ifdef SEND_NEC

void IRsend::sendNEC(unsigned long data, int nbits)
{
  enableIROut(38);
  mark(NEC_HDR_MARK);
  space(NEC_HDR_SPACE);
  for (int i = 0; i < nbits; i++) {
    if (data & TOPBIT) {
      mark(NEC_BIT_MARK);
      space(NEC_ONE_SPACE);
    }
    else {
      mark(NEC_BIT_MARK);
      space(NEC_ZERO_SPACE);
    }
    data <<= 1;
  }
  mark(NEC_BIT_MARK);
  space(0);
}
#endif




But they don't match with the #defines in the .h file



#define IRsendNEC
#define IRsendSONY
#define IRsendRC5
#define IRsendRC6
#define IRsendDISH
#define IRsendSHARP
#define IRsendPANASONIC
#define IRsendJVC
#define IRsendSANYO
#define IRsendMITSUBISHI
#define IRsendSAMSUNG
#define IRsendRAW





I don't know why it's written that way, but those #ifdef are keeping any of those functions from ever being compiled. Ergo they don't exist.

Thank you for your help. I didn't even see the #ifdef issue when I was looking through. Sorry for the confusion earlier on.

I believe there is a new group active providing support & updates in the IRremote Github.
They introduced the "defines' as a way to reduce SRAM usage of the library.

They seem pretty active & responsive, if you want to post any issues via Github.

From your log:

Using library Robot IR Remote in folder: /Applications/Arduino.app/Contents/Java/libraries/RobotIRremote

There's a naming conflict between a couple of different IRRemote libraries, and it looks like the IDE is pulling code from the wrong one for your application. If you don't have an Arduino Robot, try deleting the RobotIRRemote directory.
(or renaming the shirriff library and the files it contains.)
(IIRC, this has come up a couple of times before...)

Hi guys,
I have a problem.... I would like to control AC with my arduino.
I was able to do all good for an LG brand aircon but now I would like to do the same for a different brand AC (HAIER brand) and I found an issue...

The problem is that HAIER has a command string array long 229, much more than 56 of LG brand.
I need to store 3 commands (ON-OFF-FAN) and I run out of memory.

I tried to store those variables using PROGMEM but then when I need to use it with the

irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz);

I got the error:

invalid conversion from 'const unsigned int*' to 'unsigned int*' [-fpermissive]

The IR library want to have INT not CONST INT....

somebody has a clue ??
this is my code:

//Libreria Ir
#include <IRremote.h>
IRsend irsend;

//Libreria NFC Pn532 board
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>
#define PN532_SS (10)
// Use this line for a breakout with a hardware SPI connection. Note that
// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
Adafruit_PN532 nfc(PN532_SS);

//Relay controllo luci
#define RELAY_PIN 4

//Reed controllo porta
const int DoorSwitch = 7; //Pin Reed

//Controllo Temperatura ambiente

int tempPin = A0;
float tempC;

//Libreria Timer
#include "Timer.h"
Timer timer;

//Variabili di stato:
float mintemp = 20.0; //Temperatura minima da settare
int RelaycommandON = 0;
int RelaycommandOFF = 0;
int StatoSwitch = 0; //Stato switch luci HIGH/LOW
#define interval 45000 //Intervallo di tempo per mandare AcFan
long previousMills = 0; //Memorizza l'ultima volta che il led è stato aggiornato

void setup()
{
Serial.begin(115200);
pinMode(RELAY_PIN, OUTPUT); // initialize the digital pin as an output.
pinMode(DoorSwitch, INPUT);
analogReference(INTERNAL);
delay(100);
nfc.begin();

uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print(F("Didn't find PN53x board"));
while (1); // halt
}
nfc.SAMConfig();
Serial.println("Waiting for an ISO14443A Card ...");
}

void loop() {

uint8_t success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 1000); //success indica la presenza di un Tag

if (success) { //se presente un Tag
uint32_t cardid = uid[0];
cardid <<= 8;
cardid |= uid[1];
cardid <<= 8;
cardid |= uid[2];
cardid <<= 8;
cardid |= uid[3];
Serial.print(F(" Card # "));
Serial.println(cardid);

if (cardid == 2871234277 || cardid == 1357089509) //controllo identificativo Tag
{
if (RelaycommandON == 0){ //controllo di non aver gia' madato ON
timer.after(5000, sendAcCommandOn); //Mando solo 1 volta AC ON di cortesia
relayOn(); // turn the relay on (HIGH is the voltage level) Accendo le luci
RelaycommandON = 1; //imposto stato gia' mandato segnale on
RelaycommandOFF = 0; // imposto comando OFF non ancora inviato
}
checkDoor(); //controllo lo stato della porta

if (StatoSwitch == HIGH){ //se la porta e' chiusa:
checkTemperature(); //controllo la temperatura ambiente
if(tempC<mintemp){ //
sendAcCommandOn();
delay(60000);
}
previousMills = millis(); //azzero il timer della porta aperta
}
}
delay(1000);
}
else{ //altrimenti se non e' presente Tag :
if (RelaycommandOFF == 0){ // se non ho gia mandato il comando Off:
timer.after(30000, relayOff); // dopo 30 secondi spengo la luce
timer.every(5000, sendAcCommandOff, 2); //mando ogni 5 secondi x 3 volte Ac Off
RelaycommandON = 0; //imposto stato non ancora mandato segnale ON
RelaycommandOFF = 1; //imposto come gia' mandato seganle OFF per non ripetere continuamente il comando
delay(1000);
}
}
timer.update(); //updato il timer ad ogni giro
}

// ========= FINE LOOP ============= //

void sendAcCommandOn(){
int khz = 38; // 38kHz carrier frequency for the NEC protocol
Serial.println(F("+AC ON+"));

unsigned int irSignal [] = {8850,4150, 500,1600, 500,500, 500,500, 550,500, 500,1550, 550,500, 500,550, 500,500, 500,550, 500,550, 500,500, 500,550, 500,550, 500,550, 500,500, 500,550, 500,1550, 500,1550, 500,550, 500,1550, 500,550, 500,1550, 500,550, 500,500, 500,550, 500,500, 500,550, 500,1550, 500}; //AnalysIR Batch Export (IRremote) - RAW
irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.

}

void sendAcCommandOff(){
int khz = 38; // 38kHz carrier frequency for the NEC protocol
Serial.println(F("++AC OFF++"));
unsigned int irSignalon[] = {8800,4100, 550,1550, 500,550, 500,500, 500,550, 500,1550, 500,550, 500,500, 500,550, 500,1550, 500,1550, 550,500, 500,550, 500,500, 500,550, 500,500, 550,500, 500,550, 500,550, 500,500, 500,550, 500,550, 500,1550, 500,500, 550,1550, 500,500, 550,500, 500,550, 500,1550, 500};
irsend.sendRaw(irSignalon, sizeof(irSignalon) / sizeof(irSignalon[0]), khz);
}

void sendAcCommandFan(){
int khz = 38; // 38kHz carrier frequency for the NEC protocol
Serial.println(F("++AC FAN ON++"));
unsigned int irSignal[] = {8800,4100, 550,1500, 550,500, 550,500, 500,550, 500,1550, 600,400, 550,500, 550,500, 500,550, 500,550, 500,500, 500,550, 500,1550, 550,500, 500,1550, 500,550, 500,500, 550,500, 500,1550, 500,1550, 500,500, 550,550, 500,1500, 550,500, 500,1550, 550,1550, 500,1550, 500,1550, 500};
irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz);
}

void relayOff(){
Serial.println(F("++RELAY OFF++"));
digitalWrite(RELAY_PIN, LOW);
}

void relayOn(){
Serial.println(F("++RELAY ON++"));
digitalWrite(RELAY_PIN, HIGH);
}

bool checkTemperature(){
float tempC;
int reading;
reading = analogRead(tempPin);
tempC = reading / 9.31;
Serial.println(tempC);
delay(1000);
}

bool checkDoor(){
StatoSwitch = digitalRead(DoorSwitch); //Leggo il valore del Reed
if (StatoSwitch == HIGH){
Serial.println(F(" Door Closed "));
}
else{
Serial.println(F(" Door Open "));
if (millis() - previousMills > interval ){
previousMills = millis(); //Tiene in memoria l'ultimo invio AcFan
sendAcCommandFan();
}

}
}