Bonjour , je partage pour ceux qui seraient intéressés.
J'ai fait ce petit programme (tiré d'un programme trouvé sur le net et modifié pour fonctionner sur un shield ethernet) pour relevé la température d'une pièce de mon domicile à distance .
L'interface est très rudimentaire , et sera surement à améliorer par la suite , mais cela fonctionne .
N’hésitez pas à apporter des modifications et des idées je suis preneur .
// Pin ou est branchee la CTN
#define PINOTERMISTOR A0
// Parametre de la CTN
#define TERMISTORNOMINAL 10000
#define TEMPERATURENOMINAL 25
#define NUMAMOSTRAS 5
#define BCOEFFICIENT 3977
#define SERIESRESISTOR 10000
#include <SPI.h>
#include <Ethernet.h>
// Entrez votre adresse MAC à la place des 00 et votre adresse IP
byte mac[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
byte ip[] = { 192,168,0, 0 };
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
int amostra[NUMAMOSTRAS];
int i;
void setup(void) {
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
Serial.begin(9600);
analogReference(EXTERNAL);
}
void loop(void) {
float media;
for (i=0; i< NUMAMOSTRAS; i++) {
amostra[i] = analogRead(PINOTERMISTOR);
delay(10);
}
media = 0;
for (i=0; i< NUMAMOSTRAS; i++) {
media += amostra[i];
}
media /= NUMAMOSTRAS;
// Convert the thermal stress value to resistance
media = 1023 / media - 1;
media = SERIESRESISTOR / media;
//Calculate temperature using the Beta Factor equation
float temperatura;
temperatura = media / TERMISTORNOMINAL; // (R/Ro)
temperatura = log(temperatura); // ln(R/Ro)
temperatura /= BCOEFFICIENT; // 1/B * ln(R/Ro)
temperatura += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
temperatura = 1.0 / temperatura; // Invert the value
temperatura -= 273.15; // Convert it to Celsius
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
client.print("La temperature est de: ");
client.print(temperatura);
client.println(" *C");
client.stop();
}}}
}