Google sheets + совместить код

Sem553

✩✩✩✩✩✩✩
10 Янв 2021
91
8
Здравствуйте, есть код который работает
C++:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

#include <OneWire.h>
#include <DallasTemperature.h>

#include <SimpleDHT.h>

#define ONE_WIRE_BUS 15

//набор переменных для подсчета uptime
long secs, mins;
int hours, days;

int pinDHT11 = 13;
SimpleDHT11 dht11;

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

MDNSResponder mdns;

// Wi-Fi
const char* ssid = "";
const char* password = "";

byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress ip(192,168,4,35);
IPAddress gateway(192,168,4,1);
IPAddress subnet(255,255,255,0);

ESP8266WebServer server(80);

int D0_pin = 16;
int D2_pin = 2;//d4
int D1_pin = 5;


void setup(void){
  // preparing GPIOs
  pinMode(D0_pin, OUTPUT);
  digitalWrite(D0_pin, LOW);
  pinMode(D2_pin, OUTPUT);
  digitalWrite(D2_pin, LOW);
  pinMode(D1_pin, OUTPUT);
  digitalWrite(D1_pin, LOW);

  sensors.begin();

  delay(100);
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  WiFi.config(ip, gateway, subnet);


  Serial.println("");

  // 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());

  if (mdns.begin("esp8266", WiFi.localIP())) {
    Serial.println("MDNS responder started");
  }

  //+++++++++++++++++++++++ START  LED-1 ++++++++++++++++++++
  server.on("/", [](){
    server.send(200, "text/html", webPage());
  });
  server.on("/socket1On", [](){
    digitalWrite(D0_pin, HIGH);
    server.send(200, "text/html", webPage());
    delay(100);
   
  });
  server.on("/socket1Off", [](){
    digitalWrite(D0_pin, LOW);
    server.send(200, "text/html", webPage());
    delay(100);
});  
   //+++++++++++++++++++++++ END  LED-1 ++++++++++++++++++++
   
   //+++++++++++++++++++++++ START  LED-2  ++++++++++++++++++++

  server.on("/socket2On", [](){
    digitalWrite(D2_pin, HIGH);
    server.send(200, "text/html", webPage());
    delay(100);  
  });
  server.on("/socket2Off", [](){
    digitalWrite(D2_pin, LOW);
    server.send(200, "text/html", webPage());
    delay(100);
    });
   // +++++++++++++++++++++++ END  LED-2 ++++++++++++++++++++
 
   //+++++++++++++++++++++++ START  LED-3  ++++++++++++++++++++

  server.on("/socket3On", [](){
    digitalWrite(D1_pin, HIGH);
    server.send(200, "text/html", webPage());
    delay(100);  
  });
  server.on("/socket3Off", [](){
    digitalWrite(D1_pin, LOW);
    server.send(200, "text/html", webPage());
    delay(100);
   });
   // +++++++++++++++++++++++ END  LED-3 ++++++++++++++++++++
   
   

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void){
  server.handleClient();
    //########### Пересчет millis для uptime ###############
  secs = millis() / 1000;
  mins = secs / 60;
  hours = mins / 60;
  days = hours / 24;
  secs -= mins * 60;
  mins -= hours * 60;
  hours -= days * 24;
  //######################################################
}

String webPage()
{
  sensors.requestTemperatures();
  byte temperature = 0;
  byte humidity = 0;
  dht11.read(pinDHT11, &temperature, &humidity, NULL);
  String web;
  web += "<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/> <meta charset=\"utf-8\"><title>ESP 8266</title><style>button{color:red;padding: 10px 27px;}</style></head>";
  web += "<h1 style=\"text-align: center;font-family: Open sans;font-weight: 100;font-size: 20px;\">ESP8266 Web Server</h1><div>";
    web += "<p style=\"text-align: left;margin-top: 0px;margin-bottom: 5px;\">UPTIME:  " + String(days) + " дней " + String(hours) + " час. " + String(mins) + " мин. " + String(secs) + " сек. </p>";
  //++++++++++ LED-1  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----LED 1----</p>";
  if (digitalRead(D0_pin) == 1)
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #43a209;margin: 0 auto;\">ON</div>";
  }
  else
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #ec1212;margin: 0 auto;\">OFF</div>";
  }
  web += "<div style=\"text-align: center;margin: 5px 0px;\"> <a href=\"socket1On\"><button>ON</button></a>&nbsp;<a href=\"socket1Off\"><button>OFF</button></a></div>";
  // ++++++++ LED-1 +++++++++++++

  //++++++++++ LED-2  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----LED 2----</p>";
  if (digitalRead(D2_pin) == 1)
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #43a209;margin: 0 auto;\">ON</div>";
  }
  else
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #ec1212;margin: 0 auto;\">OFF</div>";
  }
  web += "<div style=\"text-align: center;margin: 5px 0px;\"> <a href=\"socket2On\"><button>ON</button></a>&nbsp;<a href=\"socket2Off\"><button>OFF</button></a></div>";
  // ++++++++ LED-2 +++++++++++++

  //++++++++++ LED-3  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----LED 3----</p>";
  if (digitalRead(D1_pin) == 1)
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #43a209;margin: 0 auto;\">ON</div>";
  }
  else
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #ec1212;margin: 0 auto;\">OFF</div>";
  }
  web += "<div style=\"text-align: center;margin: 5px 0px;\"> <a href=\"socket3On\"><button>ON</button></a>&nbsp;<a href=\"socket3Off\"><button>OFF</button></a></div>";
  // ++++++++ LED-3 +++++++++++++

   //++++++++++ DS18B20 TEMP  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----DS18B20 TEMP----</p>";
  web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #5191e4;margin: 0 auto;\">"+ String(sensors.getTempCByIndex(0))+"</div>";
  // ++++++++ DS18B20 TEMP  +++++++++++++

  //++++++++++ DHT11 TEMP  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----DHT11 TEMP----</p>";
  web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #5191e4;margin: 0 auto;\">"+ String((int)temperature)+"</div>";
  // ++++++++ DHT11 TEMP  +++++++++++++

  //++++++++++ DHT11 H  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----DHT11 H----</p>";
  web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #5191e4;margin: 0 auto;\">"+ String((int)humidity)+"</div>";
  // ++++++++ DHT11 H  +++++++++++++

  // ========REFRESH=============
  web += "<div style=\"text-align:center;margin-top: 20px;\"><a href=\"/\"><button style=\"width:158px;\">REFRESH</button></a></div>";
  // ========REFRESH=============


  web += "</div>";
  return(web);
}

Как добавить в него етот код что бы работал ( код для внесения данных в гугл таблицу)
C++:
//----------------------------------------Include the NodeMCU ESP8266 Library
//----------------------------------------see here: https://www.youtube.com/watch?v=8jMr94B8iN0 to add NodeMCU ESP12E ESP8266 library and board (ESP8266 Core SDK)
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>


//----------------------------------------
//----------------------------------------Include the DHT Library
#include "DHT.h"
//----------------------------------------

#define DHTTYPE DHT11 //--> Defines the type of DHT sensor used (DHT11, DHT21, and DHT22), in this project the sensor used is DHT11.

const int DHTPin = 5; //--> The pin used for the DHT11 sensor is Pin D1 = GPIO5
DHT dht(DHTPin, DHTTYPE); //--> Initialize DHT sensor, DHT dht(Pin_used, Type_of_DHT_Sensor);

#define ON_Board_LED 2  //--> Defining an On Board LED, used for indicators when the process of connecting to a wifi router

//----------------------------------------SSID and Password of your WiFi router.
const char* ssid = ""; //--> Your wifi name or SSID.
const char* password = ""; //--> Your wifi password.
//----------------------------------------

//----------------------------------------Host & httpsPort
const char* host = "script.google.com";
const int httpsPort = 443;
//----------------------------------------

WiFiClientSecure client; //--> Create a WiFiClientSecure object.

String GAS_ID = ""; //--> spreadsheet script ID

//============================================================================== void setup
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  delay(500);

  dht.begin();  //--> Start reading DHT11 sensors
  delay(500);

  WiFi.begin(ssid, password); //--> Connect to your WiFi router
  Serial.println("");
   
  pinMode(ON_Board_LED,OUTPUT); //--> On Board LED port Direction output
  digitalWrite(ON_Board_LED, HIGH); //--> Turn off Led On Board

  //----------------------------------------Wait for connection
  Serial.print("Connecting");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    //----------------------------------------Make the On Board Flashing LED on the process of connecting to the wifi router.
    digitalWrite(ON_Board_LED, LOW);
    delay(250);
    digitalWrite(ON_Board_LED, HIGH);
    delay(250);
    //----------------------------------------
  }
  //----------------------------------------
  digitalWrite(ON_Board_LED, HIGH); //--> Turn off the On Board LED when it is connected to the wifi router.
  //----------------------------------------If successfully connected to the wifi router, the IP Address that will be visited is displayed in the serial monitor
  Serial.println("");
  Serial.print("Successfully connected to : ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.println();
  //----------------------------------------

  client.setInsecure();
}
//==============================================================================
//============================================================================== void loop
void loop() {
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  int h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor !");
    delay(500);
    return;
  }
  String Temp = "Temperature : " + String(t) + " °C";
  String Humi = "Humidity : " + String(h) + " %";
  Serial.println(Temp);
  Serial.println(Humi);

  sendData(t, h); //--> Calls the sendData Subroutine
}
//==============================================================================
//============================================================================== void sendData
// Subroutine for sending data to Google Sheets
void sendData(float tem, int hum) {
  Serial.println("==========");
  Serial.print("connecting to ");
  Serial.println(host);

  //----------------------------------------Connect to Google host
  if (!client.connect(host, httpsPort)) {
    Serial.println("connection failed");
    return;
  }
  //----------------------------------------

  //----------------------------------------Processing data and sending data
  String string_temperature =  String(tem);
  // String string_temperature =  String(tem, DEC);
  String string_humidity =  String(hum, DEC);
  String url = "/macros/s/" + GAS_ID + "/exec?temperature=" + string_temperature + "&humidity=" + string_humidity;
  Serial.print("requesting URL: ");
  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
         "Host: " + host + "\r\n" +
         "User-Agent: BuildFailureDetectorESP8266\r\n" +
         "Connection: close\r\n\r\n");

  Serial.println("request sent");
  //----------------------------------------

  //----------------------------------------Checking whether the data was sent successfully or not
  while (client.connected()) {
    String line = client.readStringUntil('\n');
    if (line == "\r") {
      Serial.println("headers received");
      break;
    }
  }
  String line = client.readStringUntil('\n');
  if (line.startsWith("{\"state\":\"success\"")) {
    Serial.println("esp8266/Arduino CI successfull!");
  } else {
    Serial.println("esp8266/Arduino CI has failed");
  }
  Serial.print("reply was : ");
  Serial.println(line);
  Serial.println("closing connection");
  Serial.println("==========");
  Serial.println();
  //----------------------------------------
}
//==============================================================================
А то если добавляю то что-то не получается))
Заранее благодарен!
 
Изменено:

bort707

★★★★★★✩
21 Сен 2020
3,066
914
В такой форме это не вопрос, а заказ для раздела возмездной помощи.
Если хотите, чтобы вам именно помогли, а не сделали за вас - показывайте код вашей попытки обьединить скетчи. Не забудьте описать, что именно не получается.
 

Sem553

✩✩✩✩✩✩✩
10 Янв 2021
91
8
В первый код добавляю из второго:
C++:
#include <WiFiClientSecure.h>

//----------------------------------------Host & httpsPort
const char* host = "script.google.com";
const int httpsPort = 443;
//----------------------------------------

WiFiClientSecure client; //--> Create a WiFiClientSecure object.

String GAS_ID = ""; //--> spreadsheet script ID

//Еще раз добавляю
  sensors.requestTemperatures();
  byte temperature = 0;
  byte humidity = 0;
  dht11.read(pinDHT11, &temperature, &humidity, NULL);
