Étape 3: Exemple de Code
#include#define aref_voltage 3
const int tmpPin = A2 ;
tampon de char [50] ;
int tmpReading ;
void setup() {}
}
void loop() {}
tmpReading = analogRead(tmpPin) ;
printf ("tmpReading = %d\n",tmpReading) ;
flotteur de tension = tmpReading * aref_voltage ;
tension / = 4096 ;
flotteur tmpC = (tension - 0.5) * 100 ;
sprintf (buffer, "{\"value\":%4.2f}\n", tmpC) ;
FICHIER * fp = fopen ("/ home/ubuntu/datafile.txt","w+") ;
fwrite (tampon, sizeof(char), strlen(buffer), fp) ;
fclose (fp) ;
Exit (0) ;
}