Inviare più di 3 raw IR codes

Salve a tutti, sto realizzando un progettino (app android + BT → arduino → IR trasmission).
Nella fattispecie, riesco già a comandare i televisori di casa. Passando ai condizionatori, ho notato tramite IRrecvdump che la mia codifica è una RAW.
Ho il seguente sketch:

#include <IRremote.h>

String readString;
IRsend irsend;



unsigned int on[]={8900,4400,650,1600,650,1650,600,500,650,550,650,500,600,550,600,500,650,1650,650,500,650,1550,700,1600,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,1600,650,550,600,550,600,500,650,500,650,550,600,550,600,1650,600,500,650,550,650,500,650,500,600,550,600,1650,650,500,650,500,650,500,600,550,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,600};

unsigned int condsuper[]={9100,4250,800,1450,700,1550,750,400,750,450,750,350,800,350,750,400,650,1600,700,500,750,1450,750,1550,750,400,650,500,800,350,750,350,750,450,800,1450,650,500,800,350,750,400,700,450,800,350,750,400,750,400,800,350,750,1500,650,500,800,350,750,400,650,500,800,350,750,400,650,500,800,350,800,350,750,450,750,400,750,350,700,450,650,550,750,350,750,400,650,500,750,400,750,1550,750,350,750,400,700,1550,700};
unsigned int condalt[]={9000,4400,650,1650,600,1650,600,500,650,550,650,500,650,500,600,550,600,1650,650,500,650,1600,650,1600,650,500,650,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,550,600,1650,600,500,600,600,650,500,600,550,600,550,600,550,650,500,650,500,600,550,600,550,600,550,650,500,650,500,600,550,650,500,650,500,650,500,650,500,650,500,650,500,600,550,600,550,600};
unsigned int condmed[]={9000,4400,650,1650,600,1600,650,500,650,550,650,500,650,500,600,550,600,1650,650,500,650,1600,650,1550,700,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,550,600,1600,650,500,650,550,650,1550,700,500,600,1650,600,550,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650};
unsigned int condbas[]={8950,4450,650,1600,650,1600,650,450,700,500,650,500,650,500,650,500,650,1600,650,500,650,1600,650,1600,650,550,600,550,600,500,650,500,650,500,700,500,600,550,600,500,650,550,650,450,700,500,600,550,600,550,650,500,650,1600,650,500,600,550,650,500,650,500,650,500,650,1600,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,500,650,500,650,500,650,500,650};




unsigned int riscalt[]={9000,4450,650,1550,700,1600,650,500,600,550,650,500,650,500,650,500,650,1600,650,500,650,1600,650,1600,650,550,600,500,650,500,650,500,650,550,600,550,600,500,650,500,650,550,650,500,600,550,600,550,600,550,650,500,650,500,600,550,600,550,650,500,650,1600,650,1600,650,1600,650,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,550,600,500,650,500,650,500,650};



void setup()
{
  Serial.begin(9600);
}

void loop(){

  while (Serial.available()){
  delay(3);
  char c = Serial.read();
  readString +=c;
  }
  
  if (readString.length() >0){
    Serial.println(readString);
  
   
      /*AC*/
      /*DE LONGHI*/
      
      if (readString == "DELONGHIon")
      {
          irsend.sendRaw(on,sizeof(on)/sizeof(int),38);
           delay(50);
      }    
    
    if (readString == "DELONGHIcondsuper")
      {

        irsend.sendRaw(condsuper,sizeof(condsuper)/sizeof(int),38);
           delay(50);
    }
    
   if (readString == "DELONGHIcondalta")
      {

        irsend.sendRaw(condalt,sizeof(condalt)/sizeof(int),38);
           delay(50);
    }
    
    if (readString == "DELONGHIcondmedia")
      {
        
        irsend.sendRaw(condmed,sizeof(condmed)/sizeof(int),38);
           delay(50);
    }
    
    if (readString == "DELONGHIcondbassa")
      {
       
        irsend.sendRaw(condbas,sizeof(condbas)/sizeof(int),38);
           delay(50);
    }
    
    
    
    
    
    
    if (readString == "DELONGHIriscalta")
      {
                        

       irsend.sendRaw(riscalt,sizeof(riscalt)/sizeof(int),38);
           delay(50);
    }
      
      
      
      
      readString="";
  }
}

Purtroppo non funziona. Se invece carico su arduino il seguente:

#include <IRremote.h>

