Update: 2023-04-11

Esp8266 AHT10 als Arduino Tab.


// ****************************************************************
// Sketch Esp8266 AHT10 Modular(Tab)
// created: Jens Fleischer, 2023-04-11
// last mod: Jens Fleischer, 2023-04-11
// For more information visit: https://fipsok.de
// ****************************************************************
// Hardware: Esp8266, AHT10
// SCL an D1 = GPIO5
// SDA an D2 = GPIO4
// Software: Esp8266 Arduino Core 2.6.0 -3.1.2
// Getestet auf: Nodemcu
  Copyright (c) 2023 Jens Fleischer. All rights reserved.

  This file is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  This file is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  Lesser General Public License for more details.
// Diese Version von AHT10 sollte als Tab eingebunden werden.
// #include <ESP8266WebServer.h> muss im Haupttab aufgerufen werden
// Die Funktionalität des ESP8266 Webservers ist erforderlich.
// Die Funktion "aht10();" muss im Setup aufgerufen werden.

#include <AHT10.h>                   // https://github.com/enjoyneering/AHT10

AHT10 myAHT10(0X38);                 // 0x38 oder 0x39

void aht10() {
  for (; !myAHT10.begin(); Serial.println("Der AHT10 ist nicht angeschlossen!"), delay(5e3));
  server.on("/aht10", []() {
   server.send(200, "application/json", "[\"" + static_cast<String>(myAHT10.readTemperature()) + "\",\"" + myAHT10.readHumidity() + "\"]");

Die Webseite zum Esp8266 AHT10.


<!DOCTYPE HTML> <!-- For more information visit: https://fipsok.de -->
<html lang='de'>
	<meta charset='UTF-8'>
	<meta name='viewport' content='width=device-width, initial-scale=1'>
	<link rel='stylesheet' href='style.css'>
	  addEventListener('DOMContentLoaded', renew, setInterval(renew, 2000));
		async function renew() {
		  let resp = await fetch('/aht10');
		  let array = await resp.json();
		  temp.innerHTML = array[0] + '°C';
		  hum.innerHTML = array[1] + ' %';
	  main {
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: black;
		font-size: 3em;
		width: 6em;
		padding: 0.2em;
		border: .15em solid #aeaeab;
		box-shadow: 5px 7px 10px;
		border-radius: .2em;
	  span {
		color: #02fc07;
		position: relative;
		top: .1em;
		left: .1em;
		font-weight: bold
	  <span id="temp"></span>
	  <span id="hum"></span>