Lier esp 8266 avec protocole i2c + bootstrap


#1

salut, et merci pour m’aider
je veux ajouter a ce code la laibrerie WIRE.H pour qu ’ il soit a marche avec le protocole i2c .
et a la fin lorsque je clique boutton ON il envoie numero 1 et je clique botton OFF il envoie numero 2
et en basant sur deux sorties (sdl , scl)
voici le code master
https://www.mediafire.com/file/b843pvy3s13lij4/code_master.txt/file


#2

#include <ESP8266WiFi.h>

#include <WiFiClient.h>

#include <ESP8266WebServer.h>

#include <ESP8266mDNS.h>

const char* ssid = “your ssid”;

const char* password = “your password”;

int led = 2;

int value = LOW;

WiFiServer server(80);

void setup(){

Serial.begin(115200);

delay(10);

pinMode(led, OUTPUT);

digitalWrite(led, LOW);

Serial.println();

Serial.println();

Serial.print("Connecting to ");

Serial.println(ssid);

WiFi.begin(ssid, password);

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

delay(500);

Serial.print(".");

}

Serial.println("");

Serial.println(“WiFi connected”);

server.begin();

Serial.println(“Server started”);

Serial.print("Use this URL to connect: ");

Serial.print(“http://”);

Serial.print(WiFi.localIP());

Serial.println("/");

}

void loop() {

WiFiClient client = server.available();

if (!client) {

return;

}

Serial.println(“new client”);

client.println(“HTTP/1.1 200 OK”);

client.println(“Content-Type: text/html”);

client.println("");

client.println("");

client.println("");

client.println("");

client.println(“First Project”);

client.println("<meta charset=“utf-8”>");

client.println("<meta name=“viewport” content=“width=device-width, initial-scale=1”>");

client.println("<link rel=“stylesheet” href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">");

client.println("<script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”>");

client.println("<script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”>");

client.println("");

client.println("");

client.println("<div class=“container”>");

client.print(“

ESP8266 Web Server

”);

client.print("<p class=“text-danger”>on-off Button:

");

client.print("<a href="/LED=ON" class=“btn btn-success” role=“button”>ON");

client.print("<a href="/LED=OFF" class=“btn btn-danger” role=“button”>OFF");

client.print("

");

client.println("Led pin is now: ");

if(value == HIGH) {

client.print(“On”);

}

else {

client.print(“Off”);

}

client.println("");

client.println("");

client.println("");

while(!client.available()){

delay(1);

}

String request = client.readStringUntil(’\r’);

Serial.println(request);

client.flush();

if (request.indexOf(’/LED=ON’) != -1) {

digitalWrite(led, HIGH);

value = HIGH;

}

if (request.indexOf(’/LED=OFF’) != -1) {

digitalWrite(led, LOW);

value = LOW;

}

delay(1);

Serial.println(“Client disonnected”);

Serial.println("");

}