如何使用ENC28J60从Ardunio Nano发送数据到PHP

问题描述

我正在尝试从与ENC28J60模块连接的Arduino Nano发送传感器数据以进行以太网连接,Nano从路由器获取IP地址没有任何问题,但是当我想将数据发送至PHP页面时,它没有工作!

我尝试了Postman中的链接并工作,但在Arduino Nano中不起作用:

我的代码

#include <UIPEthernet.h>
#include <ArduinoHttpClient.h>
#include "utility/logging.h"
EthernetClient client;
unsigned long next;
char serverAddress[] = "test.tech";  // server address
int port = 8080;

void setup() {
  Serial.begin(115200);
  uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
//  Ethernet.init(3); Serial.println("cs pin");
 Ethernet.begin(mac);

  Serial.println("Initiliazed");
  Serial.print(("localIP: "));
  Serial.println(Ethernet.localIP());
  Serial.print(("subnetMask: "));
  Serial.println(Ethernet.subnetMask());
  Serial.print(("gatewayIP: "));
  Serial.println(Ethernet.gatewayIP());
  Serial.print(("dnsServerIP: "));
  Serial.println(Ethernet.dnsServerIP());
  next = 0;
 

}
HttpClient client1 = HttpClient(client,serverAddress,port);
void loop()
{
  Serial.println("making GET request");
  client1.get("/Sensor/insert.PHP?temp=20&time=2020-08-10 19:58:46&Date=2020-08-10&Clock=19:58:46");
  int statusCode = client1.responseStatusCode();
  String response = client1.responseBody();
  Serial.print("Status code: ");
  Serial.println(statusCode);
  Serial.print("Response: ");
  Serial.println(response);
  Serial.println("Wait five seconds");
  delay(5000);
}

解决方法

感谢所有人:

此代码可以使用ENC28J60与我一起使用,并且我可以将数据发送到PHP服务器,希望希望有人会发现它有用:

&Reader{}