Bonjour à tous,
Je viens à vous car j'ai déployé un réseau de xbee (Api) avec des capteurs de température LM35DZ. En effet, j'utilise les entrées analogiques des xbees afin de récupérer les différentes températures. Chaque pièce comporte un xbee, en receveur j'ai un autre xbee qui récupère tous les paquets des transmetteurs.Afin d'afficher les températures, j'utilise un arduino + ethernet shield afin de convertir ses paquets en valeurs décimales et l'envoyer sur une page HTML. L'acquisition se fait pendant un petit moment puis au bout de quelques jours la page HTML ne se génère plus (elle reste en perpétuelle recherche).
Est ce que cela pourrait venir de la mémoire du serveur qui serait saturée au bout d'un certain temps? Dois-je vider mon buffer?
Voici mon code :
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x14, 0x46 };
IPAddress ip(162,38,115, 28);
unsigned long delayMax = 0;
int packet[32];
int analogSamples[5];
int moduleID[1];
float v[4];
float z[5];
float y[6];
EthernetServer server(80);
void setup()
{
Ethernet.begin(mac, ip);
server.begin();
Serial.begin(9600);
delay(1);
}
void loop()
{
readpacket();
EthernetClient client = server.available();
if (client)
{
boolean currentLineIsBlank = true;
while (client.connected())
{
if (client.available())
{
char c = client.read();
if (c == '\n' && currentLineIsBlank)
{
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println(v[1]);
client.println(v[2]);
client.println(v[3]);
client.println(v[4]);
client.println();
client.println(z[1]);
client.println(z[2]);
client.println(z[3]);
client.println(z[4]);
client.println(z[5]);
client.println();
client.println(y[1]);
client.println(y[2]);
client.println(y[3]);
client.println(y[4]);
client.println(y[5]);
client.println();
break;
}
if (c == '\n')
{
currentLineIsBlank = true;
}
else if (c != '\r')
{
currentLineIsBlank = false;
}
}
}
delay(1000);
client.stop();
}
}
void readpacket()
{
if (Serial.available() > 0)
{
delayMax = millis()+50;
int b = Serial.read();
if (b == 0x7E)
{
packet[0] = b;
packet[1] = readByte();
packet[2] = readByte();
int dataLength = (packet[1] << 8) | packet[2];
for(int i=1;i<=dataLength;i++)
{
packet[2+i] = readByte();
}
int apiID = packet[3];
if (apiID == 0x83)
{
moduleID[1] = (packet[4] << 8) | packet[5];
if (moduleID[1]==0x01)
{
int SgnlPwr = packet[6];
int SampleNumber = packet[8];
int i;
if (SampleNumber >= 1)
{
analogSamples[1] = (packet[11] << 8) | packet[12];
analogSamples[2] = (packet[13] << 8) | packet[14];
analogSamples[3] = (packet[15] << 8) | packet[16];
analogSamples[4] = (packet[17] << 8) | packet[18];
delay(1);
}
int reading = analogSamples[1];
int reading_2 = analogSamples[2];
int reading_3 = analogSamples[3];
int reading_4 = analogSamples[4];
// On converti la valeur lue en millivolts
v[1] =((float) reading)*330/1024;
v[2] =((float) reading_2)*330/1024;
v[3] =((float) reading_3)*330/1024;
v[4] =((float) reading_4)*330/1024;
delay(1);
}
else if (moduleID[1]==0x02)
{
int SgnlPwr = packet[6];
int SampleNumber = packet[8];
int i;
if (SampleNumber >= 1)
{
analogSamples[1] = (packet[11] << 8) | packet[12];
analogSamples[2] = (packet[13] << 8) | packet[14];
analogSamples[3] = (packet[15] << 8) | packet[16];
analogSamples[4] = (packet[17] << 8) | packet[18];
analogSamples[5] = (packet[19] << 8) | packet[20];
delay(1);
}
int reading_5 = analogSamples[1];
int reading_6 = analogSamples[2];
int reading_7 = analogSamples[3];
int reading_8 = analogSamples[4];
int reading_9 = analogSamples[5];
// On converti la valeur lue en millivolts
z[1] =((float) reading_5)*330/1024;
z[2] =((float) reading_6)*330/1024;
z[3] =((float) reading_7)*330/1024;
z[4] =((float) reading_8)*330/1024;
z[5] =((float) reading_9)*330/1024;
delay(1);
}
else if (moduleID[1]==0x03)
{
int SgnlPwr = packet[6];
int SampleNumber = packet[8];
int i;
if (SampleNumber >= 1)
{
analogSamples[1] = (packet[11] << 8) | packet[12];
analogSamples[2] = (packet[13] << 8) | packet[14];
analogSamples[3] = (packet[15] << 8) | packet[16];
analogSamples[4] = (packet[17] << 8) | packet[18];
analogSamples[5] = (packet[19] << 8) | packet[20];
delay(1);
}
int reading_10 = analogSamples[1];
int reading_11 = analogSamples[2];
int reading_12 = analogSamples[3];
int reading_13 = analogSamples[4];
int reading_14 = analogSamples[5];
// On converti la valeur lue en millivolts
y[1] =((float) reading_10)*330/1024;
y[2] =((float) reading_11)*330/1024;
y[3] =((float) reading_12)*330/1024;
y[4] =((float) reading_13)*330/1024;
y[5] =((float) reading_14)*330/1024;
delay(1);
}
}
}
}
}
uint8_t readByte()
{
while (true)
{
if(delayMax <= millis())
{
break;
}
if (Serial.available() > 0)
{
return Serial.read();
}
}
return 0;
}
Merci d'avance,