Je vous présente mon projet: réalisation d'une commande pour un climatiseur au travers d'un photo-transistor.
L'objectif final étant d'avoir un arduino qui me permette d'allumer mes climatiseurs suivant des plages horaires et de regler la température souhaitée, en gros un thermostat.
La première étape que je souhaite réaliser est l'apprentissage de l'ensemble des trames envoyé par ma telecommande et déjà la ça merde!
Mon premier problème est la compilation des examples de sketch que j'ai trouvé sur github de IRremote.
J'obtiens les erreurs durant la compilation: "IRsend" does not name a type.
//------------------------------------------------------------------------------
// Include the IRremote library header
//
#include <IRremote.h>
//------------------------------------------------------------------------------
// Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838)
//
int recvPin = 11;
IRrecv irrecv(recvPin);
//+=============================================================================
// Configure the Arduino
//
void setup ( )
{
Serial.begin(9600); // Status message will be sent to PC at 9600 baud
irrecv.enableIRIn(); // Start the receiver
}
//+=============================================================================
// Display IR code
//
void ircode (decode_results *results)
{
// Panasonic has an Address
if (results->decode_type == PANASONIC) {
Serial.print(results->address, HEX);
Serial.print(":");
}
// Print Code
Serial.print(results->value, HEX);
}
//+=============================================================================
// Display encoding type
//
void encoding (decode_results *results)
{
switch (results->decode_type) {
default:
case UNKNOWN: Serial.print("UNKNOWN"); break ;
case NEC: Serial.print("NEC"); break ;
case SONY: Serial.print("SONY"); break ;
case RC5: Serial.print("RC5"); break ;
case RC6: Serial.print("RC6"); break ;
case DISH: Serial.print("DISH"); break ;
case SHARP: Serial.print("SHARP"); break ;
case JVC: Serial.print("JVC"); break ;
case SANYO: Serial.print("SANYO"); break ;
case MITSUBISHI: Serial.print("MITSUBISHI"); break ;
case SAMSUNG: Serial.print("SAMSUNG"); break ;
case LG: Serial.print("LG"); break ;
case WHYNTER: Serial.print("WHYNTER"); break ;
case AIWA_RC_T501: Serial.print("AIWA_RC_T501"); break ;
case PANASONIC: Serial.print("PANASONIC"); break ;
case DENON: Serial.print("Denon"); break ;
}
}
//+=============================================================================
// Dump out the decode_results structure.
//
void dumpInfo (decode_results *results)
{
// Check if the buffer overflowed
if (results->overflow) {
Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWLEN");
return;
}
// Show Encoding standard
Serial.print("Encoding : ");
encoding(results);
Serial.println("");
// Show Code & length
Serial.print("Code : ");
ircode(results);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
}
//+=============================================================================
// Dump out the decode_results structure.
//
void dumpRaw (decode_results *results)
{
// Print Raw data
Serial.print("Timing[");
Serial.print(results->rawlen-1, DEC);
Serial.println("]: ");
for (int i = 1; i < results->rawlen; i++) {
unsigned long x = results->rawbuf[i] * USECPERTICK;
if (!(i & 1)) { // even
Serial.print("-");
if (x < 1000) Serial.print(" ") ;
if (x < 100) Serial.print(" ") ;
Serial.print(x, DEC);
} else { // odd
Serial.print(" ");
Serial.print("+");
if (x < 1000) Serial.print(" ") ;
if (x < 100) Serial.print(" ") ;
Serial.print(x, DEC);
if (i < results->rawlen-1) Serial.print(", "); //',' not needed for last one
}
if (!(i % 8)) Serial.println("");
}
Serial.println(""); // Newline
}
//+=============================================================================
// Dump out the decode_results structure.
//
void dumpCode (decode_results *results)
{
// Start declaration
Serial.print("unsigned int "); // variable type
Serial.print("rawData["); // array name
Serial.print(results->rawlen - 1, DEC); // array size
Serial.print("] = {"); // Start declaration
// Dump data
for (int i = 1; i < results->rawlen; i++) {
Serial.print(results->rawbuf[i] * USECPERTICK, DEC);
if ( i < results->rawlen-1 ) Serial.print(","); // ',' not needed on last one
if (!(i & 1)) Serial.print(" ");
}
// End declaration
Serial.print("};"); //
// Comment
Serial.print(" // ");
encoding(results);
Serial.print(" ");
ircode(results);
// Newline
Serial.println("");
// Now dump "known" codes
if (results->decode_type != UNKNOWN) {
// Some protocols have an address
if (results->decode_type == PANASONIC) {
Serial.print("unsigned int addr = 0x");
Serial.print(results->address, HEX);
Serial.println(";");
}
// All protocols have data
Serial.print("unsigned int data = 0x");
Serial.print(results->value, HEX);
Serial.println(";");
}
}
//+=============================================================================
// The repeating section of the code
//
void loop ( )
{
decode_results results; // Somewhere to store the results
if (irrecv.decode(&results)) { // Grab an IR code
dumpInfo(&results); // Output the results
dumpRaw(&results); // Output the results in RAW format
dumpCode(&results); // Output the results as source code
Serial.println(""); // Blank line between entries
irrecv.resume(); // Prepare for the next value
}
}
L'IDE arduino installe une librairie IRremote ici: "C:\Program Files (x86)\Arduino\libraries\RobotIRremote" (sous Win7)
La librairie qu'il faut utiliser est celle ci.
Malheureusement lors de la compilation l'IDE utilise la librairie RobotIRremote par défaut (il y a un warning lors de la compilation). Le seul moyen que j'ai trouvé est d'effacer la librairie RobotIRremote (en fait je j'ai déplacée). Il faut relancer l'IDE après.
Merci pour l'info! ca va un peu plus loin maintenant.
Mais j'ai encore des messages d'erreur.
Arduino : 1.6.5 (Windows 7), Carte : "Arduino Yún"
IRremote\IRremote.cpp.o: In function `MATCH(int, int)':
C:\Program Files (x86)\Arduino\libraries\Arduino-IRremote-master/IRremote.cpp:43: multiple definition of `MATCH(int, int)'
IRremote.cpp.o:C:\Users\Frank\AppData\Local\Temp\build8120864029827355337.tmp/IRremote.cpp:43: first defined here
IRremote\IRremote.cpp.o: In function `MATCH(int, int)':
C:\Program Files (x86)\Arduino\libraries\Arduino-IRremote-master/IRremote.cpp:43: multiple definition of `MATCH_MARK(int, int)'
IRremote.cpp.o:C:\Users\Frank\AppData\Local\Temp\build8120864029827355337.tmp/IRremote.cpp:43: first defined here
IRremote\IRremote.cpp.o: In function `MATCH(int, int)':
C:\Program Files (x86)\Arduino\libraries\Arduino-IRremote-master/IRremote.cpp:43: multiple definition of `MATCH_SPACE(int, int)'
IRremote.cpp.o:C:\Users\Frank\AppData\Local\Temp\build8120864029827355337.tmp/IRremote.cpp:43: first defined here
IRremote\IRremote.cpp.o: In function `MATCH(int, int)':
C:\Program Files (x86)\Arduino\libraries\Arduino-IRremote-master/IRremote.cpp:43: multiple definition of `__vector_41'
IRremote.cpp.o:C:\Users\Frank\AppData\Local\Temp\build8120864029827355337.tmp/IRremote.cpp:43: first defined here
IRremote\IRremote.cpp.o: In function `MATCH(int, int)':
C:\Program Files (x86)\Arduino\libraries\Arduino-IRremote-master/IRremote.cpp:43: multiple definition of `irparams'
IRremote.cpp.o:C:\Users\Frank\AppData\Local\Temp\build8120864029827355337.tmp/IRremote.cpp:43: first defined here
collect2.exe: error: ld returned 1 exit status
Erreur lors de la compilation.
Ce rapport contiendrait plus d'informations si l'option
"Montrer les informations de sortie pendant la compilation"
était activée dans Fichier > Préférences.
Tu as installé ta librairie comment? car dans la version 1.6.X l'IDE installe les librairies additionnelles dans Mes Documents\Documents\Arduino\libraries et non dans C:\Program Files (x86)\Arduino\libraries
Merci beaucoup, ca y est ca compile!
Tu as raison c'est bien dans mes documents.
J'ai viré les autres librairies et ca compile sans erreurs.
Je vais pouvoir commencer à regarder le code...
Bon j'ai encore un souci.
Je n'arrive pas a uploader l'exe dans l'arduino.
Il compile, il lance le televersement, la jauge se remplie et après cela reste sur televersement...
La led USB s'allume aussi après plusieur dizaine de seconde. c'est pas normal?
Oui c bien yun qui est sélectionné. Je vois com1 dans la liste aucun com virtuel est indiqué. J'ai essayé de réinstaller les drivers USB mais ça change rien.