Communication Between Two 8266's Without WiFi Router/AP?
Posted:
Mon Aug 31, 2015 12:25 pm
by jmd13391
Hi All, Newbie 8266 user here seeking some assistance… My project consists of two 8266’s running the latest NodeMCU firmware (0.9.6 dev). I am trying to turn-on a LED on 8266 #2 GPIO #4 when GPIO #4 of 8266 #1 goes high.Simple, right? LOL — Challenge with this project is I do not have an external WiFi AP or Internet connection available. I was looking into placing 8266 #1 in STATIONAP mode and 8266 #2 in STATION mode but there doesn’t seem to be a way for the station component of an 8266 in STATIONAP mode to connect to the AP component (i.e. connect to itself). I now find myself a bit confused about how to accomplish this rather simple communication with only two 8266’s. I am now thinking that I may need at least three 8266’s (1 in SOFTAP mode and the other two in STATION mode). Any input about this issue would be greatly appreciated. Thank you in advance, -JoeD
Re: Communication Between Two 8266's Without WiFi Router/AP?
Posted:
Mon Aug 31, 2015 12:45 pm
by martinayotte
why do you need the STA+AP connect to itself ?
Re: Communication Between Two 8266's Without WiFi Router/AP?
Posted:
Mon Aug 31, 2015 5:52 pm
by jmd13391
Hi Martin, Well, maybe "connect to itself" was a bad choice of words... Let's try this (stop me when I stray off path)... I am assuming that both modules will need to acquire an IP via DHCP from an AP. Since I do not have an existing AP, one of the modules (#1 for example) will need to be both an AP and a STATION (because both modules will be sending and receiving data). Based on reading the sparse documentation, If I put module #1 in SOFTAP mode, it can only be an AP and cannot send/receive data streams. If I place module #1 in STATION mode, I can send/receive data streams but not provide AP services like DHCP. How does one get two 8266's to join a network created by one of the modules and have both be able to send and receive data to each other? Eventually, the project calls for one 8266 module to be the "control module" (the one that provides AP functions and has the GPIO input pin) and multiple "remote modules" that listen for the state change from the CM and responds with an ACK back to the CM to confirm receipt / heartbeat. Initially, I am keeping it simple with a CM and a single RM. I guess this would be a lot easier if the NodeMCU documentation and examples were a tad better. Again, thank you for your assistance. It is greatly appreciated. -JoeD
Re: Communication Between Two 8266's Without WiFi Router/AP?
Posted:
Mon Aug 31, 2015 6:16 pm
by martinayotte
Only the STA needs to get an IP via DHCP, the STA+AP has already it AP IP as 192.168.4.1.
This way the STA can connect to AP and AP can connect to STA without having having to "connect to itself" only to get an IP which is useless anyway, since the AP cannot route packets between STAs.
If you are using Arduino IDE, I've done some example more than a month ago for this scenario for which I've provides to ZIP files, one is the MyAPServer and the other MyAPClient (for the STA).
viewtopic.php?f=27&t=4080#p23577viewtopic.php?f=8&t=4502&p=25965&hilit=MyAPServer#p25965viewtopic.php?f=12&t=4770&p=27361&hilit=MyAPServer#p27361