String readString;
IRsend irsend;



unsigned int on[]={8900,4400,650,1600,650,1650,600,500,650,550,650,500,600,550,600,500,650,1650,650,500,650,1550,700,1600,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,1600,650,550,600,550,600,500,650,500,650,550,600,550,600,1650,600,500,650,550,650,500,650,500,600,550,600,1650,650,500,650,500,650,500,600,550,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,600};

unsigned int condsuper[]={9100,4250,800,1450,700,1550,750,400,750,450,750,350,800,350,750,400,650,1600,700,500,750,1450,750,1550,750,400,650,500,800,350,750,350,750,450,800,1450,650,500,800,350,750,400,700,450,800,350,750,400,750,400,800,350,750,1500,650,500,800,350,750,400,650,500,800,350,750,400,650,500,800,350,800,350,750,450,750,400,750,350,700,450,650,550,750,350,750,400,650,500,750,400,750,1550,750,350,750,400,700,1550,700};

unsigned int riscalt[]={9000,4450,650,1550,700,1600,650,500,600,550,650,500,650,500,650,500,650,1600,650,500,650,1600,650,1600,650,550,600,500,650,500,650,500,650,550,600,550,600,500,650,500,650,550,650,500,600,550,600,550,600,550,650,500,650,500,600,550,600,550,650,500,650,1600,650,1600,650,1600,650,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,550,600,500,650,500,650,500,650};



void setup()
{
  Serial.begin(9600);
}

void loop(){

  while (Serial.available()){
  delay(3);
  char c = Serial.read();
  readString +=c;
  }
  
  if (readString.length() >0){
    Serial.println(readString);
  
     
      /*AC*/
      /*DE LONGHI*/
      
      if (readString == "DELONGHIon")
      {
          irsend.sendRaw(on,sizeof(on)/sizeof(int),38);
           delay(50);
      }    
    
    if (readString == "DELONGHIcondsuper")
      {

        irsend.sendRaw(condsuper,sizeof(condsuper)/sizeof(int),38);
           delay(50);
    } 
    
    
    
    if (readString == "DELONGHIriscalta")
      {
                        

       irsend.sendRaw(riscalt,sizeof(riscalt)/sizeof(int),38);
           delay(50);
    }
      
      
      
      
      readString="";
  }
}

Questo funziona. La differenza sta nel numero di raw codes che dovrebbero inviare.
Il primo ne invia 6, il secondo codice ne invia solo 3. Se provo ad inviarne 4 già non funziona più.
Inoltre una cosa strana che succede è che nel primo caso, il monitor seriale non visualizza niente, nel secondo caso invece appaiono le stringhe inviate dalla app, nella fattispecie DELONGHIon, DELONGHIcondsuper, DELONGHIriscalta e tutto funziona regolarmente.
Quale potrebbe essere una soluzione?
Grazie in anticipo :slight_smile:

Ti invitiamo a presentarti (dicci quali conoscenze hai di elettronica e di programmazione) qui: Presentazioni e a leggere il regolamento: Regolamento - qui una serie di schede by xxxPighi per i collegamenti elettronici vari: ABC - Arduino Basic Connections - qui le pinout delle varie schede by xxxPighi: Pinout - qui una serie di link [u]generali[/u] utili: Link Utili

Hai esaurito la memoria SRam della MCU. Quei vettori/array sono grandi. E Arduino Uno ha poca memoria.

Grazie per la risposta, sapresti indicarmi una possibile soluzione per ovviare a questo problema?
Avrei pensato di immagazzinare le sequenze(gli array) direttamente all’interno della app e non sullo sketch…non so se sia fattibile però

Oppure.
Ho appena notato questo http://www.arduino.cc/en/Reference/PROGMEM

Nel paragrafo Example
// save some unsigned ints
PROGMEM prog_uint16_t charSet = { 65000, 32796, 16843, 10, 11234};

Ho appena provato e adesso il monitor seriale riceve il text inviato dalla app tramite BT.
Purtroppo non partono più i segnali IR.

#include <IRremote.h>
#include <avr/pgmspace.h>


String readString;
IRsend irsend;


PROGMEM  prog_uint16_t on[]  = {8900,4400,650,1600,650,1650,600,500,650,550,650,500,600,550,600,500,650,1650,650,500,650,1550,700,1600,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,1600,650,550,600,550,600,500,650,500,650,550,600,550,600,1650,600,500,650,550,650,500,650,500,600,550,600,1650,650,500,650,500,650,500,600,550,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,600};


