Compile error with ATTINY85

I am getting the following error when i am compiling the code by selecting the board as attiny85, and if i compile the same code by selecting board as arduino nano ,i am getting no error. please help
code:

 #include <IRremote.h>

IRrecv irrecv(0);
decode_results results;

int lig1 = 1;
int lig2 = 2;
int lig3 = 3;
int lig4 = 4;

int flag1 = 0;
int flag2 = 0;
int flag3 = 0;
int flag4 = 0;

unsigned int value; 

void setup() {
  irrecv.enableIRIn();
  
  pinMode(lig1, OUTPUT);
  pinMode(lig2, OUTPUT);
  pinMode(lig3, OUTPUT);
  pinMode(lig4, OUTPUT);
  
  
}

void loop() {
  if (irrecv.decode(&results)) { 
    value = results.value;
    irrecv.resume();

   
    
    
    if (results.value == 0x1FE50AF) {flag1 = !flag1; digitalWrite(lig1, flag1 ? HIGH : LOW); value =0; }
    if (results.value == 0x1FED827) {flag2 = !flag2; digitalWrite(lig2, flag2 ? HIGH : LOW); value =0; }
    if (results.value == 0x1FEF807) {flag3 = !flag3; digitalWrite(lig3, flag3 ? HIGH : LOW); value =0; }
    if (results.value == 0x1FE30CF) {flag4 = !flag4; digitalWrite(lig4, flag4 ? HIGH : LOW); value =0; }
    if (results.value == 0x1FE48B7)
    {digitalWrite(lig1 , LOW);
    digitalWrite(lig2, LOW);
    digitalWrite(lig3 , LOW);
    digitalWrite(lig4 , LOW);
    
    }    
  }    }

Error :

 In file included from 
C:\Users\Kamal\Documents\Arduino\libraries\IRremote\src/IRremote.h:197:0,
                 from C:\Users\Kamal\Desktop\IR_home_automation_code\IR_home_automation_code.ino:1:
