[ESP32 아두이노] Arduino - TCP Client
ESPRESSIF2021. 1. 3. 18:56
Simple TCP/IP Client example based on Arduino
Reference :
WiFi.begin
www.arduino.cc/en/Reference/WiFiBegin
WiFiClient : WiFi Client class
www.arduino.cc/en/Reference/WiFiClient
client.connect(host, port)
www.arduino.cc/en/Reference/ClientConnect
client.print
www.arduino.cc/en/Reference/ClientPrint
client.stop
www.arduino.cc/en/Reference/ClientStop
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include <WiFi.h>
const char* ssid = "yourNetworkName";
const char* password = "yourNetworkPass";
const uint16_t port = 8090;
const char * host = "192.168.1.83";
void setup()
{
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("...");
}
Serial.print("WiFi connected with IP: ");
Serial.println(WiFi.localIP());
}
void loop()
{
WiFiClient client;
if (!client.connect(host, port)) {
Serial.println("Connection to host failed");
delay(1000);
return;
}
Serial.println("Connected to server successful!");
client.print("Hello from ESP32!");
Serial.println("Disconnecting...");
client.stop();
delay(10000);
}
cs |
WiFiClient
'ESPRESSIF' 카테고리의 다른 글
[ESP32] 의 AT command firmware Download 방법 (0) | 2021.01.04 |
---|---|
[ESP32] Linux Host for IP-Camera, ESP32 hosted mode (0) | 2021.01.04 |
ESP32 How to : JTAG, OpenOCD (0) | 2021.01.03 |
[ESP32] ESP-IDF 도스창 menuconfig 폰트 깨짐 문제 (0) | 2021.01.02 |
[ESP32, ESP8266] firmware download 가 안될 때 확인 사항 (0) | 2021.01.02 |