Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Python, how to DIY a small family weather station

Shulou Source: shulou.com Published: 2022-06-01 04:04:19 09月30日 Update

This article mainly introduces the relevant knowledge of Python how to DIY small family weather station, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this Python how to DIY small family weather station article. Let's take a look at it.

BMP180 has always been a common air pressure sensor. BMP180 is a pressure sensor with high precision, small volume and ultra-low energy consumption, which can be used in mobile devices. It has excellent performance, the lowest accuracy can reach 0.03hPa, and the power consumption is only 3 μ A; BMP180 uses powerful 8-pin ceramic leadless chip carrier (LCC) ultra-thin package, which can be directly connected to a variety of microprocessors through the I2C bus.

We use TPYBoardv102 and BMP180 pressure sensors and OLED LCD screen to make a simple home weather station to detect the indoor air pressure, temperature and local altitude. Interested friends can access other sensors and display them on OLED.

BMP180 physical diagram

TPYBoardv102 physical diagram

Effect display diagram

After the connection is completed, import the library of font.py,ssd1306.py and bmp180, and you can read the temperature, air pressure and altitude respectively by the following methods.

From bmp180 import BMPbmp=BMP180 (1) tem=bmp.getTemp () press=bmp.getPress () altitude=bmp.getAltitude ()

Import the required class library, edit main.py, and run ok directly. Here is the program source code of main.py.

Import pybfrom ssd1306 import SSD1306from bmp180 import BMP180bmp=BMP180 (1) display = SSD1306 (pinout= {'dc':' Y9, 'res':' Y10'}, height=64 External_vcc=False) while 1: tem=bmp.getTemp () press=bmp.getPress () altitude=bmp.getAltitude () display.poweron () display.init_display () display.draw_text (1 display.draw_text (tem), size=1,space=1) display.draw_text (60 display.draw_text) (space=1) display.draw_text (60pcr (altitude), size=1,space=1) display.draw_text # shows what you want to display display.display () pyb.delay (3000) about "how to DIY a small family weather station in Python". Thank you for reading! I believe you all have a certain understanding of the knowledge of "Python how to DIY a small family weather station". If you want to learn more, you are welcome to follow the industry information channel.

Tags: Home meteorology weather station sensor air pressure content knowledge can pass physical object altitude temperature article height excellence power minimum value interest pressure only Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Linux Shulou Technology macOS Docker