[RESOLU][Arduino] Conflit de librairies.

Partie du forum pour tout ce qui concerne la partie électronique. Forum, conseil, astuce et entraide sur le dépannage de carte électronique ou divers conseils .
Avatar de l’utilisateur
maxpeigne
Créateur de langage
Créateur de langage
Messages : 712
Inscription : 11 oct. 2015, 17:31
Localisation : Nord pas de calais

[RESOLU][Arduino] Conflit de librairies.

Message par maxpeigne »

Bonjour à tous,

Avec un arduino UNO, je suis en train de réaliser une pico brasserie. Les principaux éléments sont:

- via un afficheur LCD, demander un nombre de paliers, puis demande une temperature et un temps pour chacun des paliers.
- puis réalise une régulation de temperature en fonction des données récupérées.

Le code fonction bien, mais j'ai 2 problèmes:

Le 1er, pas trop grave, est que dans l'état actuel, ma valeur mesureTemperature (l'acquisition d'analogRead(A0)) reste tout le temps figée à 1023. Le cablage parait bon car lorsque je charge le programme d'exemple analogInput et que je rajoutes l'affichage de l'entree sur le moniteur serie ca fonctionne.

Le 2e probleme, plus genant, est que lorsque j'essaie d'inclure la librairie onewire.h pour utiliser des capteurs de temperature DS18B20, j'ai tout une tapée d'erreur qui apparaissent.

Code : Tout sélectionner

/* PicoBrasserie
- void setup()
- void loop()

-menuAcquisitionDesParametres()
- void actualiserLesBoutons()
- void raffraichirEcranLCD()

-

*/

#include <simpleMinuteur.h>
#include <simpleBouton.h>
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(11, 10, 5, 4, 3, 2);
char message1[16] = " ";
char message2[16] = " ";

//Variables de menu
int menuPage = 0;
int nbreDePalier =0;
int palierEnCours = 0;
int csgTemperaturePalier = 0;
int csgTempsPalier = 0;
int csgTemperature[10] = {0};
int csgTemps[10] = {0};

// Variables de regulation
boolean verrouPalier = false;
int phaseDeLaRegul = 0;
int led = 13;
int mesureTemperature = 0;
// Declaration des minuteurs
simpleMinuteur palier1;
simpleMinuteur palier3;

// Déclaration des boutons
simpleBouton bouton_plus(7);
simpleBouton bouton_moins(8);
simpleBouton bouton_entrer(9);

void setup(){
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(led, OUTPUT);
digitalWrite(led,LOW);
}


void loop(){
while (menuPage != 4){
menuAcquisitionDesParametres();
}

while (palierEnCours<=nbreDePalier && menuPage == 4){

mesureTemperature = analogRead(A0);
delay(100);
regulation();
}
}


/********************************************************************************
Menu d'acquisition des parametres via l'ecran LCD
********************************************************************************/
void menuAcquisitionDesParametres(){
actualiserLesBoutons();

switch(menuPage){

case 1:
// Reglage du nombre de palier
sprintf(message1,"Nombre de palier");
if (bouton_plus.vientDEtreEnfonce()){
nbreDePalier++;
}
if (bouton_moins.vientDEtreEnfonce()){
nbreDePalier--;
}
if (bouton_entrer.vientDEtreEnfonce()){
menuPage = 2;
}
sprintf(message2,"Palier= %d ",nbreDePalier);
break;

case 2:
//Reglage de la temperature de chaque palier
palierEnCours = 0;
while (palierEnCours<nbreDePalier){

actualiserLesBoutons();

sprintf(message1,"Temp palier:%d ",palierEnCours);
if (bouton_plus.vientDEtreEnfonce()){
csgTemperaturePalier++;
}
if (bouton_moins.vientDEtreEnfonce()){
csgTemperaturePalier--;
}
if (bouton_entrer.vientDEtreEnfonce()){
csgTemperature[palierEnCours] = csgTemperaturePalier;
palierEnCours++;
}
sprintf(message2,"Palier= %d ",csgTemperaturePalier);
raffraichirEcranLCD();
}
menuPage = 3;
break;

case 3:
//Reglage de la temps de chaque palier
palierEnCours = 0;
while (palierEnCours<nbreDePalier){

actualiserLesBoutons();

sprintf(message1,"Tps palier:%d ",palierEnCours);
if (bouton_plus.vientDEtreEnfonce()){
csgTempsPalier++;
}
if (bouton_moins.vientDEtreEnfonce()){
csgTempsPalier--;
}
if (bouton_entrer.vientDEtreEnfonce()){
csgTemps[palierEnCours] = csgTempsPalier;
palierEnCours++;
}
sprintf(message2,"Tps= %d ",csgTempsPalier);
raffraichirEcranLCD();
}
menuPage = 4;
palierEnCours = 0;
break;

case 4:

for (int i = 0; i < nbreDePalier; i++) {
sprintf(message1,"Palier %d",i);
sprintf(message2,"Tps=%d / T=%d",csgTemps[i], csgTemperature[i]);
raffraichirEcranLCD();
delay(3000);

}
break;

default:
sprintf(message1," Menu: ");
sprintf(message2,"AutomabEEr");
if (bouton_entrer.vientDEtreEnfonce()){
menuPage = 1;
}
break;
}

//on envoie le texte
raffraichirEcranLCD();
}