PROGMEM  prog_uint16_t condsuper[]={9100,4250,800,1450,700,1550,750,400,750,450,750,350,800,350,750,400,650,1600,700,500,750,1450,750,1550,750,400,650,500,800,350,750,350,750,450,800,1450,650,500,800,350,750,400,700,450,800,350,750,400,750,400,800,350,750,1500,650,500,800,350,750,400,650,500,800,350,750,400,650,500,800,350,800,350,750,450,750,400,750,350,700,450,650,550,750,350,750,400,650,500,750,400,750,1550,750,350,750,400,700,1550,700};
PROGMEM  prog_uint16_t condalt[]={9000,4400,650,1650,600,1650,600,500,650,550,650,500,650,500,600,550,600,1650,650,500,650,1600,650,1600,650,500,650,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,550,600,1650,600,500,600,600,650,500,600,550,600,550,600,550,650,500,650,500,600,550,600,550,600,550,650,500,650,500,600,550,650,500,650,500,650,500,650,500,650,500,650,500,600,550,600,550,600};
PROGMEM  prog_uint16_t condmed[]={9000,4400,650,1650,600,1600,650,500,650,550,650,500,650,500,600,550,600,1650,650,500,650,1600,650,1550,700,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,550,600,1600,650,500,650,550,650,1550,700,500,600,1650,600,550,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650};
PROGMEM  prog_uint16_t condbas[]={8950,4450,650,1600,650,1600,650,450,700,500,650,500,650,500,650,500,650,1600,650,500,650,1600,650,1600,650,550,600,550,600,500,650,500,650,500,700,500,600,550,600,500,650,550,650,450,700,500,600,550,600,550,650,500,650,1600,650,500,600,550,650,500,650,500,650,500,650,1600,650,500,650,500,650,500,650,500,650,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,500,650,500,650,500,650,500,650};


PROGMEM  prog_uint16_t riscalt[]={9000,4450,650,1550,700,1600,650,500,600,550,650,500,650,500,650,500,650,1600,650,500,650,1600,650,1600,650,550,600,500,650,500,650,500,650,550,600,550,600,500,650,500,650,550,650,500,600,550,600,550,600,550,650,500,650,500,600,550,600,550,650,500,650,1600,650,1600,650,1600,650,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,500,650,500,650,500,650,550,600,550,600,500,650,500,650,500,650};


void setup()
{
  Serial.begin(9600);
}

void loop(){

  while (Serial.available()){
  delay(3);
  char c = Serial.read();
  readString +=c;
  }
  
  if (readString.length() >0){
    Serial.println(readString);
   
      /*AC*/
      /*DE LONGHI*/
      
      if (readString == "DELONGHIon")
      {
           
          irsend.sendRaw(on,sizeof(on)/sizeof(int),38);
           delay(50);
      }    
    
    if (readString == "DELONGHIcondsuper")
      {
        
          irsend.sendRaw(condsuper,sizeof(condsuper)/sizeof(int),38);
           delay(50);
    }
    
    if (readString == "DELONGHIcondalta")
      {

          irsend.sendRaw(condalt,sizeof(condalt)/sizeof(int),38);
           delay(50);
    }
    
    if (readString == "DELONGHIcondmedia")
      {
        
        irsend.sendRaw(condmed,sizeof(condmed)/sizeof(int),38);
           delay(50);
    }
    
    if (readString == "DELONGHIcondbassa")
      {
        irsend.sendRaw(condbas,sizeof(condbas)/sizeof(int),38);
           delay(50);
    }
    
    
    
    
    
    
    if (readString == "DELONGHIriscalta")
      {

       irsend.sendRaw(riscalt,sizeof(riscalt)/sizeof(int),38);
           delay(50);
    }
      
      
      
      
      readString="";
  }
}

Non credo che la libreria IRRemote per il comando sandRaw() accetti un array/vettore che non è in memoria SRAM.

Potresti usare 1 solo vettore in SRAM (ovvero NON con progmem) e prima di mandare la sendRaw() copi l'array da quello/i che sono in progmem (ovvero in Flash) a quello che sta in SRam. Devi usare i comandi appositi per leggere ogni int da array che stà in Flash a quello che stà in SRam con comandi tipo pgm_read_word_near() Forse operazione lenta, non sò, mai provato.

Se passa @Leo72 ti sà aiutare meglio :D