In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to monitor pm2.5 information on raspberry pie 4B plus light snow 2.13-inch ink screen. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Title: raspberry pie 4B plus light snow 2.13 inch ink screen to monitor pm2.5 messages
Open spi
Vim / boot/config.txt
Add
Dtparam=spi=on
Pip mirror source
Pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
Pacman-S gcc python-numpy make wiringpi freetype2
Pip install spidev RPi.GPIO requests
Pip install wiringpi
Pip install-no-cache-dir pillow
Pip install-upgrade pip
Load sample package https://github.com/waveshare/e-Paper
The following python file is to be placed in e-paper/RaspberryPi&JetsonNano/python/examples/
The url in Daizhong refers to the getData.php of the first web site in the format {"pm": "(23 pm:" (23 pyrrine 32, 35 pyrrine, 23 pyrrine 35) 3669, 1042, 1313), "date": "2020-02-24 13:40:01", the address of another raspberry pie in my code, you can also use it in the same raspberry pie.
The python code is as follows:
#! / usr/bin/python
#-*-coding:utf-8-*-
Import sys
Import os
Import datetime
Import requests
Picdir = os.path.join (os.path.dirname (os.path.dirname (os.path.realpath (_ _ file__), 'pic')
Libdir = os.path.join (os.path.dirname (os.path.dirname (os.path.realpath (_ _ file__), 'lib')
If os.path.exists (libdir):
Sys.path.append (libdir)
Import logging
From waveshare_epd import epd2in13_V2
Import time
From PIL import Image,ImageDraw,ImageFont
Import traceback
Logging.basicConfig (level=logging.DEBUG)
Try:
Logging.info ("epd2in13_V2 Demo")
Epd = epd2in13_V2.EPD ()
Logging.info ("init and Clear")
Epd.init (epd.FULL_UPDATE)
# epd.Clear (0xFF)
# Drawing on the image
Font15 = ImageFont.truetype (os.path.join (picdir, 'Font.ttc'), 15)
Font24 = ImageFont.truetype (os.path.join (picdir, 'Font.ttc'), 24)
Logging.info ("1.Drawing on the image...")
Image = Image.new ('1customers, (epd.height, epd.width), 255) # 255: clear the frame
Draw = ImageDraw.Draw (image)
# GetTime
# time = (datetime.datetime.now () + datetime.timedelta (hours=8)). Strftime ('% Y.%m.%d% HRV% MRV% S')
# PrintWord
# draw.text ((20,40), 'hehe', font = font15, fill = 0)
# PrintTime
# draw.text ((20,80), time, font = font15, fill = 0)
# Your PM2.5 data url
# Content for example:
# {"pm": (25 date: "2020-02-24 13:30:03")
Url = "http://192.168.1.196/pm25/getData.php"
# Format pm2.5 data
Alldata = requests.get (url)
Pmdata = alldata.json () ["pm"]
Pmdata = pmdata [1Rau Murray 1]
Pmdata = pmdata.split (",")
# Get time
Time = alldata.json () ["date"]
# Get pm2.5,temperature,humidity
Pm25 = pmdata [4]
Temperature = pmdata [13]
Humidity = pmdata [14]
# Draw all data
Draw.text ((20,10), 'Air quality:' + pm25 +'μ g draw.text ³', font = font15, fill = 0)
Draw.text ((20,30), 'temperature:' + temperature +'°C, font = font15, fill = 0)
Draw.text (20,50), 'humidity:' + humidity +'%', font = font15, fill = 0)
Draw.text ((20,70), time, font = font15, fill = 0)
Draw.text ((20,90),'By Andy', font = font15, fill = 0)
# ScreenRotate180
Image = image.transpose (Image.ROTATE_180)
Epd.display (epd.getbuffer (image))
Logging.info ("Goto Sleep...")
Epd.sleep ()
Except IOError as e:
Logging.info (e)
Except KeyboardInterrupt:
Logging.info ("ctrl + c:")
Epd2in13_V2.epdconfig.module_exit ()
Exit ()
The effect is as follows:
About raspberry pie 4B plus light snow 2.13 inch ink screen how to monitor pm2.5 information is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.