Kód: Vybrať všetko
#include <OneWire.h> //KNIZNICA ONEWIRE PRE VYUZITIE ONEWIRE ZBERNICE
#include <DallasTemperature.h> //KNIZNICA PRE TEPLOTNE CIDLA
#define ONE_WIRE_BUS 2 //DEFINICIA PINU AKO ZBERNICE PRE ONEWIRE ZARIADENIA
OneWire oneWire(ONE_WIRE_BUS); //ONEWIRE ČÍTAŤ IBA NA PORTE DEFINOVANOM VYSSIE
DallasTemperature sensors(&oneWire);
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <SPI.h>
const char *ssid = "ESPap";
const char *password = "thereisnospoon";
ESP8266WebServer server(80);
/* Just a little test message. Go to http://192.168.4.1 in a web browser
connected to this access point to see it.
*/
void handleRoot() {
sensors.begin();
sensors.requestTemperatures();
server.send(200, "text/html", "<!DOCTYPE html><html><head><title>Teploty</title></head><body><h1>Teplota 1</h1><p>TU CHCEM VLOZIT sensors.getTempCByIndex(0);</p></body></html> ");
}
void setup() {
delay(1000);
Serial.begin(115200);
Serial.println();
Serial.print("Configuring access point...");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.print("IP adresa pristupoveho bodu je: ");
Serial.println(myIP);
server.on("/", handleRoot);
server.begin();
Serial.println("Webserver bezi");
}
void loop() {
server.handleClient();
}