Cov txheej txheem:

Chaw Nres Tsheb Inky_pHAT: 5 Kauj Ruam
Chaw Nres Tsheb Inky_pHAT: 5 Kauj Ruam

Video: Chaw Nres Tsheb Inky_pHAT: 5 Kauj Ruam

Video: Chaw Nres Tsheb Inky_pHAT: 5 Kauj Ruam
Video: Plab Plab Ntswg..(Pluav Pluav Ntswg) Maiv Twm New Song 2023-2024 2024, Kaum ib hlis
Anonim
Inky_pHAT Weather Station
Inky_pHAT Weather Station
Inky_pHAT Weather Station
Inky_pHAT Weather Station
Inky_pHAT Weather Station
Inky_pHAT Weather Station
Inky_pHAT Weather Station
Inky_pHAT Weather Station

Kuv nyob ntawm no xav piav qhia qhov yooj yim heev thiab kev cog lus, Raspberry Pi Zero-based huab cua chaw nres tsheb, uas qhia qhov ntsuas ntsuas los ntawm BME280 qhov ntsuas kub/siab/av noo ntawm Pimoroni Inky pHAT e-paper/e-ink zaub. Txhawm rau tso cai kev sib txuas ntawm cov ntsuas thiab pHAT rau GPIO ntawm Pi Kuv tso Pimorini Pico HAT hacker nrog ob tus poj niam lub taub hau txuas ntawm GPIO thiab cov zaub. Cov cuab yeej tau siv los txuas ob peb lub ntsuas, yog li BME280 cov lus piav qhia ntawm no tsuas yog piv txwv.

Tsis zoo li cov lus qhia hauv LCD, e-ink qhia pom cov duab txawm hais tias lub zog tau raug tua. Yog li ntawd lawv yog ib qho kev daws teeb meem zoo heev yog tias koj xav qhia cov ntaub ntawv uas tau hloov kho tshiab tas li los ntawm lub sijhawm, tshwj xeeb tshaj yog los tsim cov cuab yeej siv hluav taws xob qis. Qhov txiaj ntsig tseem ceeb ntawm cov xim ib leeg/xim dub ntawm Inky pHAT yog qhov hloov kho cov duab tsuas yog siv li ib pliag xwb, hloov li kaum rau kaum tsib vib nas this uas xav tau los ntawm peb xim. Saib yeeb yaj kiab.

Adafruit's Blinka lub tsev qiv ntawv tso cai khiav Circuit Python code ntawm Raspberry Pi, thiab Circuit Python cov qauv rau ntau yam kev ntsuas tau los ntawm Adafruit. Cov lus piav qhia ntxaws li cas rau nruab Blinka thiab Circuit Python cov lej tuaj yeem pom ntawm Adafruit lub vev xaib. Cov tsev qiv ntawv kuv tau sim txog tam sim no (BMP280, BME280, TSL2591, TCS34785, VEML7065, …) tau ua haujlwm zoo heev, thaum muaj teeb meem me me hauv qee qhov piv txwv piv txwv.

BME280 yog lub ntsuas ntsuas ntsuas kub, av noo thiab huab cua siab. BMP280 kev tawm tsam muaj los ntawm ntau tus neeg muag khoom, suav nrog Adafruit, tab sis kuv nyob ntawm no tau siv tus lej Suav pheej yig. Thov nco ntsoov tias cov no siv cov chaw nyob sib txawv i2c (Adafruit: 0x77, lwm tus: 0x76).

Qhov kev tawm tsam tau txuas nrog Pi los ntawm i2c, thiab nyeem ntawv lub ntsuas tau yooj yim heev siv lub tsev qiv ntawv thiab piv txwv tus lej.

Kauj Ruam 1: Cov Khoom Siv

Cov Khoom Siv
Cov Khoom Siv
Cov Khoom Siv
Cov Khoom Siv
Cov Khoom Siv
Cov Khoom Siv
Cov Khoom Siv
Cov Khoom Siv

Raspberry Pi Zero, nrog tus txiv neej lub taub hau txuas nrog. Tab sis ib qho Raspberry Pi version yuav ua.

