Cov txheej txheem:

IoT RPi LED Message Board: 3 Cov Kauj Ruam (nrog Duab)
IoT RPi LED Message Board: 3 Cov Kauj Ruam (nrog Duab)

Video: IoT RPi LED Message Board: 3 Cov Kauj Ruam (nrog Duab)

Video: IoT RPi LED Message Board: 3 Cov Kauj Ruam (nrog Duab)
Video: Часы G-Shock до 250 долларов-15 лучших часов Casio G до 250 доллар... 2024, Hlis ntuj nqeg
Anonim
Image
Image
Kho vajtse teeb
Kho vajtse teeb

Hauv Cov Lus Qhia no, Kuv tau ua wifi-txuas nrog LED lub rooj tsav xwm siv Raspberry Pi (RPi). Cov neeg siv yuav txuas rau Raspberry Pi lub vev xaib siv lawv cov browser kom xa cov lus luv uas yuav tshwm rau ntawm 8x8 LED zaub. Txij li cuam tshuam 8x8 LED matrix nrog MAX7219 tus tsav tsheb hauv Python tau sau tseg zoo los ntawm lwm tus hauv Is Taws Nem, txoj haujlwm no tsom mus rau kev tsim lub vev xaib sib cuam tshuam thiab siv ZeroMQ Messaging los tswj cov lus xa tuaj.

Hloov tshiab: Ntawm no yog qhov kev taug qab qhov project IoT Decimal/Hexadecimal 8x8 LED Matrix Drawing Board

(Kuv yog tus pab txhawb pab pawg rau Cov Ntxhais Uas Code Club thiab kuv tau los nrog txoj haujlwm yooj yim no los qhia cov tub ntxhais kawm ntawm web interface tsim thiab xa xov.)

Kauj Ruam 1: Teeb Kho Vajtse

Kho vajtse teeb
Kho vajtse teeb
Kho vajtse teeb
Kho vajtse teeb

Txoj haujlwm no xav tau cov cuab yeej hauv qab no:

  • Raspberry Pi
  • USB lub zog siv xws li Anker nrog luv USB rau MicroUSB cable
  • MAX7219 dot matrix module nrog cov hlua kab (Aliexpress rau tsawg dua $ 2)
  • Cov ntaub ntawv kaw (Kuv tau ua ib qho los ntawm lub thawv ntawv thawv thiab tshuaj tsuag xim dub)

Kho vajtse teeb yog qhov yooj yim. Cias txuas ib 5 xaim hlua cable los ntawm LED matrix mus rau RPi ib MAX7219 lub tsev qiv ntawv doc.

LED-> RPi ======== VCC-> GPIO Pin #2 (5v) GND-> GPIO Pin #6 (GND) DIN-> GPIO Pin #19CS-> GPIO Pin #24CLK-> GPIO Pin # 23

Kuv siv daim kab xev ua ob sab ua ke txhawm rau txuas LED chav rau RPi rooj plaub. Tom qab ntawd, Kuv tau ua lub thawv ntawv tawm ntawm lub thawv ntawv rau lub tsev RPi thiab roj teeb.

Kauj ruam 2: Teeb Software

Teeb Software
Teeb Software
Teeb Software
Teeb Software
Teeb Software
Teeb Software
Teeb Software
Teeb Software

RPi yuav tsum muaj cov software hauv qab no:

  • Nab hab sej 3
  • Apache 2 websever
  • Max7219 tus neeg tsav tsheb rau Python
  • ZeroMQ Kev Xa Ntawv

Nab hab sej 3

RPi yuav tsum muaj Python 3 twb tau teeb tsa ua ntej lawm. Thaum kuv tus lej sau rau Python 3, Python 2 yuav tsum ua haujlwm nrog qee qhov kev hloov pauv me me.

Apache 2

Teeb Apache thiab pab kom Python CGI sau ntawv. Hauv qab no yog ob peb cov peev txheej zoo rau teeb tsa Apache ntawm RPi yog li kuv yuav tsis rov hais dua ntawm no. Tsuas yog ua raws cov lus qhia hauv qab no teeb tsa Apache thiab CGI. Nco ntsoov *.py cov ntawv sau ua tiav los ntawm qhov browser.

  • https://raspberrywebserver.com/cgiscripting/
  • https://www.knight-of-pi.org/apache-web-server-with-cgi-for-python/

Max7291 Tsav Tsheb

Txhim kho Max7219 tus tsav tsheb los ntawm kev ua raws cov lus qhia teeb tsa tshiab kawg:

https://max7219.readthedocs.io/en/latest/install.html

Tom qab kev teeb tsa, khiav cov piv txwv tus lej, matrix_test.py, ib daim ntawv qhia teeb tsa los tso saib "Nyob Zoo Ntiaj Teb" ntawm LED Matrix. Qhov no yuav tsum ua haujlwm ua ntej mus rau kauj ruam tom ntej.

ZeroMQ Kev Xa Ntawv

Vim li cas peb thiaj xav tau Kev Xa Xov? Sim khiav cov cai piv txwv saum toj no, matrix_test.py, ntawm ob lub davhlau ya nyob twg cov ntxaij vab tshaus ib txhij. Lub kaw lus yuav tso cai ntau tus lej kom ua haujlwm ib txhij tab sis koj yuav pom cov lus sib tshooj uas tsis xav tau. Hauv ib tus neeg siv ib puag ncig, qhov no yuav tsis yog qhov teeb meem txij li koj tuaj yeem paub tseeb tias tsuas yog ib txoj haujlwm tuaj yeem ua haujlwm ib zaug. Hauv ntau tus neeg siv ib puag ncig xws li lub vev xaib, lub kaw lus yuav tsum tsim FIFO (Thawj-Hauv-Thawj-Tawm) kab kom paub tseeb tias tsuas yog ib tus neeg tuaj yeem ua txoj cai thaum lwm tus tos. Thaum tej zaum yuav muaj lwm cov kev daws teeb meem kom ua tiav qhov no, Kuv txiav txim siab siv ZeroMQ los tswj hwm FIFO kab. ZeroMQ server tus lej muaj qhov ua haujlwm tiag tiag los tso tawm cov lus ntawm LED matrix ib zaug thaum lub vev xaib ua haujlwm ua ZeroMQ tus thov kom nug thiab xa lus mus rau ZeroMQ server. Txoj kev no, thaum ntau tus neeg siv tuaj yeem xa cov lus ntawm lub vev xaib ib txhij, ZeroMQ server yuav tsuas tso tawm ib nqe lus ib zaug.

Txog qhov haujlwm no, peb yuav tsuas yog nruab Python pob pyzmq thiab tsis yog tag nrho ZeroMQ pob.

khiav:

sudo pip3 nruab pyzmq

Nyeem ZeroMQ phau ntawv qhia ntawm https://zguide.zeromq.org thiab sim ua lub ntiaj teb nyob zoo tus neeg rau zaub mov thiab piv txwv cov neeg siv khoom hauv Python. Luam tus nab npawb piv txwv tus lej rau ob tus neeg rau zaub mov thiab tus neeg siv khoom rau RPi thiab xyuas kom lawv ua haujlwm ua ntej mus rau kauj ruam tom ntej.

Kauj Ruam 3: Teeb Web Page

Hauv nplooj ntawv web, Kuv siv lub bootstrap css/js moj khaum los ua nplooj ntawv zoo nkauj. Qhov no yog qhov kev xaiv tag nrho.

Rub cov ntawv txuas led_msg.tar.gz txuas rau Apache hauv paus lossis cov npe hauv qab. Txhawm rau tshem tawm cov ntaub ntawv gzip'd tar, khiav:

tar -xzvf led_msg.tar.gz

Qhov no tsim cov ntaub ntawv hauv qab no:

msg.py (txoj haujlwm tseem ceeb)

templates/interstitial.html (html template) templates/send_msg.html (html template) zoo li qub/img/led_150x150-j.webp

Optionally, nruab bootstrap css/js moj khaum nyob rau hauv cov npe zoo li qub.

Nkag mus rau qhov URL rau msg.py koj lub browser thiab xyuas kom lub vev xaib tuaj. Tsis txhob xa lus tsis tau !!!

Ua ntej cov lus tuaj yeem xa mus, ZeroMQ server yuav tsum tau pib lees txais cov lus los ntawm cov vev xaib cov vev xaib thiab tso saib lawv ntawm LED matrix. Tsis muaj dab tsi yuav tshwm ntawm qhov screen yog tias ZeroMQ server tsis ua haujlwm.

Rub tawm qhov txuas max7219_server.py code rau koj phau ntawv qhia tsev, tsis nyob hauv Apache hauv paus dir qhov twg nws tuaj yeem ua tiav los ntawm cov neeg siv web. Khiav nws li hauv paus:

sudo python max7219_server.py

Tam sim no ZeroMQ server tau npaj kom tau txais cov lus los ntawm nplooj ntawv web. Nkag mus thiab xa cov lus yooj yim los ntawm nplooj ntawv web. Yog tias txhua yam tau teeb tsa kom raug, koj yuav pom cov lus ntawd ntawm ZeroMQ server screen ntxiv rau ntawm LED Matrix.

Yog tias koj xav kaw lub server, tsuas yog Tswj-C kom tawm ntawm lub server server.

Qhov ntawd yog nws. Vam tias koj yuav txaus siab rau txoj haujlwm no ntau npaum li kuv tau ua.

Ib qho kev txhim kho uas koj tuaj yeem ua tau yog ua ZeroMQ kev sib txuas lus ntawm cov neeg rau zaub mov thiab cov neeg siv khoom asynchronous kom lub vev xaib tsis tos thaum lwm cov lus tau tshwm sim. Tsis tas li, koj tuaj yeem txuas ntxiv LED matrix hauv hom cascade. Kuv yuav tso qhov ntawd tseg rau koj.

Pom zoo: