2018-08-08

Die Webseite zum Esp8266 Dht22.

Dht22.html

<!-- For more information visit: https://fipsok.de -->
<!DOCTYPE HTML>
<html lang="de">
   <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <link rel="stylesheet" href="style.css">
      <title>Klimadaten</title>
      <script>
         function renew() {
           fetch('/dht22').then(function (response) {
             return response.json();
           }).then(function (array) {
             var elem = document.querySelector('#temp');
             array[0] == 'OK' ? elem.innerHTML = array[1].replace('.', ',') + '°C' : elem.innerHTML = '---------';
             elem = document.querySelector('#hum');
             array[0] == 'OK' ? elem.innerHTML = array[2].replace('.', ',') + ' %' : elem.innerHTML = array[0];
             elem = document.querySelector('#tau');
             array[0] == 'OK' ? elem.innerHTML = array[3].replace('.', ',') + '°C' : elem.innerHTML = array[0];
             elem = document.querySelector('#hi');
             array[0] == 'OK' ? elem.innerHTML = array[4].replace('.', ',') + '°C' : elem.innerHTML = '---------';
           });
         }
         document.addEventListener('DOMContentLoaded', renew);
         setInterval(renew, 2000)
       </script>
      <style>
         body {
         padding: 10px;
         font-size: 3em;
         }
         section {
         align-items: center;
         background-color: black;
         width: 290px;
         height: 290px;
         border: .15em solid #aeaeab;
         box-shadow: 5px 10px 5px rgba(0, 0, 0, 0.7);
         border-radius: .2em;
         }
         span {
         color: #02fc07;
         position: relative;
         top: 0.05em;
         left: .1em;
         font-weight: bold
         }
         .klein {
         color: #a4aba4;
         font-size: 0.5em;
         top: 0.2em;
         }
      </style>
   </head>
   <body>
      <section>
         <span id='temp'></span>
         <span id='hum'></span>
         <span class='klein'>Taupunkt</span>
         <span id='tau'></span>
         <span class='klein'>Hitzeindex</span>
         <span id='hi'></span>
      </section>
   </body>
</html>

Zurück