What's new

NODEMCU ESP8266

Deyb_pransya

Addict
Established
Joined
Apr 4, 2018
Posts
31
Reaction
3
Points
73
Baka may alam kayo paano maaaccess ng internet yung webserver o web controller ng NodeMcu
 
  1. Set up your NodeMcu and write code to make it a web server.
  2. Connect NodeMcu to Wi-Fi.
  3. Optionally, if you want to access it from the internet, set up port forwarding on your router.
  4. Access the web server using the NodeMcu's IP address in a web browser on a device connected to the same network.


C++:
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

const char *ssid = "your-ssid";
const char *password = "your-password";

ESP8266WebServer server(80);

void setup() {
  Serial.begin(115200);

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(250);
    Serial.print(".");
  }
  Serial.println("");

  Serial.println("WiFi connected");
  Serial.println("IP address: " + WiFi.localIP().toString());

  // Define route handlers
  server.on("/", HTTP_GET, handleRoot);

  // Start server
  server.begin();
}

void loop() {
  server.handleClient();
}

void handleRoot() {
  server.send(200, "text/plain", "Hello from NodeMcu!");
}
 

Similar threads

Back
Top