• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
wysylanie danych na serwer
#1
witam jestem poczatkujacym uzytkownikem arduino. \dysponuje płytka leonardo eth.
Zainstalowalem czujnik temperaturu i wilgotnosci. Teraz chcialbym te dane przeslac na serwer zewnetrzny. Przygotowalem baze mysql oraz skrypt php pokazujacy i wstawiajacy dane to tabeli przy pomocy GET.
Kod:
http://pogodynka.abcflex.eu/add1.php?temp1=15&hum=15
mam narazie dwie zmienne. i to działa
napisalem wysyslanie na serwer ale gdzies mam błąd i nie działa i nie mogę namierzyc co jest zle.
wyglada to tak:
Kod:
#include <SPI.h>
#include <Ethernet2.h>
byte mac[] = {
 0x90, 0xA2, 0xDA, 0x10, 0xE0, 0xD0 };

// Enter the IP address for Arduino, as mentioned we will use 192.168.0.16
// Be careful to use , insetead of . when you enter the address here
IPAddress ip(192,168,0,35);

char server[] = "pogodynka.abcflex.eu";

EthernetClient client;

void setup() {

 // Serial.begin starts the serial connection between computer and Arduino
 Serial.begin(9600);

 // start the Ethernet connection
 Ethernet.begin(mac, ip);

 Serial.begin(115200);                    //inicjalizacja monitora szeregowego
 Serial.println("test pogodynki ");
 Serial.println();    
}

void loop() {

 // Connect to the server (your computer or web page)  
 if (client.connect(server, 80)) {
   client.print("GET /add1.php?"); // This
   client.print("temp1="); // This
   client.print("aa"); // And this is what we did in the testing section above. We are making a GET request just like we would from our browser but now with live data from the sensor
   client.println(" HTTP/1.1"); // Part of the GET request
   client.println("Host: pogodynka.abcflex.eu"); // IMPORTANT: If you are using XAMPP you will have to find out the IP address of your computer and put it here (it is explained in previous article). If you have a web page, enter its address (ie.Host: "www.yourwebpage.com")
   client.println("Connection: close"); // Part of the GET request telling the server that we are over transmitting the message
   client.println(); // Empty line
   client.println(); // Empty line
   client.stop();    // Closing connection to server
 
 Serial.print(server);
 }

 else {
   // If Arduino can't connect to the server (your computer or web page)
   Serial.println("--> connection failed\n");
 }

 // Give the server some time to recieve the data and store it. I used 10 seconds here. Be advised when delaying. If u use a short delay, the server might not capture data because of Arduino transmitting new data too soon.
 delay(1000);
}

Sprawdzalem logi servera i nie ma zadnej informaci i tym ze plytka sie komunikuje z serwerem. ip arduino dziala porawnie. wykrywane w sieci lan.
Bardzo prosze o wskazanie bledu lub jakies wskazowki.
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości