首页 > 解决方案 > 使用 W5100 shield 向 Web 服务器发送数据时出现问题

问题描述

我正在尝试使用带有 Arduino 的 W5100 扩展板将数据发送到 Web 服务器。但是由于某种原因,当我尝试发送时遇到了这个问题,这似乎是一个 HTTP 错误。我正在编辑,所以你也可以看到我的 Arduino 代码,也许它有帮助。我希望我能够发送这些数据,我尝试将 HTTP/1.0 更改为 HTTP/1.1 但没有成功。

问题:

Connected to network, your ip: 192.168.100.00 


Connecting to the server and sending data:
Sensor 1 = 7.00
Sensor 2 = 9.00
Sensor 3 = 89.00


HTTP/1.1 302 Found
Date: Wed, 16 Oct 2019 18:47:20 GMT
Server: Apache
Location: https://mywebsite.com.br/conexao.php?s1=7.00&s2=9.00&s3=89.00
Content-Length: 317
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://mywebsite/conexao.php?s1=7.00&amp;s2=9.00&amp;s3=89.00">here</a>.</p>
<hr>
<address>Apache Server at mywebsite.com.br Port 80</address>
</body></html>

这是Arduino代码

 if (ArduinoClient.available())
  {
    char dadosretornados = ArduinoClient.read();
    Serial.print(dadosretornados);
  }
  if (!ArduinoClient.connected())
  {
    ArduinoClient.stop();
  }

  char comando = Serial.read();

  if (comando == '1')
  {
    //====================================================== ENFEITE ============================================================================================================
    Serial.println("\n");
    Serial.println("Conectando ao servidor e enviando dados: ");
    delay(500); //Delay apenas de enfeite
    Serial.print("Sensor 1 = ");
    Serial.println(sensor1);
    Serial.print("Sensor 2 = ");
    Serial.println(sensor2);
    Serial.print("Sensor 3 = ");
    Serial.println(sensor3);
    delay(1000); //Delay apenas de enfeite
    Serial.println("\n");
    //===========================================================================================================================================================================

    if (ArduinoClient.connect(servidor, 80))
    {
      //Sucesso ao conectar
      //ArduinoClient.println("GET /conexao.php HTTP/1.0");   // Podemos trocar para HTTP/1.1 se der algum problema
      ArduinoClient.print("GET /conexao.php?");
      ArduinoClient.print("s1=");
      ArduinoClient.print(sensor1);
      ArduinoClient.print("&s2=");
      ArduinoClient.print(sensor2);
      ArduinoClient.print("&s3=");
      ArduinoClient.print(sensor3);
      ArduinoClient.println(" HTTP/1.0");

      ArduinoClient.println("Host: mywebsite.com.br"); 
      ArduinoClient.println("Connection: close"); 
      ArduinoClient.println();         
    }
    else 
    {

标签: phphtmlwebserverethernet

解决方案


推荐阅读