//


  String Temp = "Temperature : " + String(t) + " °C";
  String Humi = "Humidity : " + String(h) + " %";
  Serial.println(Temp);
  Serial.println(Humi);

  sendData(t, h); //--> Calls the sendData Subroutine
}
//==============================================================================
//============================================================================== void sendData
// Subroutine for sending data to Google Sheets
void sendData(float tem, int hum) {
  Serial.println("==========");
  Serial.print("connecting to ");
  Serial.println(host);

  //----------------------------------------Connect to Google host
  if (!client.connect(host, httpsPort)) {
    Serial.println("connection failed");
    return;
  }
  //----------------------------------------

  //----------------------------------------Processing data and sending data
  String string_temperature =  String(tem);
  // String string_temperature =  String(tem, DEC);
  String string_humidity =  String(hum, DEC);
  String url = "/macros/s/" + GAS_ID + "/exec?temperature=" + string_temperature + "&humidity=" + string_humidity;
  Serial.print("requesting URL: ");
  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
         "Host: " + host + "\r\n" +
         "User-Agent: BuildFailureDetectorESP8266\r\n" +
         "Connection: close\r\n\r\n");

  Serial.println("request sent");
  //----------------------------------------

  //----------------------------------------Checking whether the data was sent successfully or not
  while (client.connected()) {
    String line = client.readStringUntil('\n');
    if (line == "\r") {
      Serial.println("headers received");
      break;
    }
  }
  String line = client.readStringUntil('\n');
  if (line.startsWith("{\"state\":\"success\"")) {
    Serial.println("esp8266/Arduino CI successfull!");
  } else {
    Serial.println("esp8266/Arduino CI has failed");
  }
После того как совместил код, получилось следуещее:

C++:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <WiFiClientSecure.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#include <SimpleDHT.h>

#define ONE_WIRE_BUS 15

//набор переменных для подсчета uptime
long secs, mins;
int hours, days;

int pinDHT11 = 13;
SimpleDHT11 dht11;

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

MDNSResponder mdns;

// Wi-Fi
const char* ssid = "";
const char* password = "";

byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress ip(192,168,4,35);
IPAddress gateway(192,168,4,1);
IPAddress subnet(255,255,255,0);

ESP8266WebServer server(80);

int D0_pin = 16;
int D2_pin = 2;//d4
int D1_pin = 5;

//----------------------------------------Host & httpsPort
const char* host = "script.google.com";
const int httpsPort = 443;
//----------------------------------------

WiFiClientSecure client; //--> Create a WiFiClientSecure object.

String GAS_ID = ""; //--> spreadsheet script ID

void setup(void){
  // preparing GPIOs
  pinMode(D0_pin, OUTPUT);
  digitalWrite(D0_pin, LOW);
  pinMode(D2_pin, OUTPUT);
  digitalWrite(D2_pin, LOW);
  pinMode(D1_pin, OUTPUT);
  digitalWrite(D1_pin, LOW);

  sensors.begin();

  delay(100);
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  WiFi.config(ip, gateway, subnet);


  Serial.println("");

  // 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());

  if (mdns.begin("esp8266", WiFi.localIP())) {
    Serial.println("MDNS responder started");
  }

  //+++++++++++++++++++++++ START  LED-1 ++++++++++++++++++++
  server.on("/", [](){
    server.send(200, "text/html", webPage());
  });
  server.on("/socket1On", [](){
    digitalWrite(D0_pin, HIGH);
    server.send(200, "text/html", webPage());
    delay(100);
 
  });
  server.on("/socket1Off", [](){
    digitalWrite(D0_pin, LOW);
    server.send(200, "text/html", webPage());
    delay(100);
});
   //+++++++++++++++++++++++ END  LED-1 ++++++++++++++++++++
 
   //+++++++++++++++++++++++ START  LED-2  ++++++++++++++++++++

  server.on("/socket2On", [](){
    digitalWrite(D2_pin, HIGH);
    server.send(200, "text/html", webPage());
    delay(100); 
  });
  server.on("/socket2Off", [](){
    digitalWrite(D2_pin, LOW);
    server.send(200, "text/html", webPage());
    delay(100);
    });
   // +++++++++++++++++++++++ END  LED-2 ++++++++++++++++++++

   //+++++++++++++++++++++++ START  LED-3  ++++++++++++++++++++

  server.on("/socket3On", [](){
    digitalWrite(D1_pin, HIGH);
    server.send(200, "text/html", webPage());
    delay(100); 
  });
  server.on("/socket3Off", [](){
    digitalWrite(D1_pin, LOW);
    server.send(200, "text/html", webPage());
    delay(100);
   });
   // +++++++++++++++++++++++ END  LED-3 ++++++++++++++++++++
 
 

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void){
  server.handleClient();
    //########### Пересчет millis для uptime ###############
  secs = millis() / 1000;
  mins = secs / 60;
  hours = mins / 60;
  days = hours / 24;
  secs -= mins * 60;
  mins -= hours * 60;
  hours -= days * 24;
  //######################################################

{
  sensors.requestTemperatures();
  byte temperature = 0;
  byte humidity = 0;
  dht11.read(pinDHT11, &temperature, &humidity, NULL);
}
//==============================================================================
//============================================================================== void sendData
// Subroutine for sending data to Google Sheets
void sendData(float tem, int hum) {
  Serial.println("==========");
  Serial.print("connecting to ");
  Serial.println(host);

  //----------------------------------------Connect to Google host
  if (!client.connect(host, httpsPort)) {
    Serial.println("connection failed");
    return;
  }
  //----------------------------------------

  //----------------------------------------Processing data and sending data
  String string_temperature =  String(sensors.getTempCByIndex(0), DEC);
  // String string_temperature =  String(tem, DEC);
  String string_humidity =  String(humidity, DEC);
    String string_temperature2 =  String(temperature, DEC);
  String url = "/macros/s/" + GAS_ID + "/exec?temperature=" + string_temperature + "&humidity=" + string_humidity + "&temperature2=" + string_temperature;
  Serial.print("requesting URL: ");
  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
         "Host: " + host + "\r\n" +
         "User-Agent: BuildFailureDetectorESP8266\r\n" +
         "Connection: close\r\n\r\n");

  Serial.println("request sent");
  //----------------------------------------

  //----------------------------------------Checking whether the data was sent successfully or not
  while (client.connected()) {
    String line = client.readStringUntil('\n');
    if (line == "\r") {
      Serial.println("headers received");
      break;
    }
  }
  String line = client.readStringUntil('\n');
  if (line.startsWith("{\"state\":\"success\"")) {
    Serial.println("esp8266/Arduino CI successfull!");
  } else {
    Serial.println("esp8266/Arduino CI has failed");
  }



}

String webPage()
{

  String web;
  web += "<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/> <meta charset=\"utf-8\"><title>ESP 8266</title><style>button{color:red;padding: 10px 27px;}</style></head>";
  web += "<h1 style=\"text-align: center;font-family: Open sans;font-weight: 100;font-size: 20px;\">ESP8266 Web Server</h1><div>";
    web += "<p style=\"text-align: left;margin-top: 0px;margin-bottom: 5px;\">UPTIME:  " + String(days) + " дней " + String(hours) + " час. " + String(mins) + " мин. " + String(secs) + " сек. </p>";
  //++++++++++ LED-1  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----LED 1----</p>";
  if (digitalRead(D0_pin) == 1)
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #43a209;margin: 0 auto;\">ON</div>";
  }
  else
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #ec1212;margin: 0 auto;\">OFF</div>";
  }
  web += "<div style=\"text-align: center;margin: 5px 0px;\"> <a href=\"socket1On\"><button>ON</button></a>&nbsp;<a href=\"socket1Off\"><button>OFF</button></a></div>";
  // ++++++++ LED-1 +++++++++++++

  //++++++++++ LED-2  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----LED 2----</p>";
  if (digitalRead(D2_pin) == 1)
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #43a209;margin: 0 auto;\">ON</div>";
  }
  else
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #ec1212;margin: 0 auto;\">OFF</div>";
  }
  web += "<div style=\"text-align: center;margin: 5px 0px;\"> <a href=\"socket2On\"><button>ON</button></a>&nbsp;<a href=\"socket2Off\"><button>OFF</button></a></div>";
  // ++++++++ LED-2 +++++++++++++

  //++++++++++ LED-3  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----LED 3----</p>";
  if (digitalRead(D1_pin) == 1)
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #43a209;margin: 0 auto;\">ON</div>";
  }
  else
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #ec1212;margin: 0 auto;\">OFF</div>";
  }
  web += "<div style=\"text-align: center;margin: 5px 0px;\"> <a href=\"socket3On\"><button>ON</button></a>&nbsp;<a href=\"socket3Off\"><button>OFF</button></a></div>";
  // ++++++++ LED-3 +++++++++++++

   //++++++++++ DS18B20 TEMP  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----DS18B20 TEMP----</p>";
  web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #5191e4;margin: 0 auto;\">"+ String(sensors.getTempCByIndex(0))+"</div>";
  // ++++++++ DS18B20 TEMP  +++++++++++++

  //++++++++++ DHT11 TEMP  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----DHT11 TEMP----</p>";
  web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #5191e4;margin: 0 auto;\">"+ String((int)temperature)+"</div>";
  // ++++++++ DHT11 TEMP  +++++++++++++

  //++++++++++ DHT11 H  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----DHT11 H----</p>";
  web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #5191e4;margin: 0 auto;\">"+ String((int)humidity)+"</div>";
  // ++++++++ DHT11 H  +++++++++++++

  // ========REFRESH=============
  web += "<div style=\"text-align:center;margin-top: 20px;\"><a href=\"/\"><button style=\"width:158px;\">REFRESH</button></a></div>";
  // ========REFRESH=============


  web += "</div>";
  return(web);
}
В строке 123 выдает ошибку
exit status 1
'webPage' was not declared in this scope

Странно, но на строку 118 ошибку не выдает, а она такая же как и 123

Но без внедрения кода гугл скрипта этой ошибки не выдает

В чем может быть проблема ?
 
Изменено:

Sem553

✩✩✩✩✩✩✩
10 Янв 2021
91
8
@Sergo_ST, спасибо большое, после етого еще несколько ошибок было, но вроде поправил, скетч скомпилировался, щас попробую загрузить, посмотрю будет ли работать )))
C++:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <WiFiClientSecure.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#include <SimpleDHT.h>

#define ONE_WIRE_BUS 15

//набор переменных для подсчета uptime
long secs, mins;
int hours, days;

int pinDHT11 = 13;
SimpleDHT11 dht11;

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

MDNSResponder mdns;

// Wi-Fi
const char* ssid = "";
const char* password = "";

byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress ip(192,168,4,35);
IPAddress gateway(192,168,4,1);
IPAddress subnet(255,255,255,0);

ESP8266WebServer server(80);

int D0_pin = 16;
int D2_pin = 2;//d4
int D1_pin = 5;

//----------------------------------------Host & httpsPort
const char* host = "script.google.com";
const int httpsPort = 443;
//----------------------------------------

WiFiClientSecure client; //--> Create a WiFiClientSecure object.

String GAS_ID = ""; //--> spreadsheet script ID

void setup(void){
  // preparing GPIOs
  pinMode(D0_pin, OUTPUT);
  digitalWrite(D0_pin, LOW);
  pinMode(D2_pin, OUTPUT);
  digitalWrite(D2_pin, LOW);
  pinMode(D1_pin, OUTPUT);
  digitalWrite(D1_pin, LOW);

  sensors.begin();

  delay(100);
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  WiFi.config(ip, gateway, subnet);


  Serial.println("");

  // 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());

  if (mdns.begin("esp8266", WiFi.localIP())) {
    Serial.println("MDNS responder started");
  }

  //+++++++++++++++++++++++ START  LED-1 ++++++++++++++++++++
  server.on("/", [](){
    server.send(200, "text/html", webPage());
  });
  server.on("/socket1On", [](){
    digitalWrite(D0_pin, HIGH);
    server.send(200, "text/html", webPage());
    delay(100);
 
  });
  server.on("/socket1Off", [](){
    digitalWrite(D0_pin, LOW);
    server.send(200, "text/html", webPage());
    delay(100);
});
   //+++++++++++++++++++++++ END  LED-1 ++++++++++++++++++++
 
   //+++++++++++++++++++++++ START  LED-2  ++++++++++++++++++++

  server.on("/socket2On", [](){
    digitalWrite(D2_pin, HIGH);
    server.send(200, "text/html", webPage());
    delay(100);
  });
  server.on("/socket2Off", [](){
    digitalWrite(D2_pin, LOW);
    server.send(200, "text/html", webPage());
    delay(100);
    });
   // +++++++++++++++++++++++ END  LED-2 ++++++++++++++++++++

   //+++++++++++++++++++++++ START  LED-3  ++++++++++++++++++++

  server.on("/socket3On", [](){
    digitalWrite(D1_pin, HIGH);
    server.send(200, "text/html", webPage());
    delay(100);
  });
  server.on("/socket3Off", [](){
    digitalWrite(D1_pin, LOW);
    server.send(200, "text/html", webPage());
    delay(100);
   });
   // +++++++++++++++++++++++ END  LED-3 ++++++++++++++++++++
 
 

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void){
  server.handleClient();
    //########### Пересчет millis для uptime ###############
  secs = millis() / 1000;
  mins = secs / 60;
  hours = mins / 60;
  days = hours / 24;
  secs -= mins * 60;
  mins -= hours * 60;
  hours -= days * 24;
  //######################################################



}
//==============================================================================
//============================================================================== void sendData
// Subroutine for sending data to Google Sheets
void sendData(float tem, int hum) {
  Serial.println("==========");
  Serial.print("connecting to ");
  Serial.println(host);

  //----------------------------------------Connect to Google host
  if (!client.connect(host, httpsPort)) {
    Serial.println("connection failed");
    return;
  }
  //----------------------------------------
  sensors.requestTemperatures();
  byte temperature = 0;
  byte humidity = 0;
  dht11.read(pinDHT11, &temperature, &humidity, NULL);
  //----------------------------------------Processing data and sending data
  String string_temperature =  String(sensors.getTempCByIndex(0), DEC);
  // String string_temperature =  String(tem, DEC);
  String string_humidity =  String(((int)humidity), DEC);
  String string_temperature2 =  String((int)temperature);
  String url = "/macros/s/" + GAS_ID + "/exec?temperature=" + string_temperature + "&humidity=" + string_humidity + "&temperature2=" + string_temperature;
  Serial.print("requesting URL: ");
  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
         "Host: " + host + "\r\n" +
         "User-Agent: BuildFailureDetectorESP8266\r\n" +
         "Connection: close\r\n\r\n");

  Serial.println("request sent");
  //----------------------------------------

  //----------------------------------------Checking whether the data was sent successfully or not
  while (client.connected()) {
    String line = client.readStringUntil('\n');
    if (line == "\r") {
      Serial.println("headers received");
      break;
    }
  }
  String line = client.readStringUntil('\n');
  if (line.startsWith("{\"state\":\"success\"")) {
    Serial.println("esp8266/Arduino CI successfull!");
  } else {
    Serial.println("esp8266/Arduino CI has failed");
  }



}

String webPage()
{
  sensors.requestTemperatures();
  byte temperature = 0;
  byte humidity = 0;
  dht11.read(pinDHT11, &temperature, &humidity, NULL);
  String web;
  web += "<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/> <meta charset=\"utf-8\"><title>ESP 8266</title><style>button{color:red;padding: 10px 27px;}</style></head>";
  web += "<h1 style=\"text-align: center;font-family: Open sans;font-weight: 100;font-size: 20px;\">ESP8266 Web Server</h1><div>";
    web += "<p style=\"text-align: left;margin-top: 0px;margin-bottom: 5px;\">UPTIME:  " + String(days) + " дней " + String(hours) + " час. " + String(mins) + " мин. " + String(secs) + " сек. </p>";
  //++++++++++ LED-1  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----LED 1----</p>";
  if (digitalRead(D0_pin) == 1)
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #43a209;margin: 0 auto;\">ON</div>";
  }
  else
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #ec1212;margin: 0 auto;\">OFF</div>";
  }
  web += "<div style=\"text-align: center;margin: 5px 0px;\"> <a href=\"socket1On\"><button>ON</button></a>&nbsp;<a href=\"socket1Off\"><button>OFF</button></a></div>";
  // ++++++++ LED-1 +++++++++++++

  //++++++++++ LED-2  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----LED 2----</p>";
  if (digitalRead(D2_pin) == 1)
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #43a209;margin: 0 auto;\">ON</div>";
  }
  else
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #ec1212;margin: 0 auto;\">OFF</div>";
  }
  web += "<div style=\"text-align: center;margin: 5px 0px;\"> <a href=\"socket2On\"><button>ON</button></a>&nbsp;<a href=\"socket2Off\"><button>OFF</button></a></div>";
  // ++++++++ LED-2 +++++++++++++

  //++++++++++ LED-3  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----LED 3----</p>";
  if (digitalRead(D1_pin) == 1)
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #43a209;margin: 0 auto;\">ON</div>";
  }
  else
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #ec1212;margin: 0 auto;\">OFF</div>";
  }
  web += "<div style=\"text-align: center;margin: 5px 0px;\"> <a href=\"socket3On\"><button>ON</button></a>&nbsp;<a href=\"socket3Off\"><button>OFF</button></a></div>";
  // ++++++++ LED-3 +++++++++++++

   //++++++++++ DS18B20 TEMP  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----DS18B20 TEMP----</p>";
  web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #5191e4;margin: 0 auto;\">"+ String(sensors.getTempCByIndex(0))+"</div>";
  // ++++++++ DS18B20 TEMP  +++++++++++++

  //++++++++++ DHT11 TEMP  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----DHT11 TEMP----</p>";
  web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #5191e4;margin: 0 auto;\">"+ String((int)temperature)+"</div>";
  // ++++++++ DHT11 TEMP  +++++++++++++

  //++++++++++ DHT11 H  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----DHT11 H----</p>";
  web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #5191e4;margin: 0 auto;\">"+ String((int)humidity)+"</div>";
  // ++++++++ DHT11 H  +++++++++++++

  // ========REFRESH=============
  web += "<div style=\"text-align:center;margin-top: 20px;\"><a href=\"/\"><button style=\"width:158px;\">REFRESH</button></a></div>";
  // ========REFRESH=============


  web += "</div>";
  return(web);
}
 

Sem553

✩✩✩✩✩✩✩
10 Янв 2021
91
8
Загрузил код, почти все работает, как было, только в таблицу так и не пишет ничего((
Что же я пропустил, подскажите пожалуйста
 

bort707

★★★★★★✩
21 Сен 2020
3,066
914
Не нашел у вас в коде вызова процедуры sendData(), которая пишет записи в таблицу.
 
  • Лойс +1
Реакции: Sem553

Sem553

✩✩✩✩✩✩✩
10 Янв 2021
91
8
@bort707, я так понял мне вот этот код (который работал когда-то отдельно):
C++:
void loop() {
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  int h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
 
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor !");
    delay(500);
    return;
  }
  String Temp = "Temperature : " + String(t) + " °C";
  String Humi = "Humidity : " + String(h) + " %";
  Serial.println(Temp);
  Serial.println(Humi);
 
  sendData(t, h); //--> Calls the sendData Subroutine
}
//==============================================================================
//============================================================================== void sendData
// Subroutine for sending data to Google Sheets
void sendData(float tem, int hum) {
  Serial.println("==========");
  Serial.print("connecting to ");
  Serial.println(host);
 
  //----------------------------------------Connect to Google host
  if (!client.connect(host, httpsPort)) {
    Serial.println("connection failed");
    return;
  }
  //----------------------------------------

  //----------------------------------------Processing data and sending data
  String string_temperature =  String(tem);
  // String string_temperature =  String(tem, DEC);
  String string_humidity =  String(hum, DEC);
  String url = "/macros/s/" + GAS_ID + "/exec?temperature=" + string_temperature + "&humidity=" + string_humidity;
  Serial.print("requesting URL: ");
  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
         "Host: " + host + "\r\n" +
         "User-Agent: BuildFailureDetectorESP8266\r\n" +
         "Connection: close\r\n\r\n");

  Serial.println("request sent");
  //----------------------------------------

  //----------------------------------------Checking whether the data was sent successfully or not
  while (client.connected()) {
    String line = client.readStringUntil('\n');
    if (line == "\r") {
      Serial.println("headers received");
      break;
    }
  }
  String line = client.readStringUntil('\n');
  if (line.startsWith("{\"state\":\"success\"")) {
    Serial.println("esp8266/Arduino CI successfull!");
  } else {
    Serial.println("esp8266/Arduino CI has failed");
  }
  Serial.print("reply was : ");
  Serial.println(line);
  Serial.println("closing connection");
  Serial.println("==========");
  Serial.println();
  //----------------------------------------
}
//=============
к вот этим значением, изменить названия которые будут передаваться

C++:
  sensors.requestTemperatures();
  byte temperature = 0;
  byte humidity = 0;
  dht11.read(pinDHT11, &temperature, &humidity, NULL);
я верно понял?

вывести значения вот этим
String((int)humidity)
String((int)temperature)
String(sensors.getTempCByIndex(0))
и отправить их через sendData() ?
 

bort707

★★★★★★✩
21 Сен 2020
3,066
914
Имхо, зря вы начали редактировать sendData(). Простите, но вы пока слишком мало знаете и теперь вообще там все перепутали. Вам надо было оставить чтение датчиков в ЛУПе, как это было в старом скетче - а потом значения температуры и влажности передавать sendData()
 

Sem553

✩✩✩✩✩✩✩
10 Янв 2021
91
8
Хотел добавить гугл таблицы, но мое внимание перешло к телеграм боту, в итоге соединил код который у меня был (без гугл таблицы) и телеграм бота, и получилось следующее:

C++:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <UniversalTelegramBot.h>
#include <Adafruit_NeoPixel.h>

#include <OneWire.h>
#include <DallasTemperature.h>
#include <SimpleDHT.h>
#define ONE_WIRE_BUS 15
//набор переменных для подсчета uptime
long secs, mins;
int hours, days;
int pinDHT11 = 13;
SimpleDHT11 dht11;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
MDNSResponder mdns;
// Wi-Fi
const char* ssid = "";
const char* password = "";

byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress ip(192,168,4,35);
IPAddress gateway(192,168,4,1);
IPAddress subnet(255,255,255,0);
ESP8266WebServer server(80);

int D0_pin = 16;
int D2_pin = 2;//d4
int D1_pin = 5;
const unsigned long TEMP_MTBS = 60000;
unsigned long temp_lasttime;
#define PIN 12
#define NUMPIXELS 5
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int maxTemp = 40;
WiFiClientSecure secured_client;
#define BOT_TOKEN ""
#define CHAT_ID "" //https://api.telegram.org/bot1875231296:AAE7Z-XxLwqJ9tOUwt1IueRa8Ilszkcbptg/getUpdates
const unsigned long BOT_MTBS = 3000;
X509List cert(TELEGRAM_CERTIFICATE_ROOT);
UniversalTelegramBot bot(BOT_TOKEN, secured_client);
unsigned long bot_lasttime;


void setup(void){
  // preparing GPIOs
  pinMode(D0_pin, OUTPUT);
  digitalWrite(D0_pin, LOW);
  pinMode(D2_pin, OUTPUT);
  digitalWrite(D2_pin, LOW);
  pinMode(D1_pin, OUTPUT);
  digitalWrite(D1_pin, LOW);
   pixels.begin();
  sensors.begin();

  delay(100);
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  WiFi.config(ip, gateway, subnet);
 
 
  Serial.println("");

  // 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());
 
  if (mdns.begin("esp8266", WiFi.localIP())) {
    Serial.println("MDNS responder started");
  }
 bot.sendMessage(CHAT_ID, "Hi! I'm online", "");
 
 
  //+++++++++++++++++++++++ START  LED-1 ++++++++++++++++++++
  server.on("/", [](){
    server.send(200, "text/html", webPage());
  });
  server.on("/socket1On", [](){
    digitalWrite(D0_pin, HIGH);
    server.send(200, "text/html", webPage());
    delay(100);
    
  });
  server.on("/socket1Off", [](){
    digitalWrite(D0_pin, LOW);
    server.send(200, "text/html", webPage());
    delay(100);
 });   
   //+++++++++++++++++++++++ END  LED-1 ++++++++++++++++++++
    
   //+++++++++++++++++++++++ START  LED-2  ++++++++++++++++++++
 
  server.on("/socket2On", [](){
    digitalWrite(D2_pin, HIGH);
    server.send(200, "text/html", webPage());
    delay(100);   
  });
  server.on("/socket2Off", [](){
    digitalWrite(D2_pin, LOW);
    server.send(200, "text/html", webPage());
    delay(100);
    }); 
   // +++++++++++++++++++++++ END  LED-2 ++++++++++++++++++++
  
   //+++++++++++++++++++++++ START  LED-3  ++++++++++++++++++++

  server.on("/socket3On", [](){
    digitalWrite(D1_pin, HIGH);
    server.send(200, "text/html", webPage());
    delay(100);   
  });
  server.on("/socket3Off", [](){
    digitalWrite(D1_pin, LOW);
    server.send(200, "text/html", webPage());
    delay(100);
   });
   // +++++++++++++++++++++++ END  LED-3 ++++++++++++++++++++
    
    
 
  server.begin();
  Serial.println("HTTP server started");
}
 
