Answer the question
In order to leave comments, you need to log in
How to connect python tcp server and arduino tcp client?
python:
import socket
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM,)
server.bind(("192.168.1.11", 8000))
server.listen(1)
while True:
user_socket, address = server.accept()
user_socket.send("Hello User!".encode("utf-8"))
#include <UIPEthernet.h>
EthernetServer server = EthernetServer(8000);
void setup()
{
Serial.begin(9600);
// MAC адрес, должен быть уникальным в сети
uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
// IP адрес сервера, измените на адрес в своей подсети
IPAddress myIP(192,168,1,99);
Ethernet.begin(mac,myIP);
server.begin();
}
void loop()
{
size_t size;
if (EthernetClient client = server.available())
{
while((size = client.available()) > 0)
client.println("HELLO!!!!");
client.stop();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question