Wifi thermometer - NodeMCU in AP mode

Wifi Thermometer is a project where NodeMCU is used in AP mode, it's actually a hotspot to which you connect, and then you can view the temperatures or the magnitudes of other sensors that you connect to the NodeMCU. Values are viewed through a web browser on the page that NodeMCU generates. It is located on the same IP / DNS flag as the gateway (NodeMCU). This solution demonstrates two DS18B20 sensors using OneWire protocol.
parameters:

  • NodeMCU in Access Point (AP)
  • Custom SSID and WPA2 PSK encryption
  • Custom IP (static) / DNS flag
  • Secure web site accessible from home network
  • Always when loading the page, the current info (informative character)
  • Graphic depiction

Obrázek
The data is updated whenever the client refresh the page. This means that it always has the current temperature.
Support me and find interesting solutions at: https://arduino.php5.sk

Source code:
#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); /* IP stranky je 192.168.4.1 (predpísané kniznicou) */ void handleRoot() { sensors.begin(); sensors.requestTemperatures(); server.send(200, "text/html", "<!DOCTYPE html><html><body><table><tr><td>Cidlo</td><td>Hodnota</td></tr><tr><td>DS18b20 - dnu</td><td>"+(String)sensors.getTempCByIndex(0)+"</td></tr><tr><td>DS18b20 - von</td><td>"+(String)sensors.getTempCByIndex(1)+"</td></tr></table></body></html>"); } void setup() { delay(1000); Serial.begin(115200); Serial.println(); Serial.print("Konfigurujem 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(); }

Comments

Popular posts from this blog

Web scraper via Arduino & NodeMCU & ESP32

ESP32 control via UDP datagrams

Biking on Google Maps - Arduino Leonardo (32u4) - HID device