Hazrdous function of PHP POST
hello,
i try set home automation arduino.
local controlers arduino : ok
transfert of data main arduino controler ethernet shield i2c : ok
tcp serveur datadispath on local network : ok
creation of mysql database on website : ok
transfert of data main arduino controler database using php post : works every 2 5 times
to check use arduino programm sends post every second write in database counter value increased @ each write operation, check if lose messages, , loose 75%.
if use same php code in index.php , lauch webside, every update of website lign created in database if push update of webpage every second or faster.
so connection arduino seem haeardous
someone can me ?
my arduino code :
code: [select]
#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 local ip address:
serial.print("my ip address: ");
(byte thisbyte = 0; thisbyte < 4; thisbyte++) {
// print value of each byte of 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 server address
serial.println("connecte 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 steinhilber.eu");
}
if (client.connected()) {
client.stop();
serial.println("disconnected");
}
ethernet.maintain();
delay(1000);
}
[code]
and here 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]
try delay before disconnecting client.
look in server logs.
look in server logs.
Arduino Forum > Topics > Home Automation and Networked Objects > Hazrdous function of PHP POST
arduino
Comments
Post a Comment