def web_page(): bme = BME280.BME280(i2c=i2c) html = """

ESP32 with BME280

Pressure : """ + str(bme.pressure) + """
Humidity : """ + str(bme.humidity) + """
Temperature Celsius : """ + str(bme.temperature) + """
Temperature Fahrenheit : """ + str(round((bme.read_temperature()/100.0) * (9/5) + 32, 2)) + """F
""" return html s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', 80)) s.listen(5) while True: try: if gc.mem_free() < 102000: gc.collect() conn, addr = s.accept() conn.settimeout(3.0) print('Got a connection from %s' % str(addr)) request = conn.recv(1024) conn.settimeout(None) request = str(request) print('Content = %s' % request) response = web_page() conn.send('HTTP/1.1 200 OK\n') conn.send('Content-Type: text/html\n') conn.send('Connection: close\n\n') conn.sendall(response) conn.close() except OSError as e: conn.close() print('Connection closed')