void loop(void){

  if(millis() - bot_lasttime > BOT_MTBS)
  {
  /////////////////////////////////////////
  sensors.requestTemperatures();
  byte temperature = 0;
  byte humidity = 0;
  dht11.read(pinDHT11, &temperature, &humidity, NULL);
  const int analogInPin = A0;  // ESP8266 Analog Pin ADC0 = A0
float sensorValue = 0.00;  // value read from the pot
  sensorValue = ((float)analogRead(analogInPin) - 236.) / 100.;
//////////////////////////////////////////////
    int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
    while(numNewMessages)
    {
      handleNewMessages(numNewMessages);
      numNewMessages = bot.getUpdates(bot.last_message_received + 1);
    }
    bot_lasttime = millis();

    criticalTemp();
  }


  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

  server.handleClient();
    //########### Пересчет millis для uptime ###############
  secs = millis() / 1000;
  mins = secs / 60;
  hours = mins / 60;
  days = hours / 24;
  secs -= mins * 60;
  mins -= hours * 60;
  hours -= days * 24;
  //######################################################
  //вимір напруги і перетворення по коефіцієнту

 
}

String webPage()
{
  sensors.requestTemperatures();
  byte temperature = 0;
  byte humidity = 0;
  dht11.read(pinDHT11, &temperature, &humidity, NULL);
  const int analogInPin = A0;  // ESP8266 Analog Pin ADC0 = A0
float sensorValue = 0.00;  // value read from the pot
  sensorValue = ((float)analogRead(analogInPin) - 236.) / 100.;
  String web;
  web += "<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/> <meta charset=\"utf-8\"><title>ESP 8266</title><style>button{color:red;padding: 10px 27px;}</style></head>";
  web += "<h1 style=\"text-align: center;font-family: Open sans;font-weight: 100;font-size: 20px;\">ESP8266 Web Server</h1><div>";
    web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">UPTIME:  " + String(days) + " days " + String(hours) + " hours " + String(mins) + " min. " + String(secs) + " sec. </p>";
  //++++++++++ LED-1  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----LED 1----</p>";
  if (digitalRead(D0_pin) == 1)
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #43a209;margin: 0 auto;\">ON</div>";
  }
  else
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #ec1212;margin: 0 auto;\">OFF</div>";
  }
  web += "<div style=\"text-align: center;margin: 5px 0px;\"> <a href=\"socket1On\"><button>ON</button></a>&nbsp;<a href=\"socket1Off\"><button>OFF</button></a></div>";
  // ++++++++ LED-1 +++++++++++++
 
  //++++++++++ LED-2  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----LED 2----</p>";
  if (digitalRead(D2_pin) == 1)
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #43a209;margin: 0 auto;\">ON</div>";
  }
  else
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #ec1212;margin: 0 auto;\">OFF</div>";
  }
  web += "<div style=\"text-align: center;margin: 5px 0px;\"> <a href=\"socket2On\"><button>ON</button></a>&nbsp;<a href=\"socket2Off\"><button>OFF</button></a></div>";
  // ++++++++ LED-2 +++++++++++++
 
  //++++++++++ LED-3  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----LED 3----</p>";
  if (digitalRead(D1_pin) == 1)
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #43a209;margin: 0 auto;\">ON</div>";
  }
  else
  {
    web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #ec1212;margin: 0 auto;\">OFF</div>";
  }
  web += "<div style=\"text-align: center;margin: 5px 0px;\"> <a href=\"socket3On\"><button>ON</button></a>&nbsp;<a href=\"socket3Off\"><button>OFF</button></a></div>";
  // ++++++++ LED-3 +++++++++++++
 
   //++++++++++ DS18B20 TEMP  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----DS18B20 TEMP----</p>";
  web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #5191e4;margin: 0 auto;\">"+ String(sensors.getTempCByIndex(0))+"</div>";
  // ++++++++ DS18B20 TEMP  +++++++++++++
 
  //++++++++++ DHT11 TEMP  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----DHT11 TEMP----</p>";
  web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #5191e4;margin: 0 auto;\">"+ String((int)temperature)+"</div>";
  // ++++++++ DHT11 TEMP  +++++++++++++
 
  //++++++++++ DHT11 H  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----DHT11 H----</p>";
  web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #5191e4;margin: 0 auto;\">"+ String((int)humidity)+"</div>";
  // ++++++++ DHT11 H  +++++++++++++

    //++++++++++ АКБ  +++++++++++++
  web += "<p style=\"text-align: center;margin-top: 0px;margin-bottom: 5px;\">----АКБ----</p>";
  web += "<div style=\"text-align: center;width: 98px;color:white ;padding: 10px 30px;background-color: #5191e4;margin: 0 auto;\">"+ String(sensorValue)+"</div>";
  // ++++++++ АКБ  +++++++++++++
 
  // ========REFRESH=============
  web += "<div style=\"text-align:center;margin-top: 20px;\"><a href=\"/\"><button style=\"width:158px;\">REFRESH</button></a></div>";
  // ========REFRESH=============
 
 
  web += "</div>";
  return(web);
}




void handleNewMessages(int numNewMessages)
{

  sensors.requestTemperatures();
  byte temperature = 0;
  byte humidity = 0;
  dht11.read(pinDHT11, &temperature, &humidity, NULL);
  const int analogInPin = A0;  // ESP8266 Analog Pin ADC0 = A0
float sensorValue = 0.00;  // value read from the pot
  sensorValue = ((float)analogRead(analogInPin) - 236.) / 100.;
  for(int i = 0; i < numNewMessages; i++)
  {
    if(bot.messages[i].chat_id == CHAT_ID)
    {
      String text = bot.messages[i].text;
      if(text == "/temp")
      {
        String str = "Temp: " + String((int)temperature);
        bot.sendMessage(CHAT_ID, str, "");
      }
      /////////////////////////////////////////////////////////
      if(text == "/tempds")
      {
        String str = "TempDS: " + String(sensors.getTempCByIndex(0));
        bot.sendMessage(CHAT_ID, str, "");
      }

            if(text == "/temph")
      {
        String str = "TempH: " + String((int)humidity);
        bot.sendMessage(CHAT_ID, str, "");
      }
            if(text == "/tempv")
            {
        String str = "TempV: " + String(sensorValue);
        bot.sendMessage(CHAT_ID, str, "");
      }
      ////////////////////////////////////////////////////////
      if(text == "/led")
      {
        ledPix(5);
      }
      if(text.length() > 4)
      {
        if(text[0] == '/' && text[1] == 'l' && text[2] == 'e' && text[3] == 'd')
        {
          if(text[4] == '0')
            ledPix(0);
          if(text[4] == '1')
            ledPix(1);
          if(text[4] == '2')
            ledPix(2);
          if(text[4] == '3')
            ledPix(3);
          if(text[4] == '4')
            ledPix(4);
          if(text[4] == '5')
            ledPix(5);
        }
      }
      if(text == "/start" || text == "/help")
      {
        String welcome = "Hi i'm ESP8266.\n";
        welcome += "/temp - get the current temperature value\n";
        welcome += "/tempds - get the current temper ds value\n";
        welcome += "/temph - get the current hunidit value\n";       
        welcome += "/tempv - get the current voltage value\n";       
        welcome += "/led - light up all leds\n";
        welcome += "/led0 - turn off all leds\n";
        welcome += "/led1 - light up one led\n";
        welcome += "/led2 - light up two leds\n";
        welcome += "/led3 - light up three leds\n";
        welcome += "/led4 - light up four leds\n";
        welcome += "/led5 - light up five leds\n";
        bot.sendMessage(CHAT_ID, welcome, "");
      }
    }
  }
}
void criticalTemp()
{

  sensors.requestTemperatures();
  byte temperature = 0;
  byte humidity = 0;
  dht11.read(pinDHT11, &temperature, &humidity, NULL);
 
  if(millis() - temp_lasttime > TEMP_MTBS)
  {
    if(temperature >= maxTemp)
    {
      String str = "Critical temp: " + String((int)temperature);
      bot.sendMessage(CHAT_ID, str, "");
    }
    temp_lasttime = millis();
  }
}

void ledPix(int led)
{
  for(int i = 0; i < 5; i++)
  {
    pixels.setPixelColor(i, pixels.Color(0,0,0));
  }
  pixels.show();
 
  for(int i = 0; i < led; i++)
  {
    pixels.setPixelColor(i, pixels.Color(200,0,0));
  }
  pixels.show();
}
в итоге открывая порт я выдел что сервер раз в 2-3 секунды перегружался, или новый делался, НО интересно то, что и телеграм бот не работал, и сервер не был доступен, и оставил я ето детище где-то на час, прихожу и чуствую запах жареной ESP, в итоге она сгорела, ето может быть из-за кода или просто могло что-то коротнуть ?

Вот код ошибки с порта:
C++:
Receive: . Receive: . Receive: . Receive: . Receive: . Receive: . Connected to Epson384L IP address: 192.168.4.35 MDNS responder started Receive: --------------- CUT HERE FOR EXCEPTION DECODER --------------- Soft WDT reset >>>stack>>> ctx: cont sp: 3ffffca0 end: 3fffffc0 offset: 01a0 3ffffe40: 00000000 00000000 401004f9 00000000 3ffffe50: 00001173 40266bb8 3ffffe8c 402117ff 3ffffe60: 3ffef800 00000000 3ffef8e4 40211831 3ffffe70: 00001173 00000000 3ffef8e4 4020e569 3ffffe80: 00000000 003d003f 00000000 00000000 3ffffe90: 000b000f 00000000 00000020 40100cc0 3ffffea0: 3fffff00 00000000 3fff3660 00000000 3ffffeb0: 3fffff00 3ffffee8 3ffe986d 4020c32c 3ffffec0: 3ffe9826 3ffffee8 00000000 3fffff60 3ffffed0: 3fffff50 3ffef8e4 00000000 4020e699 3ffffee0: 3ffe91a9 00000010 3fff30a4 3fff30be 3ffffef0: 3fff3660 3fff3680 3fff2f00 3ffe85dc 3fffff00: 3fff3670 3fff3660 3ffefc20 3ffe85dc 3fffff10: 3fffff00 3ffffee8 3fffff60 402114b7 3fffff20: 3fffff70 00000000 3fffff50 40211528 3fffff30: 3ffe9826 3ffe9826 3fffff50 3ffe85dc 3fffff40: 3ffe9826 3ffefc14 3ffefbd8 40202351 3fffff50: 00000000 2304a8c0 00000000 feefeffe 3fffff60: 3fff2f14 000e000f 80000000 feefeffe 3fffff70: 39343431 39353632 0a003837 4021640c 3fffff80: 0104a8c0 4021640c 2304a8c0 feefeffe 3fffff90: feefeffe feefeffe feefeffe 3ffefd04 3fffffa0: 3fffdad0 00000000 3ffefcf0 40212690 3fffffb0: feefeffe feefeffe 3ffe85f8 40100f51 <<>>stack>>> ctx: cont sp: 3ffffc10 end: 3fffffc0 offset: 01a0 3ffffdb0: 00000000 00000010 00000020 40100cc0 3ffffdc0: 402158a0 3ffffea4 3ffffe8c 40100cf8 3ffffdd0: 3ffffe40 00000040 3ffffe80 40211441 3ffffde0: 00000000 3ffffea4 3ffffea4 40220100 3ffffdf0: 3ffffe40 00000008 00000020 00000000 3ffffe00: 0 и еще долго так ... все не влазит <<