hmm after 7 hours the arduino does hang.... But why????
This is my code:
#include <Ethernet2.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {
192, 168, 0, 177 };
byte server[] = {
111, 111, 111, 111 };
unsigned long lastmillis = -300000;
long sek = 300;
int s1;
float s2;
int s3;
int incomingByte;
int count_i = 0;
Client client(server, 80);
void setup(){
Ethernet.begin(mac, ip);
Serial.begin(9600);
Serial.println("Start!");
delay(1000);
}
void loop(){
if (millis() >= (lastmillis + (sek * 1000))){
Ethernet.begin(mac, ip);
if (client.connect()){
client.print("GET MYSITE/daten_mysql.php?s1=");
s1 = (analogRead(0) * 1000.0)/1023.0;
if ((long)s1 >= 50){
client.print((long)s1);
}
else{
client.print("0");
}
client.print("&s2=");
s2 = ((((analogRead(1) * 1000.0)/1023.0)/(1000.0))*222.22)-61.11;
client.print((long)(s2*10));
client.print("&s3=");
s3 = ((((analogRead(2) * 1000.0)/1023.0)/1000.0)*190.6)-40.2;
client.print((long)(s3*10));
client.println();
lastmillis = millis();
}
}
}
The loop funcion is quite easy. As soon as 5 minutes are over arduino is going to a Webpage with a MYSQL Database and stores 3 Sensor values to this Database. That's it.
What's wrong about that???
Thx
Geko