• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Connect two esp8266

Q&A Forum › Connect two esp8266
0 Vote Up Vote Down
Salvador Castelló asked 6 years ago
4 Answers
0 Vote Up Vote Down
DK answered 6 years ago

hi
Links
https://randomnerdtutorials.com/how-to-make-two-esp8266-talk/
https://www.instructables.com/id/WiFi-Communication-Between-Two-ESP8266-Based-MCU-T/
https://www.instructables.com/id/Accesspoint-Station-Communication-Between-Two-ESP8/
https://www.microcontroller-project.com/esp8266-inter-communication-using-arduino-ide.html
https://circuits4you.com/2018/01/01/esp-to-esp-communication/
 
videos
https://www.youtube.com/watch?v=gZhUi24_qms
Hope it helps
 
 
 
 

0 Vote Up Vote Down
Salvador Castelló answered 6 years ago

377/5000
Hi:

I want to make a simple connection with two esp8266 when the first is a client and the second is a server without using anything else.

I found a simple code to connect this but it does not run when assigning the socket, on the client, s = socket.socket (af, socktype, proto).

It doesn’t run when the server is an esp8266 but it runs if the server is my computer.

The code in the server is:
def conexion():
s=conecta()
count = 0
while True:
conn, addr = s.accept()
count = count + 1 
conn.send(b’HTTP/1.1 200 OK\n’)
conn.send(b’Content-Type: text/html\n’)
conn.send(b’Connection: close\n\n’) tx1 = “””<html><head> <meta name=”viewport” content=”width=device-width, initial-scale=1″> </head><body><h3>Conectado con dispositivo…</h3>”””+str(count) conn.sendall(tx1) conn.sendall(tx1) print(“Conectado {} veces”.format(count))
request = conn.recv(1024)
conn.close()
def conecta():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM,0)
s.bind((”, 80))
s.listen(5)
return s
def creared(): ap = network.WLAN(network.AP_IF) ap.active(True)
ap.config(essid=’RED1PR’, password=’12345678′)
if __name__ == “__main__”:
creared()
conexion()
The code client is:
def conecta(HOST):
PORT=80
for res in socket.getaddrinfo(HOST, PORT):
af, socktype, proto, canonname, sa = res
try:
s = socket.socket(af, socktype, proto) #—>>> NOT CONNECT
except OSError as msg:
print(‘Error de creacion Socket ‘,msg)
continue
try:
s.connect(sa)
return s
except OSError as msg:
s.close()
return s
def creared():
essid=’RED1PR’
password=’12345678′
station = network.WLAN(network.STA_IF)
station.active(True)
station.connect(essid, password)
while station.isconnected()==False:
continue
st=station.ifconfig()
return st[3]
if __name__ == “__main__”:
s=conecta(creared())

0 Vote Up Vote Down
DK answered 6 years ago

Hi
https://circuits4you.com/2018/01/01/esp-to-esp-communication/
 
is best
 

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

The best way to establish a two way communication between multiple ESP boards is using MQTT communication protocol. Have you considered that option?

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.