ESP32S3通过W5500以太网模块发送数据,并进行简单测速实验。
utilities.h文件中的需要打开17行的注释:LILYGO_T_ETH_LITE_ESP32S3。需要跟你你自己的主机的ip地址修改程序。硬件:ESP32S3和W5500。我这里使用jperf进行简单测速。目录下的TCPClient程序。打开TCP Server。
·
硬件:ESP32S3和W5500
连线按照上述的硬件连接
程序:参考的GitHub - Xinyuan-LilyGO/LilyGO-T-ETH-Series目录下的TCPClient程序
utilities.h文件中的需要打开17行的注释:LILYGO_T_ETH_LITE_ESP32S3
/**
* @file TCPClient.ino
* @author Lewis He (lewishe@outlook.com)
* @license MIT
* @copyright Copyright (c) 2023 Shenzhen Xin Yuan Electronic Technology Co., Ltd
* @date 2023-06-08
*
*/
#include <Arduino.h>
#if ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3,0,0)
#include <ETHClass2.h> //Is to use the modified ETHClass
#define ETH ETH2
#else
#include <ETH.h>
#endif
#include "utilities.h" //Board PinMap
#include <WiFi.h>
// Connect to the server's IP
const char *host = "192.168.165.105";
// Connect to the server's Port
const int httpPort = 8888;
WiFiClient client;
static bool eth_connected = false;
uint32_t sendMillis = 0;
void WiFiEvent(arduino_event_id_t event)
{
switch (event) {
case ARDUINO_EVENT_ETH_START:
Serial.println("ETH Started");
//set eth hostname here
ETH.setHostname("esp32-ethernet");
break;
case ARDUINO_EVENT_ETH_CONNECTED:
Serial.println("ETH Connected");
break;
case ARDUINO_EVENT_ETH_GOT_IP:
Serial.print("ETH MAC: ");
Serial.print(ETH.macAddress());
Serial.print(", IPv4: ");
Serial.print(ETH.localIP());
if (ETH.fullDuplex()) {
Serial.print(", FULL_DUPLEX");
}
Serial.print(", ");
Serial.print(ETH.linkSpeed());
Serial.println("Mbps");
eth_connected = true;
break;
case ARDUINO_EVENT_ETH_DISCONNECTED:
Serial.println("ETH Disconnected");
eth_connected = false;
break;
case ARDUINO_EVENT_ETH_STOP:
Serial.println("ETH Stopped");
eth_connected = false;
break;
default:
break;
}
}
void setup()
{
Serial.begin(115200);
#ifdef ETH_POWER_PIN
pinMode(ETH_POWER_PIN, OUTPUT);
digitalWrite(ETH_POWER_PIN, HIGH);
#endif
#if CONFIG_IDF_TARGET_ESP32
if (!ETH.begin(ETH_TYPE, ETH_ADDR, ETH_MDC_PIN,
ETH_MDIO_PIN, ETH_RESET_PIN, ETH_CLK_MODE)) {
Serial.println("ETH start Failed!");
}
#else
if (!ETH.begin(ETH_PHY_W5500, 1, ETH_CS_PIN, ETH_INT_PIN, ETH_RST_PIN,
SPI3_HOST,
ETH_SCLK_PIN, ETH_MISO_PIN, ETH_MOSI_PIN)) {
Serial.println("ETH start Failed!");
}
#endif
Serial.println("Connect to server..");
while (!client.connect(host, httpPort)) {
Serial.print("."); delay(500);
}
Serial.println();
Serial.println("Server connected!");
}
byte buf[1024];
void loop()
{
if (!client.connected()) {
Serial.println("Connect to server..");
while (!client.connect(host, httpPort)) {
Serial.print("."); delay(500);
}
Serial.println();
Serial.println("Server connected!");
}
// // Listen for returned messages
// while (client.available()) {
// // client.write(client.read());
// // if (client.available()) client.read(buf, 1024);
// client.println('a');
// }
while (client.connected()) {
client.println("12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
}
// Timestamp sent every second
// if (sendMillis < millis()) {
// client.print("->");
// client.println(millis() / 1000);
// sendMillis = millis() + 1000;
// }
}
#pragma once
// Product Link : https://www.lilygo.cc/products/t-internet-poe
// #define LILYGO_T_INTERNET_POE
// Product Link : https://www.lilygo.cc/products/t-poe-pro
// #define LILYGO_T_ETH_POE_PRO
// Product Link : https://www.lilygo.cc/products/t-internet-com
// #define LILYGO_T_INTER_COM
// Product Link : https://www.lilygo.cc/products/t-eth-lite?variant=43120880746677
// #define LILYGO_T_ETH_LITE_ESP32
// Product Link : https://www.lilygo.cc/products/t-eth-lite?variant=43120880779445
#define LILYGO_T_ETH_LITE_ESP32S3
// Product Link : N.A
// #define LILYGO_T_ETH_ELITE_ESP32S3
#if defined(LILYGO_T_INTERNET_POE)
#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
#define ETH_ADDR 0
#define ETH_TYPE ETH_PHY_LAN8720
#define ETH_RESET_PIN 5
#define ETH_MDC_PIN 23
#define ETH_MDIO_PIN 18
#define SD_MISO_PIN 2
#define SD_MOSI_PIN 15
#define SD_SCLK_PIN 14
#define SD_CS_PIN 13
#elif defined(LILYGO_T_ETH_POE_PRO)
#define ETH_TYPE ETH_PHY_LAN8720
#define ETH_ADDR 0
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_OUT
#define ETH_RESET_PIN 5
#define ETH_MDC_PIN 23
#define ETH_MDIO_PIN 18
#define SD_MISO_PIN 12
#define SD_MOSI_PIN 13
#define SD_SCLK_PIN 14
#define SD_CS_PIN 15
#define TFT_DC 2
#define RS485_TX 32
#define RS485_RX 33
#elif defined(LILYGO_T_INTER_COM)
#define ETH_TYPE ETH_PHY_LAN8720
#define ETH_ADDR 0
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_OUT
#define ETH_RESET_PIN 4
#define ETH_MDC_PIN 23
#define ETH_MDIO_PIN 18
#define SD_MISO_PIN 2
#define SD_MOSI_PIN 15
#define SD_SCLK_PIN 14
#define SD_CS_PIN 13
#define MODEM_RX_PIN 35
#define MODEM_TX_PIN 33
#define MODEM_PWRKEY_PIN 32
#define RGBLED_PIN 12
#elif defined(LILYGO_T_ETH_LITE_ESP32)
#define ETH_TYPE ETH_PHY_RTL8201
#define ETH_ADDR 0
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_IN
#define ETH_RESET_PIN -1
#define ETH_MDC_PIN 23
#define ETH_POWER_PIN 12
#define ETH_MDIO_PIN 18
#define SD_MISO_PIN 34
#define SD_MOSI_PIN 13
#define SD_SCLK_PIN 14
#define SD_CS_PIN 5
#elif defined(LILYGO_T_ETH_LITE_ESP32S3)
#define ETH_MISO_PIN 11
#define ETH_MOSI_PIN 12
#define ETH_SCLK_PIN 10
#define ETH_CS_PIN 9
#define ETH_INT_PIN 13
#define ETH_RST_PIN 14
#define ETH_ADDR 1
#define SD_MISO_PIN 5
#define SD_MOSI_PIN 6
#define SD_SCLK_PIN 7
#define SD_CS_PIN 42
#define IR_FILTER_NUM 46
#elif defined(LILYGO_T_ETH_ELITE_ESP32S3)
#define ETH_MISO_PIN 47
#define ETH_MOSI_PIN 21
#define ETH_SCLK_PIN 48
#define ETH_CS_PIN 45
#define ETH_INT_PIN 14
#define ETH_RST_PIN -1
#define ETH_ADDR 1
#define SPI_MISO_PIN 9
#define SPI_MOSI_PIN 11
#define SPI_SCLK_PIN 10
#define SD_MISO_PIN SPI_MISO_PIN
#define SD_MOSI_PIN SPI_MOSI_PIN
#define SD_SCLK_PIN SPI_SCLK_PIN
#define SD_CS_PIN 12
#define I2C_SDA_PIN 17
#define I2C_SCL_PIN 18
#define RADIO_MISO_PIN SPI_MISO_PIN
#define RADIO_MOSI_PIN SPI_MOSI_PIN
#define RADIO_SCLK_PIN SPI_SCLK_PIN
#define RADIO_CS_PIN 40
#define RADIO_RST_PIN 46
// #define RADIO_DIO1_PIN 16
#define RADIO_IRQ_PIN 8
#define RADIO_BUSY_PIN 16
#define ADC_BUTTONS_PIN 7
#define MODEM_RX_PIN 4
#define MODEM_TX_PIN 6
#define MODEM_DTR_PIN 5
#define MODEM_RI_PIN 1
#define MODEM_PWRKEY_PIN 3
#define GPS_RX_PIN 39
#define GPS_TX_PIN 42
#define LED_PIN 38
#else
#error "Use ArduinoIDE, please open the macro definition corresponding to the board above <utilities.h>"
#endif
需要跟你你自己的主机的ip地址修改程序
打开TCP Server。
我这里使用jperf进行简单测速

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐
所有评论(0)