php - 使用 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&s2=9.00&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
{
解决方案
推荐阅读
- linux - Zenity:如何创建用户并更改其密码?
- swift - UNUserNotifications 方法“requestAuthorization”在 macOS Catalyst 上不显示对话
- reactjs - 我的 GIF 没有显示在子组件中
- javascript - 如何每次在 JavaScript 中创建新的唯一 ID?
- javascript - 使用基于 jQuery 的功能列名称在 HTML ajax 响应中创建表?
- python - 将元组添加到另一个元组时出现类型错误
- swift - 如何更改 cocoapods 文件?
- perl - 轮询不断更新的文本文件以剪切选定的信息
- sql - 在制药行业中搜索药物名称,在冗长的药物名称中从每个单词中提取几个字符
- wordpress - woocommerce 在结帐页面上获取“billing_phone”字段