Hi,
I came across this website //www.tweaking4all.com/hardware/arduino/arduino-ethernet-data-push/ and wanted to test the code - with some parts of the code I did try to upload integers and decimals to a mysql-database. It worked fine!
In addition wrote a code for some measurements – the analysis of
the data and showing it at the serial monitor works as well!
Finally I wanted to merge this two codes and to send the data via a function called "DatenSenden()".
void DatenSenden()
{
#ifdef DEBUG
Serial.print("MillisDifferenz: ");
Serial.println(MillisDifferenz);
Serial.print("Sonde 1:\t");
Serial.print(counts1,DEC);
Serial.print(" ips,\t");
Serial.println(cpm1,2);
Serial.print("Sonde 2:\t");
Serial.print(counts2,DEC);
Serial.print(" ips,\t");
Serial.println(cpm2,2);
#endif
#ifdef DEBUG
Serial.println("connecting...");
#endif
if (client.connect(server, 80)) {
#ifdef DEBUG //should show, that all the parameters for the connection are avaiable
Serial.print("localIP: ");
Serial.println(Ethernet.localIP());
Serial.print("subnetMask: ");
Serial.println(Ethernet.subnetMask());
Serial.print("gatewayIP: ");
Serial.println(Ethernet.gatewayIP());
Serial.print("dnsServerIP: ");
Serial.println(Ethernet.dnsServerIP());
Serial.println("connected..."); Serial.println("");
#endif
client.print("GET /upload_data.php?zuluft=");
client.print(cpm1);
client.print("&&abluft=");
client.print(cpm2);
client.print(" HTTP/1.0\r\n");
client.print("Host: ");
client.print(server);
client.println("\r\nConnection: close\r\n\r\n");
client.stop();
} else {
#ifdef DEBUG
Serial.println("connection failed");
#endif
}
}
Typically the code is working properly until it reaches
Serial.println(cpm1,2);
This decimal-number is partly printed, the point is the last
character I do see in the serial monitor. The variable itself is avaiable in the function – if I do add the “Serial.print”-part several times, the data is written properly several times.
If I do
leave away the “Serial.print”-part, the controller again crashes several
lines above the “client.connect”-part.
Has anybody had a similar problem? (For sure I can upload the full code as well - unfortunately I could not create a smaller example with a similar problem).
Thanks a lot!