Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8013

Networking and servers • Re: Issue with connection between raspberry pi and esp32

$
0
0
And is this really your ESP32s address:

Code:

SERVER_IP = '192.168.0.1'
Quite often that is the home router address...


Note showing internal IP addresses is secure and they cannot be accessed from outside your network and by using correct addresses it helps diagnose network issues enormously. Could I also ask that you use the code tags (5th from left on the top bar) to keep indentations (vital in some languages):

Code:

import socketimport timedef send_data_to_server(server_ip, server_port, data):    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket:        client_socket.connect((server_ip, server_port))        client_socket.sendall(data.encode())        response = client_socket.recv(80)        print("Received from ESP32:", response.decode())if __name__ == "__main__":    SERVER_IP = '192.168.0.1' # Replace with your ESP32 IP address    SERVER_PORT = 80 # The port should match your ESP32 server's port    strings_to_send = ["t1", "t2", "t3", "t4", "t5", "t6", "r1"]    while True:        for data in strings_to_send:            print("Sending to ESP32:", data)            send_data_to_server(SERVER_IP, SERVER_PORT, data)            time.sleep(1) # Wait for a second before sending the next string
NOTE above is my guess at your indentation and may be wrong.

Statistics: Posted by MiscBits — Fri Mar 15, 2024 11:42 am



Viewing all articles
Browse latest Browse all 8013

Trending Articles