Pimoroni Inky pHAT, dub/monochrome version, 25 € | 22 £ | 20US $, ntawm Pimoroni.

Pimoroni Pico HAT hacker, 2.50 € | 2 £, nrog ob tus poj niam lub taub hau txuas, ib ntawm lawv yog lub taub hau txhawb nqa nrog tus pin ntev. Kuv tau tsim ob qhov sib txawv, saib cov lus piav qhia hauv qab no.

Kev tawm tsam BME280, AZ Kev xa los ntawm Amazon.de @ 7.50 €, nrog lub taub hau txuas nrog.

Elongation jumper cables

Yeem:

USB fais fab pob, rau kev siv mobile

Ib lub tsev nyob rau Pi lossis lub cuab yeej (tsis qhia ntawm no)

Kauj ruam 2: Sib dhos

Los ua ke
Los ua ke
Los ua ke
Los ua ke
Los ua ke
Los ua ke
  • Muab cov poj niam lub taub hau rau Pico HAT hacker. Ua ntej soldering, txheeb xyuas kom raug. Kuv tau tsim ob version ntawm qhov no, rau lub hom phiaj sib txawv. Ib qho nrog lub ntsej muag ntsaws lub taub hau tso rau hauv kab ua ntej thiab ib txwm muaj, nce/ntsib lub taub hau hauv kab tom qab, thiab ib qho qauv nrog lub ntsej muag tig lub taub hau txhawb rau hauv kab tom qab, thiab lub kaum sab xis poj niam lub taub hau nyob rau hauv kab ua ntej. Saib cov duab. Thawj qhov tso cai txuas thiab sib pauv cov ntsuas thiab cov kab hluav taws xob tau yooj yim heev, thaum lub khoos phis tawj nrog lub ntsej muag sab hauv nkag tau tso cai rau kaw Pi, lub ntsuas cua thiab Inky pHAT rau hauv tsev. Xwb, koj tuaj yeem txuas cov kab txuas txuas GPIO thiab ntsuas ncaj qha mus rau Pico HAT hacker thiab/lossis txuas Pico HAT hacker ncaj qha rau GPIO pins. Nyob rau hauv txhua rooj plaub siv qhov tsawg kawg nkaus ntawm cov laug cam xav tau.
  • Solder lub taub hau rau lub sensor, yog tias xav tau.
  • Tshooj hloov kho Pico HAT hacker chav ntawm Pi, tom qab ntawd ntxiv Inky pHAT. Yog xav tau, ntxig qee qhov kev txhawb nqa, piv txwv. Ua npuas ncauj thaiv lossis sawv-tawm, rau Inky pHAT.
  • Txuas cov xaim thiab lub ntsuas pa, siv 3V, GND, SDA thiab SCL cov chaw nres nkoj. Tsis yog txhua lub ntsuas hluav taws xob yuav muaj sia nyob 5V, yog li thov txheeb xyuas ua ntej koj txuas lawv rau 5V cov chaw nres nkoj.
  • Nruab Blinka lub tsev qiv ntawv, tom qab ntawd teeb tsa Circuit Python BME280 lub tsev qiv ntawv los ntawm Adafruit.
  • Nruab ib lub tsev qiv ntawv Inky pHAT los ntawm Pimoroni.
  • Nruab ib qho piv txwv Python code piav qhia hauv cov kauj ruam tom ntej thiab txuas nrog cov lus qhia no.
  • Khiav cov cai.

Kauj ruam 3: Siv Device

Siv Tus Ntaus
Siv Tus Ntaus

Muaj ob txoj hauv kev los siv lub cuab yeej.

Cov cai raws li qhia ntawm no yuav tsum pib siv lub vijtsam txuas, tab sis tom qab ntawd tuaj yeem ua haujlwm yam tsis muaj.

Nrog kev hloov kho me me rau txoj cai koj tuaj yeem siv crontab los ntsuas ntsuas ntawm cov ntsiab lus teev sijhawm. Qhov no yuav tso cai txo qis kev siv hluav taws xob ntxiv. Cov lus piav qhia zoo heev yuav siv crontab tuaj yeem nrhiav tau nyob qhov twg.

Ua ke nrog lub hwj huam pob koj tuaj yeem tsim lub xov tooj ntawm tes thiab siv nws los ntsuas qhov xwm txheej sab hauv lossis sab nraum, hauv lub tub yees, hauv chav sauna, koj lub tshuab ntxhua khaub ncaws, chav dej cawv, hauv dav hlau,….

Siv Zero W koj yuav tsis tsuas yog qhia qhov tseem ceeb ntawm cov zaub, tab sis tseem xa lawv mus rau server lossis koj lub vev xaib ntawm WLAN, raws li tau piav qhia lwm qhov.

Kauj Ruam 4: Tsab Ntawv BME280

BME280 Tsab Ntawv
BME280 Tsab Ntawv

Raws li tau hais ua ntej, koj yuav tsum teeb tsa Adafruit Blinka thiab Circuit Python BME280 cov tsev qiv ntawv ntxiv rau Pimoroni Inky pHAT lub tsev qiv ntawv.

Txoj cai xub pib ua lub ntsuas thiab Inky pHAT, tom qab ntawd nyeem qhov ntsuas kub, siab thiab qhov av noo los ntawm lub ntsuas thiab qhia lawv ntawm qhov screen thiab e-ink zaub. Siv lub sijhawm.sleep () hais kom ua, ntsuas ntsuas txhua feeb. Kho raws li xav tau. Los ntawm kev teeb tsa cov lus ntsuas, koj tuaj yeem hloov cov lus siv los tso saib cov txiaj ntsig.

Siv Inky pHAT e-ink zaub, koj xub tsim cov duab los tso rau hauv lub cim xeeb ua ntej thaum kawg nws tau pauv mus rau lub vijtsam siv inkyphat.show () hais kom ua. Lub tsev qiv ntawv Inky pHAT ua kom yooj yim dua cov txheej txheem, muab cov lus txib kom kos thiab tsim cov ntawv, kab, duab plaub, lub voj voos lossis siv cov duab tom qab.

Ntxiv nrog rau qhov ntsuas qhov ntsuas, lub sijhawm ntsuas tau tshwm sim ib yam.

Thov nco ntsoov tias tsab ntawv nrog rau cov tsev qiv ntawv tau sau hauv Python 3, yog li qhib thiab khiav siv Py3 IDLE lossis sib npaug.

# Ib tsab ntawv rau bme280 qhov kub/siab/ntsuas qhov ntsuas (tsis yog Adafruit version) # thiab cov inky pHAT - dub version # # version Dec 01 2018, Dr H # # Yuav tsum Adafruit Blinka thiab Circuit Python BME280 cov tsev qiv ntawv # thiab Pimoroni Inky pHAT lub tsev qiv ntawv ntshuam lub sijhawm ntshuam cov ntaub ntawv ntshuam ntshuam ntshuam thauj mus los ntawm adafruit_bme280 ntshuam Adafruit_BME280 los ntawm adafruit_bme280 ntshuam Adafruit_BME280_I2C ntshuam inkyphat ntshuam sys los ntawm PIL ntshuam ImageFont inkyphat.set_colour ('dub') # rau b/w inky phat inkyphat (180) 180 ° font1 = ImageFont.truetype (inkyphat.fonts. FredokaOne, 27) # Xaiv tus qauv font font2 = ImageFont.truetype (inkyphat.fonts. FredokaOne, 19) # Xaiv cov qauv ntawv font # lang = "DE" # teeb tsa cov lus ntsuas, default ("") -> lus Askiv lang = "EN" i2c = busio. I2C (board. SCL, board. SDA) bmp = Adafruit_BME280_I2C (i2c, chaw nyob = 0x76) # default i2c address (rau Adafruit BMP280) 0x77 (default), 0x76 rau suav daws tawm) #set siv siab # xav tau rau al titute xam, thov kho. Tus qauv tus nqi 1013.25 hPa # phau ntawv qhia tswv yim: #reference_hPa = cov tswv yim ("Nkag mus siv qhov siab hauv hPa:") # lossis # teeb tsa siab thaum pib lub sijhawm raws li siv, piv txwv li rau kev ntsuas qhov siab txheeb ze lub sijhawm.sleep (1) # tos thib ob ua ntej ntsuas 1 j = 0 pres_norm_sum = 0 thaum j hauv thaj tsam (5): # siv tsib ntsuas los txheeb xyuas tus nqi siv pres_norm_sum = pres_norm_sum + bmp.pressure j = j + 1 zaug.sleep (1) reference_hPa = (pres_norm_sum/j) # teeb tsa qhov ntsuas qhov tseem ceeb los ua tus taw tes los pab ntsuas qhov siab bmp.sea_level_pressure = ntab (reference_hPa) luam tawm () thaum Muaj tseeb: #run ib si, hloov kho rau crontab-version # ntsuas qhov tseem ceeb t = bmp.temperature p = bmp.pressure h = bmp.humidity a = bmp.altitude # xam los ntawm adafruit tsev qiv ntawv los ntawm kev siab #timestamp ts = datetime.datetime.now () # timestamp ts0_EN = '{:%Y-% m-%d} '. format (ts) # timestamp - date, EN format ts0_DE =' {:%d.%m.%Y} '. format (ts) # timestamp - date, German format ts1 =' {: %H:%M:%S} '. Format (ts) # timestamp - time tmp = "{0: 0.1f}". Format (t) pre = "{0: 0.1f}". Format (p) hyg = "{0: 0.1f}". Format (h) alt="{0: 0.1f}". Format (a) tText = "Temp.:" pText_EN = "Pressure:" pText_DE = "Luftdruck:" h Text_EN = "Vaum:" hText_DE = "rel. LF: "aText_EN =" Altitude: "aText_DE =" Höhe üNN: " # exakt: ü. NHN, über Normal Höhen Null yog (lang ==" DE "): ts0 = ts0_DE aText = aText_DE pText = pText_DE hText = hText_DE: # default english ts0 = ts0_EN aText = aText_EN pText = pText_EN hText = hText_EN # print values to display print (ts) print (tText, tmp, "° C") print (pText, pre, "hPa") print (hText, hyg, " %") print (aText, alt, "m") print () # print values to Inky pHAT t1 = 5 # tab 1, frist column, simplifies optimization of layout t2 = 110 # tab 2, kem thib ob inkyphat. clear () inkyphat.text ((t1, 0), ts0, inkyphat. BLACK, font2) # sau sijhawm timestamp inkyphat.text ((t2, 0), ts1, inkyphat. BLACK, font2) # sau sijhawm timestamp inkyphat.line ((t1, 25, 207, 25), 1, 3) # kos kab inkyphat.text ((t1, 30), tText, inkyphat. BLACK, font2) inkyphat.text ((t2, 30), (tmp + "° C"), inkyphat. BLACK, font2) inkyphat.text ((t1, 55), pText, inkyphat. BLACK, font2) inkyphat.text ((t2, 55), (ua ntej + "hPa"), inkyphat. BLACK, font2) inkyphat.text ((t1, 80), hText, inkyphat. BLACK, font2) inkyphat.text ((t2, 80), (hyg + " %"), inkyphat. BLACK, font2) # hloov pauv tso saib qhov siab # inkyphat.text ((t1, 80), aText, inkyphat. BLACK, font2) # inkyphat.text ((t2, 80), (alt + "m"), inkyphat. BLACK, font2) inkyphat.show () time.sleep (51) # tos qee lub sijhawm ua ntej ntsuas tom ntej, +19 vib nas this ib zaug inkyphat.clear () # npliag Inky pHAT cov txheej txheem, inkyphat.show () # ntsiag to rau crontab-version

Kauj Ruam 5: Tsab Ntawv BMP280

BMP280 zoo ib yam li BME280 sensor, tab sis tsuas yog ntsuas kub thiab siab. Cov ntawv sau zoo sib xws, tab sis koj xav tau sib txawv Circuit Python cov tsev qiv ntawv. Ntawm no hloov qhov av noo qhov suav qhov siab, raws li qhov ntsuas siab, yog tso tawm.

Txuas nrog koj pom tsab ntawv.

Pom zoo: