Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » BME280 & Raspberry Pi Pico W Web Server Weather Station
Raspberry Pi Raspberry Pi Pico W Projects

BME280 & Raspberry Pi Pico W Web Server Weather Station

Mamtaz AlamBy Mamtaz AlamUpdated:December 3, 20229 Comments4 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
BME280 Raspberry Pi Pico W Web Server Weather Station
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this tutorial, we will learn how to make an IoT Based Web Server Weather Station Project using Raspberry Pi Pico W & BME280 Sensor. The Raspberry Pi Pico W Web Server Web displays BME280 sensor readings using MicroPython firmware. The BME280 is a temperature, humidity, and pressure sensor that is excellent for use in mini weather stations and other similar applications.

We will create a Raspberry Pi Pico W Web Server that is mobile responsive and it can be accessed with any device with a browser in your local network. The data from the sensor is displayed on a web page in real-time with an auto-refresh feature after every 5 seconds.



Bill of Materials

We need the following components for this tutorial:

  1. Raspberry Pi Pico W- 1
  2. BME280 Sensor – 1
  3. Jumper Wires – 10
  4. Breadbaord – 1
  5. Micro-USB Cable – 1

BME280 Barometric Pressure Sensor

The BME280 is Barometric Pressure Sensor that can measure temperature, Humidity & Atmospheric Pressure. The Sensor has an I2C Bus and operates on 3.3V Power Supply. The unit combines high linearity and high accuracy sensors and is perfectly feasible for low current consumption, long-term stability, and high EMC robustness.

This sensor is simple to use, comes pre-calibrated, and requires no additional components, so you can start measuring relative humidity, temperature, barometric pressure, and altitude in no time.

The sensor is best for measuring humidity with ±3% accuracy, barometric pressure with ±1 hPa absolute accuracy, and temperature with ±1.0°C accuracy. Because pressure changes with altitude and the pressure measurements are so good, you can also use it as an altimeter with ±1 meter or better accuracy.

To learn more about the BME280 Sensor refer to the BME280 datasheet or you may follow the BME280 Raspberry Pi Pico interfacing guide.


Interfacing BME280 Sensor with Raspberry Pi Pico W

Let us connect the BME280 Barometric Pressure Sensor with Raspberry Pi Pico W via I2C pins. This sensor communicates using the I2C communication protocol, so the wiring is very simple.

BME280 Raspberry Pi Pico W

Raspberry Pi Pico W has multiple I2C pins, you may use any. Connect the VCC, GND, SCL & SDA pin of BME280 Sensor to 3.3V, GND, GP21 & GP20 of Raspberry Pi Pico W respectively.

BME280 Raspberry Pi Pico W IoT Weather Station



MicroPython Code

If you are beginner and want to learn how to get started with Raspberry Pi Pico W, you may refer to the Getting Started guide.

The code for interfacing the BME280 Sensor with Raspberry Pi Pico W is divided into two parts:

  1. bme280.py
  2. main.py

The library to read from the BME280 sensor isn’t part of the standard MicroPython library by default. So, you need to upload the BME280 MicroPython library to your Raspberry Pi Pico W Board. The library has all the required modules and registers details to extract the data from the Sensor.


bme280.py

Open your Thonny IDE and paste the following code to the Thonny Editor. Save the file in the Raspberry Pi Pico W and name it bme280.py.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import time
from ustruct import unpack, unpack_from
from array import array
 
# BME280 default address.
BME280_I2CADDR = 0x76
 
# Operating Modes
BME280_OSAMPLE_1 = 1
BME280_OSAMPLE_2 = 2
BME280_OSAMPLE_4 = 3
BME280_OSAMPLE_8 = 4
BME280_OSAMPLE_16 = 5
 
BME280_REGISTER_CONTROL_HUM = 0xF2
BME280_REGISTER_CONTROL = 0xF4
 
 
class BME280:
 
    def __init__(self,
                 mode=BME280_OSAMPLE_1,
                 address=BME280_I2CADDR,
                 i2c=None,
                 **kwargs):
        # Check that mode is valid.
        if mode not in [BME280_OSAMPLE_1, BME280_OSAMPLE_2, BME280_OSAMPLE_4,
                        BME280_OSAMPLE_8, BME280_OSAMPLE_16]:
            raise ValueError(
                'Unexpected mode value {0}. Set mode to one of '
                'BME280_ULTRALOWPOWER, BME280_STANDARD, BME280_HIGHRES, or '
                'BME280_ULTRAHIGHRES'.format(mode))
        self._mode = mode
        self.address = address
        if i2c is None:
            raise ValueError('An I2C object is required.')
        self.i2c = i2c
 
        # load calibration data
        dig_88_a1 = self.i2c.readfrom_mem(self.address, 0x88, 26)
        dig_e1_e7 = self.i2c.readfrom_mem(self.address, 0xE1, 7)
        self.dig_T1, self.dig_T2, self.dig_T3, self.dig_P1, \
            self.dig_P2, self.dig_P3, self.dig_P4, self.dig_P5, \
            self.dig_P6, self.dig_P7, self.dig_P8, self.dig_P9, \
            _, self.dig_H1 = unpack("<HhhHhhhhhhhhBB", dig_88_a1)
 
        self.dig_H2, self.dig_H3 = unpack("<hB", dig_e1_e7)
        e4_sign = unpack_from("<b", dig_e1_e7, 3)[0]
        self.dig_H4 = (e4_sign << 4) | (dig_e1_e7[4] & 0xF)
 
        e6_sign = unpack_from("<b", dig_e1_e7, 5)[0]
        self.dig_H5 = (e6_sign << 4) | (dig_e1_e7[4] >> 4)
 
        self.dig_H6 = unpack_from("<b", dig_e1_e7, 6)[0]
 
        self.i2c.writeto_mem(self.address, BME280_REGISTER_CONTROL,
                             bytearray([0x3F]))
        self.t_fine = 0
 
        # temporary data holders which stay allocated
        self._l1_barray = bytearray(1)
        self._l8_barray = bytearray(8)
        self._l3_resultarray = array("i", [0, 0, 0])
 
    def read_raw_data(self, result):
        """ Reads the raw (uncompensated) data from the sensor.
 
            Args:
                result: array of length 3 or alike where the result will be
                stored, in temperature, pressure, humidity order
            Returns:
                None
        """
 
        self._l1_barray[0] = self._mode
        self.i2c.writeto_mem(self.address, BME280_REGISTER_CONTROL_HUM,
                             self._l1_barray)
        self._l1_barray[0] = self._mode << 5 | self._mode << 2 | 1
        self.i2c.writeto_mem(self.address, BME280_REGISTER_CONTROL,
                             self._l1_barray)
 
        sleep_time = 1250 + 2300 * (1 << self._mode)
        sleep_time = sleep_time + 2300 * (1 << self._mode) + 575
        sleep_time = sleep_time + 2300 * (1 << self._mode) + 575
        time.sleep_us(sleep_time)  # Wait the required time
 
        # burst readout from 0xF7 to 0xFE, recommended by datasheet
        self.i2c.readfrom_mem_into(self.address, 0xF7, self._l8_barray)
        readout = self._l8_barray
        # pressure(0xF7): ((msb << 16) | (lsb << 8) | xlsb) >> 4
        raw_press = ((readout[0] << 16) | (readout[1] << 8) | readout[2]) >> 4
        # temperature(0xFA): ((msb << 16) | (lsb << 8) | xlsb) >> 4
        raw_temp = ((readout[3] << 16) | (readout[4] << 8) | readout[5]) >> 4
        # humidity(0xFD): (msb << 8) | lsb
        raw_hum = (readout[6] << 8) | readout[7]
 
        result[0] = raw_temp
        result[1] = raw_press
        result[2] = raw_hum
 
    def read_compensated_data(self, result=None):
        """ Reads the data from the sensor and returns the compensated data.
 
            Args:
                result: array of length 3 or alike where the result will be
                stored, in temperature, pressure, humidity order. You may use
                this to read out the sensor without allocating heap memory
 
            Returns:
                array with temperature, pressure, humidity. Will be the one from
                the result parameter if not None
        """
        self.read_raw_data(self._l3_resultarray)
        raw_temp, raw_press, raw_hum = self._l3_resultarray
        # temperature
        var1 = ((raw_temp >> 3) - (self.dig_T1 << 1)) * (self.dig_T2 >> 11)
        var2 = (((((raw_temp >> 4) - self.dig_T1) *
                  ((raw_temp >> 4) - self.dig_T1)) >> 12) * self.dig_T3) >> 14
        self.t_fine = var1 + var2
        temp = (self.t_fine * 5 + 128) >> 8
 
        # pressure
        var1 = self.t_fine - 128000
        var2 = var1 * var1 * self.dig_P6
        var2 = var2 + ((var1 * self.dig_P5) << 17)
        var2 = var2 + (self.dig_P4 << 35)
        var1 = (((var1 * var1 * self.dig_P3) >> 8) +
                ((var1 * self.dig_P2) << 12))
        var1 = (((1 << 47) + var1) * self.dig_P1) >> 33
        if var1 == 0:
            pressure = 0
        else:
            p = 1048576 - raw_press
            p = (((p << 31) - var2) * 3125) // var1
            var1 = (self.dig_P9 * (p >> 13) * (p >> 13)) >> 25
            var2 = (self.dig_P8 * p) >> 19
            pressure = ((p + var1 + var2) >> 8) + (self.dig_P7 << 4)
 
        # humidity
        h = self.t_fine - 76800
        h = (((((raw_hum << 14) - (self.dig_H4 << 20) -
                (self.dig_H5 * h)) + 16384)
              >> 15) * (((((((h * self.dig_H6) >> 10) *
                            (((h * self.dig_H3) >> 11) + 32768)) >> 10) +
                          2097152) * self.dig_H2 + 8192) >> 14))
        h = h - (((((h >> 15) * (h >> 15)) >> 7) * self.dig_H1) >> 4)
        h = 0 if h < 0 else h
        h = 419430400 if h > 419430400 else h
        humidity = h >> 12
 
        if result:
            result[0] = temp
            result[1] = pressure
            result[2] = humidity
            return result
 
        return array("i", (temp, pressure, humidity))
 
    @property
    def values(self):
        """ human readable values """
 
        t, p, h = self.read_compensated_data()
 
        p = p // 256
        pi = p // 100
        pd = p - pi * 100
 
        hi = h // 1024
        hd = h * 100 // 1024 - hi * 100
        return ("{}*C".format(t / 100), "{}.{:02d} hPa".format(pi, pd),
                "{}.{:02d} %".format(hi, hd))




main.py

The code for creating a Raspberry Pi Pico W-based Web Server Weather Station is simple. In the following code change the WiFi SSID and password.

1
wlan.connect("**********","**********")

Save the file to Raspberry Pi Pico W with the name main.py or anything else.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from machine import Pin, I2C        #importing relevant modules & classes
from time import sleep
import utime
import socket
import network
import bme280                       #importing BME280 library
 
i2c=I2C(0,sda=Pin(20), scl=Pin(21), freq=400000)    #initializing the I2C method
 
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("**********","**********")
 
def web_page():
    bme = bme280.BME280(i2c=i2c)          #BME280 object created
    html = """<html><head><meta http-equiv="refresh" content="5"><meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" href="data:,"><style>body { text-align: center; font-family: "Helvetica", Arial;}
  table { border-collapse: collapse; width:55%; margin-left:auto; margin-right:auto; }
  th { padding: 12px; background-color: #87034F; color: white; }
  tr { border: 2px solid #000556; padding: 12px; }
  tr:hover { background-color: #bcbcbc; }
  td { border: none; padding: 14px; }
  .sensor { color:DarkBlue; font-weight: bold; background-color: #ffffff; padding: 1px;  
  </style></head><body><h1>BME280 Pi Pico W Weather Station</h1>
  <table><tr><th>Parameters</th><th>Value</th></tr>
  <tr><td>Temperature</td><td><span class="sensor">""" + str(bme.values[0]) + """</span></td></tr>
  <tr><td>Pressure</td><td><span class="sensor">""" + str(bme.values[1]) + """</span></td></tr>
  <tr><td>Humidity</td><td><span class="sensor">""" + str(bme.values[2]) + """</span></td></tr>
  
  <head><meta http-equiv="refresh" content="5"><meta name="viewport" content="width=device-width, initial-scale=1"><style>img{display: block; margin-left: auto; margin-right: auto;}</style></head><body><img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gIoSUNDX1BST0ZJTEUAAQEAAAIYAAAAAAQwAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAAHRyWFlaAAABZAAAABRnWFlaAAABeAAAABRiWFlaAAABjAAAABRyVFJDAAABoAAAAChnVFJDAAABoAAAAChiVFJDAAABoAAAACh3dHB0AAAByAAAABRjcHJ0AAAB3AAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAFgAAAAcAHMAUgBHAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFhZWiAAAAAAAABvogAAOPUAAAOQWFlaIAAAAAAAAGKZAAC3hQAAGNpYWVogAAAAAAAAJKAAAA+EAAC2z3BhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABYWVogAAAAAAAA9tYAAQAAAADTLW1sdWMAAAAAAAAAAQAAAAxlblVTAAAAIAAAABwARwBvAG8AZwBsAGUAIABJAG4AYwAuACAAMgAwADEANv/bAEMAAwICAgICAwICAgMDAwMEBgQEBAQECAYGBQYJCAoKCQgJCQoMDwwKCw4LCQkNEQ0ODxA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LWshKUpHkknsAPcnsNIvcy7l37WKfadpQ5E8IkemwlhlTjsyS4QlKW0DKj7JSkDJJPbuADtJJsqHjzDFAosn7zKnw41xlAJNzccG9rdVtqf1A8YyU1W2fVkAfU5HlekhR+/FSFYz+Dj7AayKLdu7G8txMWLtBZc+ZVpufSi01pUmUUDGVFeAEITnJXhIGck6eXTh8KTf/eCRGrG5sZe2tsr4uLcqUfnU30lIIDUTIKCcgEvFHHJPFRHE25dPnTNtB0x2mq1NqLZRC+a9NVRqUgh2fUnEAhK5D2AVY5KIQAltJWrilPI5PkF7qgx8c1+Yge7PmDltbSwNvMC/wB1Cfon+FKxZlThbr9TyYdVrcZ1Mmm2q2oPxIyxgpdmL7pecB7hpOWxxBUpzkUosv0aNHVTJJNyjRo0aC4jRo0aCCNGjRoII1C7rV+GzYnU7Lf3Dsmox7Q3EUgB6YWiqFVuKQECUlP1JWAAA8gFQT2UlzCeJo0EFWFenT91k9Ojy6fdm1twyKXFSVCXFhqqVPDYxk+uzyDY7jsSk/jS+/473K4v5Rq26f65PAJCHSrl4wE8/wDTRo0V0NpU/JYsrMlC8KBMODRoBe9h2vsmHY/S91l9SMxiFR9s6/Dpbykr+dqsZVLpyEEHC+boT6gGD/AFq/Hfvaj0VfDy296VI6Lvrsxi69w5DXFyrrY4MU4KThbUNCiSkHJSXVYWsDw2CUaNGugW2UTNzkxPRTFmXlzjyTcqXejRo11NkaNGjQQRo0aNBBf/2Q==" alt="pico" style="max-width:100%;">
  </body></html>"""
    return html
  
# Wait for connect or fail
wait = 10
while wait > 0:
    if wlan.status() < 0 or wlan.status() >= 3:
        break
    wait -= 1
    print('waiting for connection...')
    time.sleep(1)
 
# Handle connection error
if wlan.status() != 3:
    raise RuntimeError('wifi connection failed')
else:
    print('connected')
    ip=wlan.ifconfig()[0]
    print('IP: ', ip)
    
# Open socket
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('', 80))
server.listen(5)
print('listening on', addr)
    
while True:
    try:
        conn, addr = server.accept()
        conn.settimeout(3.0)
        print('client connected from', addr)
        request = conn.recv(1024)
        conn.settimeout(None)
        # HTTP-Request receive
        print('Request:', request)              
        # HTTP-Response send
        response = web_page()
        conn.send('HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n')
        conn.sendall(response)
        conn.close()
    except OSError as e:
        conn.close()
        print('connection closed')




Testing IoT Based BME280 Web Server Weather Station

In this project, we’ll display sensor readings from the BME280 temperature, humidity and pressure sensor on a web server that you can access on your local network.

Run the above code. The Raspberry Pi Pico W will connect to the WiFi Network using the given network credentials. Then the Python Shell will display the IP Address of the Raspberry Pi Pico W.

Copy the IP Address and paste it on your Web Browser and hit enter. You should get a page with the latest sensor readings as shown in the following figure.

With the web server script provided in this project, you don’t need to refresh the web page to see the latest readings as the web page refreshes automatically after an interval of every 5 seconds.

On the Python Shell, you will able to see the following messages and response together.

You can check the Sensor reading even from multiple devices at the same time.

BME280 Raspberry Pi Pico W Web Server

You can use a similar code to display the sensor reading on a Web Server.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleInterface BME280 with Raspberry Pi Pico using MicroPython
Next Article Arduino AC Voltage Protection & Monitoring System | Under, Normal & Over Voltage

Related Posts

ADXL375 Accelerometer with Raspberry Pi Pico & MicroPython

ADXL375 Accelerometer with Raspberry Pi Pico & MicroPython

Updated:July 24, 2025
Interface BMI160 with Raspberry Pi Pico & MicroPython

Interface BMI160 with Raspberry Pi Pico & MicroPython

Updated:February 2, 20253K
Shift Register 74HC595 with Raspberry Pi Pico & MicroPython

Shift Register 74HC595 with Raspberry Pi Pico & MicroPython

Updated:February 2, 202513K
Interfacing XBee Module with Raspberry Pi Pico & MicroPython

Interfacing XBee Module with Raspberry Pi Pico & MicroPython

Updated:February 2, 20253K
Modbus RTU with Raspberry Pi Pico & Micropython

Modbus RTU with Raspberry Pi Pico & MicroPython

Updated:February 2, 20258K
Fever Detector with MLX90640 & OpenCV Raspberry Pi

Thermal Fever Detector with MLX90640 & OpenCV Raspberry Pi

Updated:February 2, 20256K
View 9 Comments

9 Comments

  1. Vlad on January 3, 2023 10:56 AM

    When I try to open webpage from IP, it says ” This page isn’t working” ; “192.168.100.15 didn’t send any data” and “ERR_EMPTY_RESPONSE”.

    Reply
  2. ineshed on January 11, 2023 12:15 PM

    Thank you. That looks interesting. I have a similar problem to Vlad. The page does not display in the browser. The messages in the Thonny confirm that the client has connected. If I remove the first line in def web_page (bme = bme.280…) and related instructions in the table, then the page displays, so is there a problem with bme280.py, or is it with my sensor?

    Reply
  3. Jon on March 12, 2023 4:47 PM

    Having an issue where it won’t start on boot, yet will work if I run the script from Thonny. Any ideas?

    Reply
  4. iarus on April 26, 2023 8:46 AM

    Vlad/ineshed – Same results here. Connects OK but browser message is “This page isn’t working 192.168.1.66 didn’t send any data.
    ERR_EMPTY_RESPONSE”

    Has this been resolved yet? How can I tell if any data was sent?

    Reply
  5. Tim Albin on June 25, 2023 3:32 PM

    I have reflashed the Pico W several times. This error will come up after the first run. I copied the code, inserted my wireless information. This error in line 41 is something I cannot get past trying other editors. Any help would be appreciated.

    MPY: soft reboot
    waiting for connection…
    Traceback (most recent call last):
    File “”, line 6, in
    File “bme280.py”, line 41, in
    NameError: name ‘time’ isn’t defined

    Reply
  6. Tim Albin on June 25, 2023 3:33 PM

    I have reflashed the Pico W several times. This error will come up after the first run. I copied the code, inserted my wireless information. This error in line 41 is something I cannot get past trying other editors. Any help would be appreciated.

    MPY: soft reboot
    waiting for connection…
    Traceback (most recent call last):
    File “”, line 6, in
    File “bme280.py”, line 41, in
    NameError: name ‘time’ isn’t defined

    Reply
  7. Tim Albin on June 25, 2023 9:15 PM

    I at least have it running without errors. However I am seeing this: This connected address is a router address. And the listening address? cannot log into to see the web page.

    %Run -c $EDITOR_CONTENT

    MPY: soft reboot
    connected
    IP: 192.168.1.227
    listening on (‘0.0.0.0’, 80)

    Reply
  8. Hub on October 6, 2023 1:42 PM

    Line 41 error – it should read uptime rather than time to activate the sleep command.
    Worked for me!

    Reply
  9. marco on March 8, 2025 5:16 PM

    i had the same Problem with main.py “not starting” when not connected to thonny. There seems to be a Problem in “# Wait for connect or fail” and “# Handle connection error” i changed uptime in line 42 to utime and ip=wlan.ifconfig()[0] in line 50 to ip = wlan.ifconfig()[0]. now its working without thonny

    Reply

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
    IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.