php -> arduino communication

float target


<?php //데이터베이스 연결 $connect = mysql_connect("localhost","root","***********8"); //데이터베이스 선택 $db_con=mysql_select_db("arduino",$connect); //DB에 데이터 입력 $sql = "SELECT * FROM `targetTemp`"; $result = mysql_query($sql,$connect); $records = mysql_num_rows($result); // mysql_num_rows 인자의 레코드 개수를 알려준다 $fields=mysql_num_fields($result); // mysql_num_fields인자의 필드개수를 알려준다 $number=1; ?>

Target Temperature

<?php for($i =0; $i < $records; $i++){ echo""; echo""; for($j=0; $j< $fields; $j++){ $data = mysql_result ($result, $i, $j); // 레코드위 특정위치에 저장된 값을 가져온다 echo ""; } echo""; $number++; } ?>

php code

#include <ESP8266WiFi.h>
#include <SPI.h>
char ssid = "hdh"; // your network SSID (name)
char pass = "
"; // your network password
//int status = WL_IDLE_STATUS;
WiFiClient client;
char server = "
******";
float targetTemp;
void setup() {
Serial.begin(115200);

Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, pass);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

// Starting the web server

Serial.println("Web server running. Waiting for the ESP IP...");
delay(5000);

// Printing the ESP IP address
Serial.println(WiFi.localIP());
delay(5000); // GIVE THE SENSOR SOME TIME TO START
}
void loop()
{

if (client.connect(server,80)) { // REPLACE WITH YOUR SERVER ADDRESS
Serial.println("connected");
client.print("GET /target1.php?");
// client.print("target=");
// client.println(targetTemp);
client.print("HTTP/1.1");
client.println("Host: ****************");
client.println("Content-Type: application/x-www-form-urlencoded" );
client.println("Connection: close");
client.println();
delay(2000);
}

if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
while(true);
}
}

arduio code

Access to php is possible. Through WiFi communication, I'm trying to place the target of php in the aduino targetTemp. On the serial monitor, it appears that the ASCII code 'H '.
I hope that 26.5(target) of php will be delivered to aduino. help me!

number target
$number $data

php code

#include <ESP8266WiFi.h>

The code that follows that line is NOT php code.

ALL code belongs in code tags.

  if (client.available()) {
    char c = client.read();

If the server generated a response, read the first character, and print it. Then, let that one character go out of scope. Hardly seems a useful thing to do. Use the example that came with the library, changing ONLY the server and network credentials, until you understand what it is doing.