/* ---------------------- Fonctions diverses du LCD --------------------- */

// Actualisation des boutons
void actualiserLesBoutons(){
bouton_plus.actualiser();
bouton_moins.actualiser();
bouton_entrer.actualiser();
}

// Raffraichir l'ecran LCD
void raffraichirEcranLCD(){
lcd.setCursor(0,0);
lcd.print(message1);
lcd.setCursor(0,1);
lcd.print(message2);
}


/********************************************************************************
Regulation de temperature par palier
********************************************************************************/

void regulation(){

if (phaseDeLaRegul == 0){
Serial.print("On chauffe pour atteindre la temperature = ");
Serial.print(csgTemperature[palierEnCours]);
Serial.print(" pour le palier numero = ");
Serial.print(palierEnCours);
Serial.print(" La valeur du potar est de = ");
Serial.println(mesureTemperature);
digitalWrite(led,HIGH);
if (mesureTemperature > csgTemperature[palierEnCours]){
phaseDeLaRegul = 1;
}
}

if (phaseDeLaRegul == 1){
if (!verrouPalier){
palier1.demarrer(csgTemps[palierEnCours]*1000); //On demarre la minuterie pour 30 min // allumer ou éteindre la led du capteur rouge
verrouPalier = true; // On met a 1 le verrou afin de creer un front pour ne pas redémarrer la tempo.
Serial.print("On active le palier pour ");
Serial.println(csgTemps[palierEnCours]);
}
if (!palier1.estTermine()){
START(csgTemperature[palierEnCours]);
}
if (palier1.estTermine()){
phaseDeLaRegul = 0;
palierEnCours++;
verrouPalier = false;
}
}
}

/* ---------------------- Fonctions diverses de regulation --------------------- */

void START(int temperatureCible){ // START (50°C)**********************************************************/

const int offsetTemperatureCible = 100;

if ( mesureTemperature > (temperatureCible + offsetTemperatureCible))
{digitalWrite(led,LOW); // eteindre la led du capteur rouge (moult)
Serial.print("On eteint le chauffage. La consigne est de ");
}
if ( mesureTemperature < offsetTemperatureCible)
{digitalWrite(led,HIGH); // eteindre la led du capteur rouge (moult)
Serial.print("On active le chauffage. La consigne est de ");
}
Serial.println(temperatureCible);
}
Avez vous une idée de ce qui ne va pas?

Merci.

(le message d'erreur suit car le post est trop long ^^)
http://automacile.fr - Site et tutoriels sur l'arduino.
Avatar de l’utilisateur
maxpeigne
Créateur de langage
Créateur de langage
Messages : 712
Inscription : 11 oct. 2015, 17:31
Localisation : Nord pas de calais

Re: [Arduino] Conflit de librairies.

Message par maxpeigne »

Et voici les erreurs lorsque j'inclus la librairie onewire.h (je l'ai tromqué vers le milieu sinon il etait encore trop grand...):

Code : Tout sélectionner

In file included from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:192:0,
                 from /home/netbook/sketchbook/libraries/OneWire/OneWire.cpp:85:
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:116:83: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, const char*)' conflicts with
  friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
                                                                                   ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:115:27: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const String&)' here
  friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
                           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:117:73: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, char)' conflicts with
  friend StringSumHelper & operator + (const StringSumHelper &lhs, char c);
                                                                         ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:116:27: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const char*)' here
  friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
                           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:117:73: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, char)' conflicts with
  friend StringSumHelper & operator + (const StringSumHelper &lhs, char c);
                                                                         ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:115:27: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const String&)' here
  friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
                           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:118:84: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' conflicts with
  friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num);
                                                                                    ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:117:27: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, char)' here
  friend StringSumHelper & operator + (const StringSumHelper &lhs, char c);
                           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:118:84: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' conflicts with
  friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num);
                                                                                    ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:116:27: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const char*)' here
  friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
                           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:118:84: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' conflicts with
  friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num);
                                                                                    ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:115:27: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const String&)' here
  friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
                           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:119:74: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, int)' conflicts with
  friend StringSumHelper & operator + (const StringSumHelper &lhs, int num);
                                                                          ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:118:27: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' here
  friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num);
                           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:119:74: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, int)' conflicts with
  friend StringSumHelper & operator + (const StringSumHelper &lhs, int num);
                                                                          ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:117:27: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, char)' here
  friend StringSumHelper & operator + (const StringSumHelper &lhs, char c);
                           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:119:74: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, int)' conflicts with
  friend StringSumHelper & operator + (const StringSumHelper &lhs, int num);
                                                                          ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:116:27: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const char*)' here
  friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
                           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:119:74: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, int)' conflicts with
  friend StringSumHelper & operator + (const StringSumHelper &lhs, int num);
                                                                          ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:115:27: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const String&)' here
  friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
                           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:120:83: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' conflicts with
  friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num);
  ..................
                                       
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:206:17: error: declaration of C function 'long int random(long int)' conflicts with
 long random(long);
                 ^
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:4:0,
                 from /home/netbook/sketchbook/libraries/OneWire/OneWire.cpp:85:
/usr/lib/avr/include/stdlib.h:504:13: error: previous declaration 'long int random()' here
 extern long random(void);
             ^
In file included from /home/netbook/sketchbook/libraries/OneWire/OneWire.cpp:85:0:
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:207:23: error: declaration of C function 'long int random(long int, long int)' conflicts with
 long random(long, long);
                       ^
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:206:6: error: previous declaration 'long int random(long int)' here
 long random(long);
      ^
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:207:23: error: declaration of C function 'long int random(long int, long int)' conflicts with
 long random(long, long);
                       ^
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:4:0,
                 from /home/netbook/sketchbook/libraries/OneWire/OneWire.cpp:85:
/usr/lib/avr/include/stdlib.h:504:13: error: previous declaration 'long int random()' here
 extern long random(void);
http://automacile.fr - Site et tutoriels sur l'arduino.
Avatar de l’utilisateur
Brebiou
Dieu du process
Dieu du process
Messages : 929
Inscription : 21 oct. 2015, 08:38

Re: [Arduino] Conflit de librairies.

Message par Brebiou »

Essaye d'enlever dans le début de ton code les ligne mis en commentaires, les 12 premières lignes.
Ensuite il y a à la ligne 220 le commentaire avec de multiple étoile et un slash à la fin, tente d'enlever les étoiles et le slash. D'ailleurs, un commentaire derrière un "{" est fortement déconseillé, met ton commentaire au dessus du void.

Je sais que c'est con au premier abord mais je me suis déjà fait chier à débugger un programme qui plantait à cause d'un commentaire mal écrit, ou alors un "é" dans un commentaire qui fumait la compilation.

Je me suis permis d'éditer ton premier post sans en changer la teneur ;)
Avatar de l’utilisateur
Bernardo59
Dieu du process
Dieu du process
Messages : 957
Inscription : 20 oct. 2015, 05:48
Localisation : Nimes

Re: [Arduino] Conflit de librairies.

Message par Bernardo59 »

Bonjour Maxpeigne,

Regarde le code source situé sur ce lien : https://skyduino.wordpress.com/2012/04/ ... e-ds18b20/
Avatar de l’utilisateur
maxpeigne
Créateur de langage
Créateur de langage
Messages : 712
Inscription : 11 oct. 2015, 17:31
Localisation : Nord pas de calais

Re: [Arduino] Conflit de librairies.

Message par maxpeigne »

Merci pour votre coup de main mais le problème est résolue.

Je programmais sur mon netbook tournant sous Ubuntu, et à priori ma version de oneWire.h est corrompue...
Lorsque je test mon prog sous windows 10 tout est OK!

Désolé pour le dérangement... :?
http://automacile.fr - Site et tutoriels sur l'arduino.
Répondre