Oui barbudor, tu as raison je n'ai pas encore créer la librairy qui est directement dans le code.
La solutions serait apparemment de convertir la variable en chaine de caractère String, comme défini par ce topic : [resolu] Afficheur ELCD série et librairie sd1307 - #5 by skywodd - Français - Arduino Forum et qui fonctionne très bien avec un capteur analogique mais pas avec un numérique.
#include <OneWire.h>
OneWire ds(2); // on pin 2
void setup(void) {
Serial.begin(19200);
ELCD_initialize();
delay(200);
ELCD_Clear_LCD();
ELCD_Cursor_Position(0, 0);
ELCD_put_str("Capteur");
delay(30);
ELCD_Cursor_Position(0, 1);
ELCD_put_str("Temp.:");
delay(30);
}
void loop(void) {
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.
present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
Serial.print(" Data = ");
Serial.print(present,HEX);
Serial.print(" ");
for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
Serial.print(data[i], HEX);
Serial.print(" ");
}
Serial.print(" CRC=");
Serial.print(OneWire::crc8(data, 8), HEX);
Serial.println();
// convert the data to actual temperature
unsigned int raw = (data[1] << 8) | data[0];
if (type_s) {
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10) {
// count remain gives full 12 bit resolution
raw = (raw & 0xFFF0) + 12 - data[6];
}
} else {
byte cfg = (data[4] & 0x60);
if (cfg == 0x00) raw = raw << 3; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw << 2; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw << 1; // 11 bit res, 375 ms
// default is 12 bit resolution, 750 ms conversion time
}
mesure_brute = (float)raw / 16.0;
String texte = (String(mesure_brute)); // Conversion de la mesure en string
ELCD_Cursor_Position(8, 2);
ELCD_put_chr(texte.toCharArray());
delay(30);
delay(1000); // On patiente une seconde
}
/* Initialize l'afficheur lcd */
void ELCD_initialize(){
Serial.print(0xA0, BYTE);
}
/* Cache le curseur */
void ELCD_Cursor_OFF(){
Serial.print(0xA3, BYTE);
Serial.print(0x0C, BYTE);
}
/* Affiche le curseur */
void ELCD_Cursor_ON(){
Serial.print(0xA3, BYTE);
Serial.print(0x0E, BYTE);
}
/* Efface l'écran et place le curseur à (0, 0) */
void ELCD_Clear_LCD(){
Serial.print(0xA3, BYTE);
Serial.print(0x01, BYTE);
}
/* Place le curseur à la position (x, y) */
void ELCD_Cursor_Position(int x, int y){
Serial.print(0xA1, BYTE);
Serial.print(x, BYTE);
Serial.print(y, BYTE);
}
/* Affiche une chaine de caractéres (char[] terminé par \0) sur l'afficheur */
void ELCD_put_str(char *str){
Serial.print(0xA2, BYTE);
while(*str)
Serial.print(*str++);
Serial.print(0, BYTE);
}
/* Affiche un caratéres ASCII sur l'afficheur (caractéres spéciaux aux LCD non pris en charge) */
void ELCD_put_chr(char ch){
Serial.print(0xA2, BYTE);
Serial.print(ch);
Serial.print(0, BYTE);
}
/* Définit un caractére personalisé à l'index défini (de 8 à 15) suivant le tableau newChar[],
de structure identique à celui utilisé par la fonction createChar de la lib LiquidCrystal.
Si showAfter = 1 le caractére sera afficher aprés la création, sinon il ne sera afficher qu'aprés un ELCD_put_chr(index) */
void ELCD_create_char(byte index, byte newChar[], byte showAfter) {
if(showAfter)
Serial.print(0xA4, BYTE);
else
Serial.print(0xA5, BYTE);
Serial.print(index, BYTE);
Serial.print(newChar[0] & 0x1F, BYTE);
Serial.print(newChar[1] & 0x1F, BYTE);
Serial.print(newChar[2] & 0x1F, BYTE);
Serial.print(newChar[3] & 0x1F, BYTE);
Serial.print(newChar[4] & 0x1F, BYTE);
Serial.print(newChar[5] & 0x1F, BYTE);
Serial.print(newChar[6] & 0x1F, BYTE);
Serial.print(newChar[7] & 0x1F, BYTE);
}
Mais j'ai ce message d'erreur, je sèche .....
project01_pde.cpp:85:3: error: 'mesure_brute' was not declared in this scope
project01_pde.cpp:88:34: error: no matching function for call to 'String::toCharArray()'
C:...........\mpide-0022-windows-20110822\hardware\pic32\cores\pic32/WString.h:80:10: note: candidate is: void String::toCharArray(char*, unsigned int)