Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Raspberry pie 4B plus light snow 2.13 inch ink screen how to monitor pm2.5 messages

Shulou Source: shulou.com Published: 2022-06-01 23:02:25 09月16日 Update

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.

Tags: Raspberries information ink monitoring code content articles more knowledge articles quality good address effects files formats temperature humidity air air quality Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Technology macOS Redmi Huawei