Cov txheej txheem:

Cov Ntawv Ceeb Toom Digital Siv Raspberry Pi thiab MQTT raws tu qauv: 8 Kauj Ruam
Cov Ntawv Ceeb Toom Digital Siv Raspberry Pi thiab MQTT raws tu qauv: 8 Kauj Ruam

Video: Cov Ntawv Ceeb Toom Digital Siv Raspberry Pi thiab MQTT raws tu qauv: 8 Kauj Ruam

Video: Cov Ntawv Ceeb Toom Digital Siv Raspberry Pi thiab MQTT raws tu qauv: 8 Kauj Ruam
Video: Casio G-Shock Mudmaster против Gulfmaster | G Shock GWG-1000 Mudmaster против G Shock GW... 2024, Kaum ib hlis
Anonim
Image
Image
Cov Ntawv Ceeb Toom Digital Siv Raspberry Pi thiab MQTT raws tu qauv
Cov Ntawv Ceeb Toom Digital Siv Raspberry Pi thiab MQTT raws tu qauv

Cov ntawv ceeb toom yuav luag siv rau txhua qhov chaw, xws li chaw ua haujlwm, tsev kawm ntawv, tsev kho mob, thiab tsev so. Lawv tuaj yeem siv rov ua dua los tso tawm cov ntawv ceeb toom tseem ceeb lossis tshaj tawm cov xwm txheej yav tom ntej lossis cov rooj sib tham. Tab sis daim ntawv ceeb toom lossis tshaj tawm yuav tsum tau luam tawm ntawm daim ntawv thiab khawm rau ntawm daim ntawv ceeb toom.

Hauv Cov Lus Qhia no cia peb kawm tsim peb Cov Ntawv Ceeb Toom Digital nrog Raspberry Pi kom txuag tau ntau cov ntawv thiab cov toner!

Kauj Ruam 1: Lub Rooj Saib Xyuas Kev Pom Zoo Digital Ua Haujlwm Li Cas?

Cov Ntawv Ceeb Toom Digital Ua Haujlwm Li Cas?
Cov Ntawv Ceeb Toom Digital Ua Haujlwm Li Cas?
  • Raspberry Pi txuas nrog lub HDMI Display uas yog peb Cov Ntawv Ceeb Toom Digital.
  • Lub Windows PC tau siv los tshaj tawm tsab ntawv ceeb toom ntawm Digital Board Board hauv internet.
  • Daim ntawv ceeb toom luam tawm los ntawm Windows PC tau txais los ntawm Digital Notice Board los ntawm CloudMQTT broker.
  • Kev sib txuas lus ntawm Windows PC thiab Digital Notice Board tau ua tiav los ntawm MQTT raws tu qauv.

Kauj Ruam 2: Yam Yuav Tsum Tau:

  1. Raspberry Pi nrog Rasbian OS
  2. Zaub nrog HDMI chaw nres nkoj
  3. Windows PC
  4. Kev Sib Txuas Internet
  5. CloudMQTT tus account

Kauj Ruam 3: GUI Tsim rau Cov Lus Ceeb Toom:

Image
Image
GUI Tsim rau Cov Lus Ceeb Toom
GUI Tsim rau Cov Lus Ceeb Toom

Peb yuav tsum tsim 2 GUIs, ib qho rau Raspberry Pi los tso tawm daim ntawv ceeb toom ntawm HDMI Zaub thiab lwm qhov rau Windows PC kom tshaj tawm tsab ntawv ceeb toom rau Raspberry Pi ntawm CloudMQTT broker.

Kev tsim GUI nyob ntawm qhov chaw uas koj yuav tso rau Digital Board Board. Piv txwv li, cia kuv tsim GUI rau Chaw Ua Haujlwm Qhia Ntawv kom nthuav tawm cov xwm txheej yav tom ntej thiab cov rooj sib tham kom cov neeg ua haujlwm tuaj yeem hloov kho nrog cov ntaub ntawv tshiab kawg.

Nws yog qhov yooj yim los tsim GUI hauv Windows PC, yog li cia peb tsim Cov Ntawv Ceeb Toom Digital GUI hauv Windows PC thiab luam cov cai rau Raspberry Pi.

Software yuav tsum tau:

Anaconda (uas suav nrog nab nab 2.7, Qt Designer pob thiab Spyder IDE).

Qt Tus Tsim Qauv yog lub cuab yeej siv los tsim GUIs. Qhov tsim tawm ntawm Qt Tus Tsim Qauv yuav yog.ui cov ntaub ntawv, tom qab ntawd nws tuaj yeem hloov pauv mus rau.py rau txheej txheem ntxiv.

Dab tsi tshwm sim hauv video?:

  • Rub tawm Anaconda Windows Installer rau nab hab sej 2.7 thiab nruab nws hauv Windows PC (txheej txheem teeb tsa ib txwm muaj).
  • Tom qab teeb tsa, koj tuaj yeem pom Qt Tus Tsim Qauv cuab yeej hauv "installation_directory / Library / bin / designer.exe" (rau kuv nws yog "C: / Anaconda2 / Library / bin / designer.exe")
  • Tsim qhov luv rau "designer.exe" thiab muab tso rau ntawm lub desktop.
  • qhib "designer.exe".
  • Tsim lub qhov rai tshiab.
  • Xaiv thiab tso cov txheej txheem thiab cov kev xav tau (saib cov ntawv, saib daim ntawv lo, thiab lwm yam).
  • Txuag ua ntaub ntawv Rpi_UI.ui.
  • Txhawm rau hloov nws mus rau hauv.py cov ntaub ntawv qhib cmd tam sim hauv daim nplaub tshev tam sim no qhov twg Rpi_UI.ui cov ntaub ntawv muaj thiab ntaus cov lus txib hauv qab no

installation_directory / Library / bin / pyuic5.bat -x RPi_UI.ui -o RPi_UI.py

rau kuv nws yog, C: / Anaconda2 / Library / bin / pyuic5.bat -x RPi_UI.ui -o RPi_UI.py

cov lus txib no yuav hloov Rpi_UI.ui cov ntaub ntawv rau Rpi_UI.py cov ntaub ntawv thiab muab tso rau hauv tib cov npe.

  • Qhib Rpi_UI.py cov ntaub ntawv nrog Spyder IDE uas suav nrog hauv Anaconda.
  • Khiav cov ntawv yuav tso saib GUI peb tau tsim ua ntej.

Tom ntej no, cia peb teeb tsa CloudMQTT tus account.

Kauj Ruam 4: Teeb Tus CloudMQTT Account:

Image
Image
  • Mus ntsib qhov txuas no.
  • Tsim ib tus as khauj nrog E-mail thiab nkag rau hauv koj tus as khauj.
  • Tsim qhov piv txwv tshiab (Kuv npe nws li TEST_1).
  • Qhib cov ntaub ntawv Instance.
  • Nco tseg ntawm Server, Tus Neeg Siv, Tus Kheej, thiab Chaw Nres Nkoj.
  • Xa mus rau CloudMQTT Python Cov Ntaub Ntawv thiab khaws cov ntawv ua CloudMQTT.py.
  • Cov piv txwv tus lej hauv cov ntaub ntawv xav tau tsev qiv ntawv paho, Nruab Paho Python Client siv cov cuab yeej pip, qhib cmd sai li tus thawj coj thiab sau cov lus txib hauv qab no.

pip nruab paho-mqtt

Kauj Ruam 5: Raspberry Pi Txoj Cai Kawg piav qhia:

Ntawm no, cia kuv piav qhia txoj kev kuv ua ke RPi_UI.py cov ntaub ntawv nrog CloudMQTT.py thiab khaws nws li RPi_UI.py.

Ntshuam tsev qiv ntawv, yog tias nws tsis tau teeb tsa tsuas yog nruab nws

ntshuam paho.mqtt.client li mqtt

ntshuam urlparse los ntawm PyQt5 ntshuam QtGui, QtWidgets, QtCore los ntawm PyQt5. QtCore ntshuam QTimer, QTime los ntawm threading ntshuam ntshuam sys ntshuam rov los ntawm google_drive_downloader ntshuam GoogleDriveDownloader li gdd ntshuam os

Txhawm rau nruab googledrivedownloader, siv qhov hais kom ua

pip nruab googledrivedownloader

Initializing zog,

icon = "qhia tau- [email protected]"

contestImg = "black" meeting1 = "Meeting1:" venue1 = "Time and venue1." meeting2 = "Meeting2:" venue2 = "Sijhawm thiab chaw 2." meeting3 = "Meeting3:" venue3 = "Sijhawm thiab chaw 3."

Ua raws los ntawm chav kawm Ui_MainWindow

chav kawm Ui_MainWindow (kwv):

def setupUi (tus kheej, MainWindow):… def retranslateUi (tus kheej, MainWindow):… def _update (tus kheej):…

Cov kab hauv qab no hauv kev teeb tsa kev ua haujlwmUi hloov kho GUI txhua 3 vib nas this los ntawm kev hu rau _update muaj nuj nqi

tus kheej.retranslateUi (MainWindow)

QtCore. QMetaObject.connectSlotsByName (MainWindow) self.timer = QTimer () self.timer.timeout.connect (self._update) self.timer.start (3000)

Lub luag haujlwm on_message tos rau cov lus los ntawm tus tswv lag luam, thaum cov lus tau txais nws rub tawm cov duab los ntawm google tsav siv lub google drive sharable txuas ID thiab tseem hloov qhov txiaj ntsig ntawm kev hloov pauv thoob ntiaj teb

def on_message (tus thov kev pab, ob, msg):

