Hello,
I try to set up home automation by Arduino.
Local controlers by Arduino : OK
Transfert of data to main Arduino controler with ethernet shield by I2C : OK
TCP serveur for datadispath on local network : OK
Creation of Mysql database on my website : OK
Transfert of data from main Arduino controler to database using PHP Post : works every 2 to 5 times
to check I use a arduino programm that sends a Post every second to write in database a counter value that is increased at each write operation, to check if I lose messages, and I loose about 75%.
If I use same PHP code in index.php and I lauch the webside, every update of website a lign is created in database even if i push update of the webpage every second or faster.
So the connection from Arduino seem haeardous ???
someone can help me ?
my arduino code :
#include <Ethernet.h>
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
String data;
int No = 0;
int h;
IPAddress ip(192, 168, 0, 125);
IPAddress myDns(212, 27, 40, 240);
IPAddress gateway(192, 168, 0, 254);
IPAddress subnet(255, 255, 255, 0);
EthernetClient client;
void setup() {
Â
 Serial.begin(9600);
 Ethernet.begin(mac, ip, myDns, gateway, subnet);
Â
 ip = Ethernet.localIP();
 // print your local IP address:
 Serial.print("My IP address: ");
 for (byte thisByte = 0; thisByte < 4; thisByte++) {
  // print the value of each byte of the IP address:
  Serial.print(ip[thisByte], DEC);
  Serial.print(".");
 }
 Serial.println();
}
void loop() {
 data = "temp1=";
 data += No ;
 data +=  "&hum1=";
 data +=  19;
 if (client.connect("www.steinhilber.eu", 80)) { // REPLACE WITH YOUR SERVER ADDRESS
  Serial.println("connecte a steinhilber.eu");
  client.println("POST /add.php HTTP/1.1");
  client.println("Host: steinhilber.eu"); // SERVER ADDRESS HERE TOO
  client.println("Content-Type: application/x-www-form-urlencoded");
  client.print("Content-Length: ");
  client.println(data.length());
  client.println();
  client.print(data);
  No += 1;
 } else {
  Serial.println("not connected to steinhilber.eu");
 }
 if (client.connected()) {
  client.stop();
  Serial.println("disconnected");
 }
Â
 Ethernet.maintain();
Â
 delay(1000);
}
[CODE]
and here is PHP code in add.php file located on server
[CODE]
<?php
 echo '<p>Index : Lancement index</p>';
Â
 $server="steinhiltearmin.mysql.db";
 $user="steinhiltearmin";
 $pass="password";
 $db="steinhiltearmin";
  Â
  $temp1=$_POST["temp1"];
  $hum1=$_POST["hum1"];
  $connection = mysqli_connect($server, $user, $pass, $db);
  echo mysqli_connect_errno($connection);
  echo '<p>lancer querry</p>';
  mysqli_query($connection,"INSERT INTO `tempLog` (`temperature`, `humidity`) VALUES (".$temp1.",".$hum1.")");
  echo '<p>fin querry</p>';
  mysqli_close($connection);
   Â
  echo '<p>Index : sql terminee</p>';
 Â
?>
[CODE]