C:\Users\Kamal\Documents\Arduino\libraries\IRremote\src/IRReceive.hpp: In member function 'bool IRrecv::decode(decode_results*)':
C:\Users\Kamal\Documents\Arduino\libraries\IRremote\src/IRReceive.hpp:1410:9: error: 'Serial' was not declared in this scope
         Serial.println(
         ^~~~~~
C:\Users\Kamal\Documents\Arduino\libraries\IRremote\src/IRReceive.hpp:1410:9: note: suggested alternative: 'Stream'
         Serial.println(
         ^~~~~~
         Stream
exit status 1
Error compiling for board ATtiny25/45/85.

PLEASE HELP
I am using attiny board manager by David A.Mellis version 1.0.2

Please read the forum guide.

Your topic subject line should be short but describe your problem or project

Your description of the problem should be in the body of your post.

Your code should be posted inside code tags.

Your error messages should be posted inside code tags. Thankyou for posting them in full.

Knowing that, please edit your post above and correct it.

What Attiny core or board package are you using? Other forum members will need to know that in order to reproduce your error.

Sir,I am using attiny board manager by David A.Mellis version 1.0.2

Thanks for fixing your post!

I would suggest changing to use this core/board package.

EDIT: the IRemote library recommends the core I mentioned above:

Supported Boards
Digispark boards are tested with the recommended ATTinyCore using New Style pin mapping for the pro board.

I think the IRemote library documentation should be changed to say that it requires the SpenceKonde library, not simply to recommend it. Otherwise users of other cores will not be able to compile it, as you have found. The library code uses Serial.println(), which is not available on all Attiny cores/board packages.

Serial.println commands are not supported by ATtiny. However the library did not consider this so you can consider it a bug. To solve it or make it work for you, you would have to modify the library files to comment out Serial.println. You would have to edit 3 files namely
IRReceive.cpp.h
ir_Denon.cpp
ir_LG.cpp

in your case located at C:\Users\Kamal\Documents\Arduino\libraries\IRremote\src\

in IRReceive.cpp.h

//        Serial.println(
//                "The function decode(&results)) is deprecated and may not work as expected! Just use decode() without a parameter and IrReceiver.decodedIRData.<fieldname> .");

in ir_Denon.cpp

//    Serial.println(
//            "The function sendDenon(data, nbits) is deprecated and may not work as expected! Use sendDenonRaw(data, NumberOfRepeats) or better sendDenon(Address, Command, NumberOfRepeats).");

in ir_LG.cpp

//    Serial.println(
//            "The function sendLG(data, nbits) is deprecated and may not work as expected! Use sendLGRaw(data, NumberOfRepeats) or better sendLG(Address, Command, NumberOfRepeats).");

They are, if I the core/board package suggested by the library documentation is used. I agree this is a problem with the library, which could be corrected either with a code change or a documentation change (to require an Attiny core which does support Serial.println()).

Let's see if changing the core fixes the problem, before changing the library code.

Now I understand.

The suggestion was to change the board manager other than David A.Mellis version 1.0.2

This core can be installed using the boards manager. The boards manager URL is:

`http://drazzy.com/package_drazzy.com_index.json`

1. File->Preferences on a PC, or Arduino->Preferences on a Mac, enter the above URL in "Additional Boards Manager URLs
2. Tools -> Boards -> Boards Manager...
  *If using 1.6.6, close boards manager and re-open it (see below)
3. Select "ATTinyCore by Spence Konde" and click "Install".

So I tried this using ATtiny85 (Micronucleus / DigiSpark). However got this warning/error

`data section exceeds available space in boardSketch uses 4692 bytes (71%) of program storage space. Maximum is 6586 bytes.

Global variables use 531 bytes (103%) of dynamic memory, leaving -19 bytes for local variables. Maximum is 512 bytes.
Not enough memory; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing your footprint.
Error compiling for board ATtiny85 (Micronucleus / DigiSpark).
`

So I think just modify the programs in the library. Its quick and dirty but it works.

Upon double checking the files that have to be updated are
ac_LG.cpp
IRReceive.hpp
ir_Denon.cpp
ir_DistanceProtocol.cpp
ir_LG.cpp

for ac_LG.cpp

//#define INFO // Deactivate this to save program space and suppress info output.

and

	/* 
    Serial.println();
    Serial.println();
    Serial.println(F("Type command and optional parameter without a separator"));
    Serial.println(F("0 Off"));
    Serial.println(F("1 On"));
    Serial.println(F("s Swing <0 or 1>"));
    Serial.println(F("a Auto clean <0 or 1>"));
    Serial.println(F("j Jet on"));
    Serial.println(F("e Energy saving <0 or 1>"));
    Serial.println(F("l Lights toggle"));
    Serial.println(F("f Fan speed <0 to 2 or 3 for cycle>"));
    Serial.println(F("t Temperature <18 to 30> degree"));
    Serial.println(F("+ Temperature + 1"));
    Serial.println(F("- Temperature - 1"));
    Serial.println(F("m <c(ool) or a(uto) or d(ehumidifying) or h(eating) or f(an) mode>"));
    Serial.println(F("S Sleep after <0 to 420> minutes"));
    Serial.println(F("T Timer on after <0 to 1439> minutes"));
    Serial.println(F("O Timer off after <0 to 1439> minutes"));
    Serial.println(F("C Clear all timer and sleep"));
    Serial.println(F("e.g. \"s1\" or \"t23\" or \"mc\" or \"O60\" or \"+\""));
    Serial.println(F("No plausibility check is made!"));
    Serial.println();
	*/

For ir_DistanceProtocol.cpp

//#define INFO // Deactivate this to save program space and suppress info output.

For IRReceive.hpp

//        Serial.println(
//                "The function decode(&results)) is deprecated and may not work as expected! Just use decode() without a parameter and IrReceiver.decodedIRData.<fieldname> .");

yes ,finally i made the changes and i compiled the program .There were no errors. But this code is working on my arduino nano but when i upload it in attiny85, it is uploading successfully but it is not responding to my ir remote.can you help me out please.

i changed the core but still there were errors.After modifying the libraries it got compiled without errors

i forgot to keep the capacitor while uploading.THanks a lot.Its working.Thanks to gerivega SIR and PaulRB SIR

1 Like