ESP8266 01 model server ardinuio kodları

Paylaş.

#include <ESP8266WiFi.h>

#include <WiFiClient.h>

#include <ESP8266WebServer.h>

//#include <OneWire.h>

//#include <DallasTemperature.h>

//#include <Math.h>

//#include <Streaming.h>

 

const char* ssid     = “WifiSSID_adi”;

const char* password = “wifi_sifrem”;

 

 

 

//IPAddress ip(192,168,0,113);

//IPAddress gateway(192,168,0,1);

//IPAddress subnet(255,255,255,0);

 

ESP8266WebServer server(80);

 

int in_temp;

int out_temp;

int len_str;

String webString = “”;

String in_temp_str, out_temp_str;

String sign_in, sign_out;

 

//unsigned long previousMillis = 0;

//const long interval = 2000;

 

void handle_root() {

server.send(200, “text/plain”, “Selam esp8266 BURHAN KARADERE “);

delay(100);

}

 

void setup(void)

{

pinMode(0, OUTPUT); //

pinMode(2, OUTPUT); //

pinMode(14, OUTPUT); //

Serial.begin(115200);

// Connect to WiFi network

WiFi.softAP(ssid, password, 1, 1); // gizle

WiFi.begin(ssid, password);

//WiFi.config(ip, gateway, subnet);

 

 

Serial.print(“\n\r \n\rWorking to connect”);

 

// Wait for connection

while (WiFi.status() != WL_CONNECTED) {

delay(500);

Serial.print(“.”);

}

Serial.println(“”);

Serial.print(“Connected to “);

Serial.println(ssid);

Serial.print(“IP address: “);

Serial.println(WiFi.localIP());

 

server.on(“/”, handle_root);

 

server.on(“/gpio0_true”, []() {

webString = “GPIO 0 ON”;

digitalWrite(0, HIGH);

server.send(200, “text/plain”, webString);

});

 

server.on(“/gpio0_false”, []() {

webString = “GPIO 0 OFF”;

digitalWrite(0, LOW);

server.send(200, “text/plain”, webString);

});

 

server.on(“/gpio2_true”, []() {

webString = “GPIO 2 ON”;

digitalWrite(2, HIGH);

server.send(200, “text/plain”, webString);

});

 

server.on(“/gpio2_false”, []() {

webString = “GPIO 2 OFF”;

digitalWrite(2, LOW);

server.send(200, “text/plain”, webString);

});

 

server.on(“/gpio14_true”, []() {

webString = “GPIO 14 ON”;

digitalWrite(14, HIGH);

server.send(200, “text/plain”, webString);

});

 

server.on(“/gpio14_false”, []() {

webString = “GPIO 14 OFF”;

digitalWrite(14, LOW);

server.send(200, “text/plain”, webString);

});

 

 

/*

server.on(“/json”, [](){  // if you add this subdirectory to your webserver call, you get text below 🙂

//  gettemperature();           // read sensor

webString=”havadurumu:[{isi:””26″”,nem:””50″”}]”;//+String((int)humidity)+”%”;

server.send(200, “text/plain”, webString);               // send to someones browser when asked

});

*/

server.begin();

Serial.println(“HTTP server started”);

}

 

void loop(void)

{  server.handleClient();

}

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)