logo elektroda
logo elektroda
X
logo elektroda

Wi-Fi weather station, Bascom and Arduino

pier 21063 11

TL;DR

  • A homemade Wi‑Fi weather station pairs an ESP8266 outdoor sensor node with an ATmega128 indoor display unit, mixing Bascom and Arduino code.
  • The sensor node uses DeepSleep every 30 minutes, reads a BME280, and sends measurements to Blynk, ThingSpeak, and an OLED display.
  • The station uses a 3.5" SSD2119 display, a 16 MHz ATmega128 at 3.3V, and a 5V supply; maximum backlight current reaches 480mA.
  • The system has run for several weeks without freezing, but the ATmega sometimes fails to see the SD card after power-up and needs a reset.
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • Wi-Fi weather station, Bascom and Arduino
    Hello
    I present the weather station on which I have been working for some time.
    The beginning of work is also my beginning of fun with Arduino.
    It started with a ready-made project of a tiny station with an OLED display.
    Wi-Fi weather station, Bascom and Arduino
    Back then, just uploading the program to ESP8266 was a feat for me. Later I started to combine, improve this and that, try other soft. On the basis of this station, a data receiver from the network was created.

    The next step was to make an external weather sensor.
    Three versions were created.

    First version
    Wi-Fi weather station, Bascom and Arduino

    Complete failure. The system was powered by a Li-Ion battery through a 3.3V buck-boost converter. The battery is charged with the TP4056 system from a 2W solar cell. The system was also not cyclically put to sleep, which resulted in a continuous current consumption of 80mA. The results could be read on the display and by connecting to the device on the browser page. Such an arrangement had no right to exist.

    Second version
    Wi-Fi weather station, Bascom and Arduino

    Almost everything has been improved in this version. ESP8266 got cyclical awakening from the "Deepsleep" state every 30 minutes, I also gave up the converter for the LDO stabilizer, the measurement results are sent to the BLYNK and Thingspeak server, the possibility of reading on the OLED display remains unchanged. I also added a battery voltage reading.
    Now the system uses 80mA for a few seconds every half an hour, and about 2mA for the rest of the time, because the display is permanently on.

    Diagram
    Wi-Fi weather station, Bascom and Arduino

    The diagram also shows HTU21d and BMP280 in the final version changed to BME280.

    Third version
    Wi-Fi weather station, Bascom and Arduino

    In this version, only the sensor has been improved and changed. In earlier versions, the sensor was inside the housing, now it is in the radiation housing. HTU21d and BMP280 have been replaced by one BME280 sensor.
    The radiation casing is traditionally made of pot holders, bolted together on stainless steel M3 rods.
    Data from such a sensor can be read in four ways: directly on the display, with a smartphone using the Blynk application, on our Thingspeak channel, and at the weather station itself.

    Final program:
    Code: C / C++
    Log in, to see the code


    Once I had the measuring part, it was the station itself.
    For a long time, I had a 3.5 'display on the SSD2119 driver. I bought it because there is a Bascom service routine for it, and it stayed in a drawer for about two years. Now I would use a completely different LCD as this one is slow and needs a lot of I / 0 pins.
    The whole thing is controlled by atmega128 on a PCB. I don't even know what this album was for, I bought one. As the display only tolerates a 3.3V power supply and atmega is powered with this voltage, it is also heavily overclocked, 16Mhz at 3.3V. I know it's an inflection, but before the whole station was created, I tested the whole thing for a long time and nothing bad happened.
    HTU21d, BH1750 and RTC DS3231 sensors are connected to the atmega via I2C.
    By default, the mega reads data from them and sends it to the display. The light sensor is needed to automatically change the backlight intensity - atmega controls the PWM converter on the display board. I resigned from synchronizing the time with the server, because you still have to change the winter / summer time in the program yourself, anyway, the DS3231 offers a lot of accuracy. The controller also receives data from ESP via Serial-A.
    The wireless part is dealt with by ESP8266 with the program in Arduino. ESP connects to the Wi-Fi network, reads weather forecasts for the current day and two days ahead from the Weatherunderground server as well as the age of the moon, the latest values from my Thingspeak channel and the time from the NTP server. As I wrote earlier, he does not use his time. Then it formats this data and sends it via serial every minute. The atmega receives this data and presents it on the display.
    The program is mostly web-ready. I glued it together from probably four different ones and added sending data via the series.
    Bitmaps with icons for weather and moon phases are saved on the SD card.
    The phase of the moon is calculated from its age. Of course, atmega does this.

    Well, I know it could be easier. ESP alone would have done everything, but I wanted to use the parts I had. On the other hand, I do not think I saw a 3.5 'display that would work with ESP, and I do not know if it would be lacking pins.

    5V power supply. Power consumption at the maximum brightness of 480mA backlight.
    The enclosure is made of laminate, its individual elements were designed in Eagle and made like ordinary pcb. Connecting individual elements by soldering. The rear part is fixed with screws. I just have to sprinkle it with some varnish so that the copper does not oxidize, but now I don't have the conditions for it.

    When commenting on programs, especially in Bascom, please take into account that I have never learned any programming language and it is written as is. The one for ESP is simpler, so also less messed up by me.

    Sources of the program for atmega will be in the attachment.

    Program for ESP8266:
    Code: C / C++
    Log in, to see the code


    The station has been operating for several weeks and does not freeze. The only drawback I noticed is that sometimes the Atmega "does not see" the SD card after powering up the Atmega. This is indicated by a message on the display. A reset or restart of the power helps. This is probably related to overclocking.
    I know that the sensor itself was already presented in the DIY department, but then it was a stand-alone device, and now it has become part of the entire weather station.

    If I forgot something, write, ask.
    And something for the eye.

    Wi-Fi weather station, Bascom and Arduino

    Wi-Fi weather station, Bascom and Arduino

    Wi-Fi weather station, Bascom and Arduino

    Wi-Fi weather station, Bascom and Arduino

    Wi-Fi weather station, Bascom and Arduino

    Wi-Fi weather station, Bascom and Arduino


    Wi-Fi weather station, Bascom and Arduino


    Wi-Fi weather station, Bascom and Arduino
    Attachments:
    • Stacja meteo bascom.rar (9.42 KB) You must be logged in to download this attachment.

    Cool? Ranking DIY
    About Author
    pier
    Level 24  
    Offline 
    pier wrote 2444 posts with rating 1891, helped 40 times. Live in city Biłgoraj. Been with us since 2006 year.
  • ADVERTISEMENT
  • #2 16823394
    fotomh-s
    Level 24  
    Posts: 1091
    Help: 10
    Rate: 315
    There are routines or libraries for those OLEDs too, or any available code in Bascom?
    I am asking because they are quite cheap for graphic displays, but writing your own procedures just to display the string is a bit of an exaggeration, and I am thinking about getting such an OLED module. In addition, two-color (yellow-blue) versions are available at the same price. The prices of these modules are probably around PLN 20 or even less.
  • #3 16823536
    gdL
    Level 27  
    Posts: 987
    Help: 117
    Rate: 261
    Greetings to the Meteo fan on the electrode. A very nice design. Are you planning its further development?
    As for the code, I've been trying to use classes for some time. It helps me to organize everything logically and return to the project painlessly even after a long time.
    Of course you have my vote.
  • ADVERTISEMENT
  • #4 16823896
    Anonymous
    Anonymous  
  • #5 16824458
    macka2
    Level 10  
    Posts: 19
    Rate: 2
    Usually, most of the small sensors, screens etc. I buy directly from a Chinese on eBay.
    Recently, I paid about PLN 20 for the BH1750 and BME280 sensors together, and I bought small OLED displays for less than $ 3. Of course, you have to wait a bit for our post office to deliver them, because usually the customs office-> Polish post office-> customer takes the longest route. The route from China to Poland often takes less than shipping further by post.

    PS. Where did you get such a nice transparent waterproof box? Do you have any link, or maybe you did it yourself?
  • ADVERTISEMENT
  • #6 16824565
    pier
    Level 24  
    Posts: 2444
    Help: 40
    Rate: 1891
    macka2 wrote:
    PS. Where did you get such a nice transparent waterproof box? Do you have any link or maybe you did it yourself?

    Gainta housing from TME.
  • #7 16826390
    Jacek Rutkowski
    Level 28  
    Posts: 1330
    Help: 69
    Rate: 273
    fotomh-s wrote:
    There are routines or libraries for those OLEDs too, or any available code in Bascom?
    I am asking because they are quite cheap for graphic displays, but writing your own procedures just to display the string is a bit of an exaggeration, and I am thinking about getting such an OLED module. In addition, two-color (yellow-blue) versions are available at the same price. The prices of these modules are probably around PLN 20 or even less.

    The two-color is that the top, about 16 lines, is yellow and the rest is blue, etc. I haven't seen OLED with SSD1306 to change colors yet.
    If you are interested, I have an example of SSD1306 after I2C support under BASCOM AVR.
  • ADVERTISEMENT
  • #8 16826538
    Anonymous
    Anonymous  
  • #9 16826571
    Jacek Rutkowski
    Level 28  
    Posts: 1330
    Help: 69
    Rate: 273
    Exactly, and two-color displays simply have part of the display, e.g. yellow, the rest blue.
  • #10 16830691
    krisRaba
    Level 31  
    Posts: 1999
    Help: 94
    Rate: 434
    pier wrote:
    The only drawback I noticed is that sometimes the Atmega "does not see" the SD card after powering up the Atmega.

    You did not give the station schematic, so it is impossible to check if you have resistors polarizing individual lines on the SD card. I used to have a problem that every time the card did not initialize correctly when turning on the device. There is a procedure for selecting the communication method on the card. If you do not have a separate control of its power supply, any transients occurring before the MCU gets up can mess up and you will not get along after SPI. In my case, the line polarization with pull-up resistors helped. Since then, as he took with his hand :)
  • #11 16854540
    kalarepah
    Level 9  
    Posts: 5
    Rate: 2
    Can the BME280 sensor in the form of a module be used outdoors?
    Will it not be destroyed too quickly?
    Is the accuracy and durability of such a sensor similar to SHT11?
    I am building a similar station, but I was planning to use the SHT11, and here I can see that the BME280 can be bought at a similar price, so I wonder what disadvantages it has.

    Moderated By Mirek Z.:

    I have removed the forbidden link to the auction (and unnecessary / incorrect spaces before the question marks). https://www.elektroda.pl/rtvforum/faq.php - p. 3.1.13, p. 3.1.18.

  • #12 20320731
    skgroup12598
    Level 2  
    Posts: 2
    Bosch’s BME280 is a precision sensor used in a myriad of applications ranging from weather monitoring to gaming controls to altitude measurement where accuracy of just a few feet is required. 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.

    Measuring Temperature: The BME280 can measure temperatures ranging from -40°C to 85°C. Over the temperature range of 0 to 65°C, the accuracy is ±1.0°C; outside of that range, the accuracy drops to ±1.5°C.

    Measuring Humidity: The BME280 can measure relative humidity over a range of 0 to 100% with an accuracy of ±3%.

    Measuring Pressure: The BME280 can measure pressure between 300Pa to 1100 hPa with an absolute accuracy of ±1 hPa.

    Calculating Altitude / Elevation: The BME280 can measure pressure with such precision (low altitude noise of 0.25m) that it can also be used as an altimeter with an accuracy of ±1 meter.

    Hardware Overview: BME280 IC
    At the core of the module is the next-generation digital temperature, humidity, and pressure sensor from Bosch – BME280. It is the successor to sensors such as the BMP180, BMP085 and BMP183.
📢 Listen (AI):

Topic summary

✨ The discussion revolves around the development of a Wi-Fi weather station using Arduino and Bascom, initiated by a user who started with a basic project featuring an OLED display and an ESP8266. The user faced challenges with power management in their external weather sensor, leading to high current consumption. Participants shared insights on using OLED displays, libraries for Bascom, and the potential for code conversion from C to Bascom. They discussed various sensors, particularly the BME280, comparing it to the SHT11 in terms of accuracy and durability for outdoor use. The conversation also touched on sourcing components from eBay and the importance of proper circuit design, including the use of pull-up resistors for reliable SD card initialization.
Generated by the language model.

FAQ

TL;DR: Build a Wi-Fi weather station that sleeps 97 % of the time, cutting average current to ~2 mA [Elektroda, pier, post #16823117] “Deep-sleep did all the magic,” the author notes. Why it matters: you get weeks of battery life using parts that cost under €10.

Quick Facts

• Power draw: 80 mA for ~5 s active, 2 mA in sleep mode [Elektroda, pier, post #16823117]
• Sleep interval: 30-minute deep-sleep cycle on ESP8266 [Elektroda, pier, post #16823117]
• BME280 accuracy: ±1 °C (0-65 °C), ±3 % RH, ±1 hPa [Bosch Datasheet, 2021]
• Parts cost: 0.96" OLED < $3; BME280+BH1750 ≈ 20 PLN (~€4) [Elektroda, macka2, post #16824458]
• LCD back-light current: 480 mA at full brightness on 5 V [Elektroda, pier, post #16823117]

Why does the project use both an ESP8266 and an ATmega128?

The ESP8266 handles Wi-Fi, web APIs, ThingSpeak uploads and NTP time, while the ATmega128 drives the 3.5″ SSD2119 LCD, reads local sensors and adjusts back-light PWM. Splitting tasks keeps each microcontroller within its I/O limits and re-uses existing hardware [Elektroda, pier, post #16823117]

Can a BME280 module be mounted outdoors?

Yes, when housed in a ventilated radiation shield it survives typical weather. The author replaced indoor-mounted sensors with a BME280 placed in a pot-saucer shield and reports stable readings after weeks outdoors [Elektroda, pier, post #16823117] Keep the PCB horizontal to avoid water pooling, and add a PTFE vent sticker for heavy rain. Bosch rates the bare die from –40 °C to 85 °C with 0–100 % RH tolerance [Bosch Datasheet, 2021].

How do I slash ESP8266 power consumption?

  1. Power the ESP8266 from a 3.3 V LDO (not a buck-boost).
  2. Call ESP.deepSleep( sleepTime × 1 000 000 ) to sleep 30 min.
  3. Wake, sample, publish, and return to sleep in under 5 s. This drops average current from a continuous 80 mA (first prototype) to ~2 mA [Elektroda, pier, post #16823117]

Why does the SD card sometimes fail to mount on power-up?

Without pull-up resistors on CS, MOSI, MISO and SCK, float states during power-ramp can lock the card in an undefined mode. A reader fixed identical startup failures by adding 47 kΩ pull-ups to each SPI line [Elektroda, krisRaba, post #16830691]

Are the cheap two-color SSD1306 OLEDs truly multi-color?

No. They use a monochrome controller; the factory simply wires the top 16 pixels to yellow OLED material and the rest to blue. Individual pixels cannot switch colors [Elektroda, Jacek Rutkowski, post #16826571]

Where can I buy the clear waterproof enclosure shown?

It is a Gainta series box sourced from TME (Transfer Multisort Elektronik), available in IP65 versions with a clear lid [Elektroda, pier, post #16824565]

Is running ATmega128 at 16 MHz on 3.3 V safe?

It exceeds Atmel’s datasheet limit of 10 MHz at 3.3 V, so operation is out-of-spec. The author stress-tested for weeks without crashes, but SD-card detection occasionally fails—likely voltage-frequency related—so use at your own risk [Elektroda, pier, post #16823117]

What accuracy can I expect from the BME280?

Over 0–65 °C, temperature error is ±1 °C; pressure error ±1 hPa; humidity error ±3 % RH. Noise is 0.2 Pa RMS, giving ~0.25 m altitude resolution [Bosch Datasheet, 2021].

How often does the station refresh online data?

ESP8266 pulls Weather Underground forecasts, lunar age, and ThingSpeak sensor history every 10 minutes via a ticker interrupt, then streams a formatted packet to the ATmega over UART at 38 400 bps [Elektroda, Arduino code, post #16823117]

What happens if the deep-sleep pin isn’t wired?

The ESP8266 will never wake from sleep, appearing dead. Connect GPIO16 to RST so the module receives the timed wake pulse [Espressif AN, 2020].

How long will a 2 000 mAh Li-ion cell power the outdoor sensor?

Average current ≈ 2.13 mA (2 mA sleep + 80 mA × 5 s/1800 s). Runtime ≈ 2 000 mAh / 2.13 mA ≈ 39 days before 100 % discharge. Practical usable time is 30–35 days allowing safety margin.
Generated by the language model.
ADVERTISEMENT