print (str (msg.payload)) yog (str (msg.payload)): noticeReceived = str (msg.payload) tshwm sim = re.search ('%1 (.*)%2 (.*)%3 (. *)%4 (.*)%5 (.*)%6 (.*)%7 (.*)%8 ', ceeb toom tau txais) kev sib tw thoob ntiaj tebImg thoob ntiaj teb kev sib tham 1 thoob ntiaj teb chaw 1 ntiaj teb kev sib tham 2 thoob ntiaj teb kev sib tham 2 thoob ntiaj teb qhov chaw 3 fileId = "" +result.group (1)+"" path = "/home/pi/Desktop/Instructables/RPi UI/ContestImages/"+result.group (1)+". jpg" gdd.download_file_from_google_drive (file_id = fileId, dest_path = path) contestImg = result.group (1) meeting1 = result.group (2) venue1 = result.group (3) meeting2 = result.group (4) venue2 = result.group (5) meeting3 = result.group (6) qhov chaw 3 = result.group (7)

Txoj cai muaj 2 lub voj voog tsis muaj qhov kawg,

rc = mqttc.loop ()

thiab

sys.exit (app.exec_ ())

Txhawm rau khiav cov loops ib txhij, Kuv tau siv Threading lub tswvyim

def sqImport (tId): yog tId == 0: thaum 1: rc = 0 thaum rc == 0: rc = mqttc.loop () print ("rc:" + str (rc)) yog tId == 1: thaum 1: app = QtWidgets. QApplication (sys.argv) MainWindow = QtWidgets. QMainWindow () ui = Ui_MainWindow () ui.setupUi (MainWindow) MainWindow.show () sys.exit (app.exec_ ()) threadA = Xov (phiaj) = sqImport, args = [0]) threadB = Xov (phiaj = sqImport, args = [1]) threadA.start () threadB.start () threadA.join () threadB.join ()

Txias, peb tau ua tiav Raspberry Pi teeb tsa, tom ntej no cia peb tsim GUI rau Windows PC los tshaj tawm cov lus rau Raspberry Pi.

Kauj Ruam 6: Windows PC GUI:

Windows PC GUI
Windows PC GUI
  • Tsim GUI rau windows thiab txuag nws li Windows_UI.ui.
  • Hloov nws mus rau hauv cov ntaub ntawv sej.
  • Muab nws nrog CloudMQTT.py cov ntaub ntawv thiab khaws nws li Windows_UI.py.
  • Kev ua haujlwm ntawm Windows_UI.py cov ntaub ntawv zoo ib yam li RPi_UI.py cov ntaub ntawv, qhov sib txawv tsuas yog Windows_UI.py cov ntawv tshaj tawm cov lus thaum RPi_UI.py tau txais cov lus.

Kauj Ruam 7: Windows PC Txoj Cai Kawg piav qhia:

  • Windows_UI.py cov ntaub ntawv muaj txhua chav kawm thiab ua haujlwm ntawm RPi_UI.ui tshwj tsis yog ob peb.
  • Hloov chaw ntawm on_message muaj nuj nqi, nws muaj on_publish muaj nuj nqi los tshaj tawm cov lus.
  • Cov cai hauv qab no tsis pub dhau retranslateUi muaj nuj nqi hu rau kev tshaj tawm ib zaug thaum PUBLISH khawm tau nyem.

self.pushButton.clicked.connect (self.publish)

  • Cov ntawv tshaj tawm ua haujlwm sib koom ua ke google drive sib koom sib txuas ID thiab cov ntaub ntawv sib tham thiab tshaj tawm nws nyob hauv qab lub ntsiab lus "ceeb toom".
  • Cov lus no yuav tau txais los ntawm Raspberry Pi.

Kauj Ruam 8: Teeb tsa Cov Ntawv Ceeb Toom Digital:

  • Txuas Raspberry Pi mus rau HDMI zaub, Kuv tau siv kuv lub Sony TV ua Digital Digital Board Board Display.
  • Khiav RPi_UI.py cov ntaub ntawv hauv Raspberry Pi.
  • Khiav Windows_UI.py cov ntaub ntawv hauv Windows PC.
  • Nkag mus rau Google tsav txuas ID ntawm daim duab sib tw thiab tshaj tawm lub rooj sib tham.
  • Nyem rau PUBLISH khawm.
  • Tam sim no koj tuaj yeem pom daim ntawv ceeb toom Digital hloov tshiab tsis pub dhau ob peb feeb.

Cov lus qhia:

  • Koj tuaj yeem tsim tus naj npawb xav tau ntawm Cov Ntawv Ceeb Toom Digital thiab Cov laug cam tuaj yeem tso npe rau Cov ncauj lus sib txawv.
  • Txhawm rau ua Windows_UI.py cov ntawv nqa tau, koj tuaj yeem hloov cov ntaub ntawv mus rau hauv cov ntaub ntawv ua tiav siv pyinstaller, yog li koj tuaj yeem ua tiav cov ntaub ntawv ua tiav hauv txhua lub Windows PC yam tsis tau txhim kho cov tsev qiv ntawv xav tau hauv PC.

Ua tsaug

SABARI KANNAN M.

Pom zoo: