In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what is the method of Python development board DIY small family weather station". In daily operation, I believe many people have doubts about the method of DIY small family weather station on Python development board. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "what is the method of DIY small family weather station on Python development board". Next, please follow the editor to study!
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.
BMP180 physical diagram
Hardware wiring diagram
TPYBoard v702
BMP180
3.3V
VIN
GND
GND
Y9
SCL
Y10
SDA
Effect display diagram
After the connection is completed, import the library of font.py,upcd8544.py and bmp180, and you can read the temperature, air pressure and altitude respectively by the following methods.
Import the required class library, edit main.py, and run ok directly. Here is the program source code of main.py.
# main.py-- put your code hereafter imports pybimport upcd8544from machine import SPI,Pinfrom ubinascii import hexlifyfrom ubinascii import * from bmp180 import BMP180bmp=BMP180 (2) SPI = pyb.SPI (1) # DIN= > X8 Mosi data flow CLK = > X6-SCK#DIN = > SPI (1). MOSI 'X8' data flow (Master out) Slave in) # CLK = > SPI (1). SCK 'X6' SPI clockRST = pyb.Pin (' X20') CE = pyb.Pin ('X19') DC = pyb.Pin (' X18') LIGHT = pyb.Pin ('X17') lcd_5110 = upcd8544.PCD8544 (SPI, RST, CE, DC, LIGHT) while True: tem=bmp.getTemp () press=bmp.getPress () altitude=bmp.getAltitude () lcd_5110.lcd_write_string (' Tem:') 0) lcd_5110.lcd_write_string (str (tem), 0 lcd_5110.lcd_write_string 1) lcd_5110.lcd_write_string ('lcd_5110.lcd_write_string (' Press:',0,2) lcd_5110.lcd_write_string (str (press), 0) lcd_5110.lcd_write_string ('Pa',65,3) lcd_5110.lcd_write_string (' Hight:') 0self 4) lcd_5110.lcd_write_string (str (altitude), 0je 5) lcd_5110.lcd_write_string ('Maurejia 65 page5) the source code of bmp180.py library import pybfrom pyb import I2CBMP180_I2C_ADDR = const (0x77) class BMP180 (): def _ init__ (self, i2c_num): self.i2c = I2C (i2c_num, I2C.MASTER) Baudrate = 100000) self.AC1 = self.short (self.get2Reg (0xAA)) self.AC2 = self.short (self.get2Reg (0xAC)) self.AC3 = self.short (self.get2Reg (0xAE)) self.AC4 = self.get2Reg (0xB0) self.AC5 = self.get2Reg (0xB2) self.AC6 = self.get2Reg (0xB4) self.B1 = self.short ) self.B2 = self.short (self.get2Reg (0xB8)) self.MB = self.short (self.get2Reg (0xBA)) self.MC = self.short (self.get2Reg (0xBC)) self.MD = self.short (self.get2Reg (0xBE)) self.UT = 0 self.UP = 0 self.B3 = 0 self.B4 = 0 self.B5 = 0 Self.B6 = 0 self.B7 = 0 self.X1 = 0 self.X2 = 0 self.X3 = 0 def short (self Dat): if dat > 32767: return dat-65536 else: return dat def setReg (self, dat, reg): buf = bytearray (2) buf [0] = reg buf [1] = dat self.i2c.send (buf, BMP180_I2C_ADDR) def getReg (self Reg): buf = bytearray (1) buf [0] = reg self.i2c.send (buf, BMP180_I2C_ADDR) t = self.i2c.recv (1, BMP180_I2C_ADDR) return t [0] def get2Reg (self Reg): a = self.getReg (reg) b = self.getReg (reg + 1) return aura 256 + b def measure (self): self.setReg (0x2E, 0xF4) pyb.delay (5) self.UT = self.get2Reg (0xF6) self.setReg (0x34) 0xF4) pyb.delay (5) self.UP = self.get2Reg (0xF6) def getTemp (self): self.measure () self.X1 = (self.UT-self.AC6) * self.AC5/ (1
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.