showing results for - "nodemcu router code"
Manuel
23 Sep 2018
1#include <ESP8266WiFi.h>
2
3const char* ssid = "******"; 
4const char* password = "******";
5
6IPAddress staticIP(192,168,1,22); 
7IPAddress gateway(192,168,1,9); 
8IPAddress subnet (255,255,255,0);
9
10void setup(void) {
11    Serial.begin(9600); 
12    Serial.println();
13
14    Serial.printf("Connecting to Xs \n", ssid); 
15    WiFi.begin(ssid, password); 
16    WiFi.config(staticIP, gateway, subnet);
17
18    while (WiFi.status() != WL_CONNECTED) {
19        delay(500); 
20        Serial.print("."); 
21    }
22
23    Serial.println();
24    Serial.print("Connected, IP address: "); 
25    Serial.println(WiFi.localIP());
26}
27void loop() {}
Ana Paula
04 Apr 2017
1#include <ESP8266WiFi.h>        // Include the Wi-Fi library
2
3const char* ssid     = "SSID";         // The SSID (name) of the Wi-Fi network you want to connect to
4const char* password = "PASSWORD";     // The password of the Wi-Fi network
5
6void setup() {
7  Serial.begin(115200);         // Start the Serial communication to send messages to the computer
8  delay(10);
9  Serial.println('\n');
10  
11  WiFi.begin(ssid, password);             // Connect to the network
12  Serial.print("Connecting to ");
13  Serial.print(ssid); Serial.println(" ...");
14
15  int i = 0;
16  while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
17    delay(1000);
18    Serial.print(++i); Serial.print(' ');
19  }
20
21  Serial.println('\n');
22  Serial.println("Connection established!");  
23  Serial.print("IP address:\t");
24  Serial.println(WiFi.localIP());         // Send the IP address of the ESP8266 to the computer
25}
26
27void loop() { }
28