2017-06-24 3 views
-2

私はtweaking4all(https://www.tweaking4all.nl/hardware/arduino/arduino-ethernet-data-push/)からチュートリアルに従っていました 私はSQLデータベースをセットアップして、私がphpスクリプトを実行しているサイトを持っています。私は手動でこのような何か私のデータベースに来る変数を入力するときhttp://apollonian-jacket.000webhostapp.com/add_data.php?serial=288884820500006X&temperature=12.3うまく動作します。データがデータベースに挿入されます。今私は私のarduinoでこれをしようとしているが、それは動作しません。これは私のシリアルモニターarduinoからphp GETリクエスト

Tweaking4All.com - Temperature Drone - v2.0 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 

IP Address  : 192.168.0.199 
Subnet Mask  : 255.255.255.0 
Default Gateway IP: 192.168.0.1 
DNS Server IP  : 195.130.131.3 
-> Connected 
-> Connected 
-> Connected 
-> Connected 

に見えるものですが、私は私のデータベースに見たとき、私は何も変更

Arduinoのためのコードが表示されない:

#include <Ethernet.h> // Used for Ethernet 

// **** ETHERNET SETTING **** 
// Arduino Uno pins: 10 = CS, 11 = MOSI, 12 = MISO, 13 = SCK 
// Ethernet MAC address - must be unique on your network - MAC Reads T4A001 in hex (unique in your network) 
byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };          
// For the rest we use DHCP (IP address and such) 

EthernetClient client; 
char server[] = "www.apollonian-jacket.000webhostapp.com"; // IP Adres (or name) of server to dump data to 
int interval = 5000; // Wait between dumps 

void setup() { 

    Serial.begin(9600); 
    Ethernet.begin(mac); 

    Serial.println("Tweaking4All.com - Temperature Drone - v2.0"); 
    Serial.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"); 
    Serial.print("IP Address  : "); 
    Serial.println(Ethernet.localIP()); 
    Serial.print("Subnet Mask  : "); 
    Serial.println(Ethernet.subnetMask()); 
    Serial.print("Default Gateway IP: "); 
    Serial.println(Ethernet.gatewayIP()); 
    Serial.print("DNS Server IP  : "); 
    Serial.println(Ethernet.dnsServerIP()); 
} 

void loop() { 
    // if you get a connection, report back via serial: 
    if (client.connect(server, 80)) { 
    Serial.println("-> Connected"); 
    // Make a HTTP request: 
    client.print("GET /add_data.php?"); 
    client.print("serial="); 
    client.print("288884820500006X"); 
    client.print("&"); 
    client.print("temperature="); 
    client.print("12.3"); 
    client.println(" HTTP/1.1"); 
    client.print("Host: "); 
    client.println(server); 
    client.println("Connection: close"); 
    client.println(); 
    client.println(); 
    client.stop(); 
    } 
    else { 
    // you didn't get a connection to the server: 
    Serial.println("--> connection failed/n"); 
    } 

    delay(interval); 
} 

私がやりました研究はたくさんあるが、すべて正しいと思われる。前もって感謝します!

答えて

0

最初に気づいたのは、Ardunioコードで "www"サブドメインを使用していて、直接呼び出すときではないことです。 http://www.apollonian-jacket.000webhostapp.com/review_data.phpは機能していないようですので、wwwサブドメインが正しくマップされていないようです。

関連する問題