Cov txheej txheem:

Raspberry Pi Tswj Kev Ntsuas Kub Hauv Chav Nrog Gnuplot Cov Duab Tso Tawm thiab Email Muaj Peev Xwm Muaj Peev Xwm: 7 Kauj Ruam
Raspberry Pi Tswj Kev Ntsuas Kub Hauv Chav Nrog Gnuplot Cov Duab Tso Tawm thiab Email Muaj Peev Xwm Muaj Peev Xwm: 7 Kauj Ruam

Video: Raspberry Pi Tswj Kev Ntsuas Kub Hauv Chav Nrog Gnuplot Cov Duab Tso Tawm thiab Email Muaj Peev Xwm Muaj Peev Xwm: 7 Kauj Ruam

Video: Raspberry Pi Tswj Kev Ntsuas Kub Hauv Chav Nrog Gnuplot Cov Duab Tso Tawm thiab Email Muaj Peev Xwm Muaj Peev Xwm: 7 Kauj Ruam
Video: leej twg tej ntxhai - Mang Vang [ Official MV ] 2024, Kaum ib hlis
Anonim
Raspberry Pi Tswj Kev Ntsuas Kub Hauv Chav Nrog Gnuplot Cov Duab Tso Tawm thiab Email Muaj Peev Xwm Muaj Peev Xwm
Raspberry Pi Tswj Kev Ntsuas Kub Hauv Chav Nrog Gnuplot Cov Duab Tso Tawm thiab Email Muaj Peev Xwm Muaj Peev Xwm

Qhov twg kuv ua haujlwm, muaj chav tseem ceeb heev uas muaj ntau lub khoos phis tawj. Qhov kub ib puag ncig ntawm chav no yuav tsum txias heev txhawm rau ua kom tau zoo ntawm cov kab ke no. Kuv tau thov kom los nrog kev tshuaj xyuas uas muaj peev xwm xa qee daim ntawv ceeb toom rau ob peb tus neeg uas yuav ceeb toom rau lawv tias qee yam tsis raug ntawm lub tshuab cua txias hauv chav ntawd. thiab USB ntsuas kub thiab av noo. Txog kev saib xyuas, Kuv siv Gnuplot los npaj peb daim duab ntsuas kub thiab tsim cov duab ntawm cov duab ntawd. Tom qab ntawd kuv tau tsim nplooj ntawv tshwj xeeb HTML uas yuav ua tus tuav ntawm Raspberry pi yog li cov xwm txheej tam sim no, cov gnuplot tso tawm cov duab, tuaj yeem saib xyuas los ntawm nplooj ntawv web hauv peb lub network. Kev ceeb toom kuv xaiv mus nrog Gmail. Kuv tau pom qee qhov piv txwv piv txwv hauv Linux Cov neeg siv phau ntawv xov xwm. (Tau kawg koj tuaj yeem siv txhua tus xa ntawv xa ntawv thaum koj paub qhov chaw ua haujlwm tseem ceeb.) Kuj tseem yog qhov tshwj xeeb ntxiv, thaum muaj kev ceeb toom tau tshwm sim, Kuv txuas ib daim duab rau hauv email yog li tus neeg tau txais email tuaj yeem tau txais lub tswv yim ntawm kev nce qib ntau npaum li cas nws tau ua rau ceeb toom.

Kauj ruam 1: Teeb Kho Vajtse

Kho vajtse teeb
Kho vajtse teeb

Tsis muaj ntau los teeb tsa kho vajtse. Raspberry pi tab tom khiav Raspian thiab lub ntsuas kub USB yooj yim ntsaws ncaj qha rau hauv ib qho ntawm USB chaw nres nkoj. Lub zog siv hluav taws xob ntawm qhov ntsuas no tsawg heev thiab vim li ntawd kuv tau siv nws ncaj qha los ntawm Raspberry pi. Txawm li cas los xij, rau USB siv cov cuab yeej siv lub zog siv me ntsis ntxiv, Kuv xav kom txhawb lawv los ntawm lub zog USB txuas thiab tsis ncaj qha los ntawm Raspberry pi's USB chaw nres nkoj. nyeem cov av noo ntawm cov xwm txheej tam sim no. kub = 20.9 ° C av noo = 62.7% dewpoint = 13.0 ° CA cov nab nab sau tsab ntawv cais cov hlua no thiab khaws cov ntsuas kub thiab av noo rau hauv peb kab ntawv txhua tsib feeb; ib hnub, 24 teev thiab 48 teev cov ntawv ntawv (Qhov sib txawv yuav tham tom qab hauv ntu HTML). Los ntawm cov ntaub ntawv no, Gnuplot yuav tsim cov duab thiab tom qab ntawd cov duab ntawm cov ntaub ntawv teeb tsa hauv txhua daim ntawv. Ua ntej kuv tham txog tsab ntawv nab nab Kuv yuav tham txog kev npaj Raspberry pi. Txij li kev saib xyuas yuav tsum ua tiav online, lub web server xav tau kev teeb tsa. Kuv tau sim ob peb ntawm lawv hauv kuv lub sijhawm ntawm Raspberry pi tab sis txawm hais tias nws loj me ntsis kuv nyiam Apache. Txhawm rau nruab Apache ntawm koj li Raspberry pi koj yooj yim ntaus: sudo apt-tau nruab apache2 Nws yuav muab rau koj sai ua ntej nws teeb tsa, nias "y" rau yog thiab Apache yuav teeb tsa ob peb feeb nyob ntawm koj li Raspberry pi. ua tiav, koj yuav tsum teeb tsa ob lub nab nab plug-ins: nab nab-serial thiab nab nab-ntsaws ntsaws ntsaws. (Txawm hais tias kuv tau pom tias tsis ntev los no Raspian tsim muaj tus nab npawb-serial plug-in tus qauv tab sis tsuas yog kom muaj kev nyab xeeb.) Txhawm rau nruab cov uas koj ntaus: sudo apt-get install python-serial python-gnuplotOnce dua tom qab lees paub cov lus qhia, cov plug no -in yuav raug teeb tsa. Thiab nrog qhov teeb tsa kho vajtse tiav.

Kauj Ruam 2: Teeb Software - Teeb Email thiab Cov Tau Txais

Ua ntej peb mus deb dhau rau hauv software tam sim no yuav yog lub sijhawm zoo los tsim Gmail account kom xa koj li email ceeb toom los ntawm. (Qhov piv txwv no siv GMail tab sis txhua tus xa ntawv tuaj yeem siv tau thaum peb paub qhov chaw nres nkoj smtp) Tus nab npawb nab npawb yog ncaj ncaj rau pem hauv ntej tab sis kev xa khoom xav tau yog qhov tseem ceeb. Tsis muaj lawv tsis muaj dab tsi yuav ua haujlwm.ntawm lub sijhawm ntshuam *ntshuam sijhawm ntshuam ntshuam ntshuam ntshuam smtplib ntshuam Gnuplot ntshuam os ntshuam sys Tau kawg peb yuav tsum ntxiv cov neeg tau txais email. Txhua qhov chaw nyob email tau khaws tseg hauv qhov sib txawv.from_address ='[email protected]'to_address1 = 'recipient1.mail.com' to_address2 = 'recipient2.mail.com'username =' [email protected] 'password =' custom_email_password '

Kauj Ruam 3: Kev teeb tsa Software - teeb tsa thiab cais

Tom ntej no peb saib cov teeb tsa nws yog qhov teeb meem ntawm kev teeb tsa qhov tsis sib xws nrog cov lej tso tawm los ntawm lub sensor. Lub sensor tso tawm ib txoj hlua ntawm 9600 8 N 1 uas yog tus qauv txheem. Tom qab txoj hlua tau txais muaj ntau txoj hauv kev los txheeb xyuas cov hlua no hauv nab hab sej thiab muaj peev xwm ua tau zoo dua. Txoj kev kuv ua nws yog txhawm rau nrhiav cov cim "temp" hauv kab ntawv txuas. Thaum nyob nws tsuas yog teeb meem ntawm kev nyeem 46 cov cim txuas ntxiv mus rau hauv txoj hlua. Cov hlua sau tam sim no tuaj yeem hais tau zoo li cov ntsiab lus hauv ib qho array. Cov ntaub ntawv xav tau cais tawm los ntawm txoj hlua thiab khaws cia rau peb cov ntaub ntawv nrog rau nws lub sijhawm sib thooj stamp.timestamp = strftime ("%d%b%Y%H:%M:%S", localtime ())

Kauj Ruam 4: Teeb Software - Gnuplot

Teeb tsa Software - Gnuplot
Teeb tsa Software - Gnuplot
Teeb tsa Software - Gnuplot
Teeb tsa Software - Gnuplot
Teeb Software - Gnuplot
Teeb Software - Gnuplot

Gnuplot yog kab hais kom ua kab ke cuab yeej. Thaum koj tau xam tawm cov hauv paus nws tuaj yeem yog cov cuab yeej muaj zog zoo nkauj rau cov duab teeb tsa ntawm cov ntaub ntawv teeb tsa. Thaum peb qhia rau gnuplot qhov twg hauv cov ntaub ntawv cov ntaub ntawv nyob peb tuaj yeem npaj cov txiaj ntsig xav tau. Kuv yuav siv sijhawm nyob ntawm X axis thiab peb qhov kub ntawm Y axis. Kev npaj sijhawm los ntawm kuv qhov kev paub yog qhov nyuaj tshaj plaws uas koj yuav tsum tau txais lub sijhawm ua hom ntawv hauv gnuplot kom phim cov hom ntawv ntawm cov ntawv. Tom qab txhua qhov kev xaiv teeb tsa ua tiav thiab rau koj nyiam, Gnuplot tuaj yeem tsim cov duab ntawm daim duab no. Qhov no yuav yog daim duab uas peb yuav siv ntawm peb lub Vev Xaib tom qab. Kuv xaiv mus nrog daim duab-p.webp

Kauj Ruam 5: Teeb Software - Teeb Chaw thiab Emailing

Qhov pib rau kev ceeb toom yuav tsum ua tiav los ntawm kev sim thiab yuam kev rau koj teeb tsa. chav uas nyob hauv tsev tsis muaj lub qhov rais yog li thaum lub tshuab cua txias nres nws tuaj yeem kub tau sai heev. Thaum xub thawj kuv tau saib cov ntaub ntawv teev tseg ob peb hnub thiab saib qhov kev hloov pauv ntawm qhov kub thiab txias ua ntej kuv txiav txim siab raws li tus nqi ceeb toom ntawm 30 degrees C. Qhov no yuav tsis zoo li siab heev tab sis thaum ceeb toom tau tshwm sim koj tseem xav muab sijhawm rau koj tus kheej los kho qhov teeb meem ua ntej nws dhau los ua qhov tseem ceeb.

Txhawm rau kom yooj yim, Kuv tab tom xa ib tus email mus rau daim ntawv teev npe. Txij li thaum daim ntawv teev npe luv luv Kuv tsis tau txhawj xeeb nrog xa email rau ntau tus neeg tau txais. Ib yam uas yuav tsum nco ntsoov ntawm no, Txij li thaum kuv tab tom sau tsab ntawv no ua haujlwm cron txhua 5 feeb, koj tsis xav xa email txhua 5 feeb thaum lub sijhawm pib tau tshwm sim. Kom tau txais qhov no, Kuv sau hnub thiab sijhawm ntawm kev ceeb toom rau ib daim ntawv thiab tshawb xyuas cov ntawv no ua ntej xa ib qho email los saib yog tias lub kaw lus twb tau nyob hauv lub xeev ceeb toom lawm. Ib zaug hauv lub xeev ceeb toom, nws tsuas yog xa email txhua txhua teev tom qab thawj qhov ua rau tsuav lub kaw lus nyob hauv thiab ceeb toom lub xeev. Txoj kev ntawd Gmail tsis thaiv koj tus email los ntawm kev xa email ntau dhau nyob rau lub sijhawm luv.

Kauj Ruam 6: Teeb Software - HTML

Kev saib xyuas tag nrho cov kab ke tau ua tiav ntawm lub vev xaib thiab cov ntawv html yooj yim heev xav tau rau qhov no. Cov duab uas Gnuplot tsim kuv tsuas yog siv rov qab tib qhov ntev ntawm daim duab. Kuv ntseeg tias kuv tau hla txog 3 qhov loj me rau cov duab no uas muab qhov haum zoo tshaj plaws ntawm kuv lub vijtsam. Ua ntej peb tsim cov ntawv html cia peb tsim daim nplaub tshev rau nws. Los ntawm lub neej ntawd lub web hosting folder nyob ntawm/var/www/. Txawm hais tias Raspberry pi 'lub hom phiaj no tsuas yog saib xyuas chav no thiab teeb tsa email ceeb toom, rau kev khaws tsev zoo Kuv tau tsim cov ntawv cais hauv/var/www/folder. Txij li daim nplaub tshev no yog ntawm tus neeg siv hauv paus koj yuav tsum siv sudo los tsim cov ntawv tais ceev tseg yog qhov chaw no. sudo mkdir/var/www/temperature Hauv qhov piv txwv no kuv siv qhov kub thiab txias raws li lub npe ntawm daim nplaub tshev tab sis koj tuaj yeem siv lub npe ntawm no tab sis nco ntsoov qhov no yuav tsum tau nkag mus rau hauv qhov chaw nyob bar los saib nplooj ntawv no. Txoj hauv kev no tau khaws cia hauv qhov sib txawv hauv tsab ntawv nab nab. Txawm hais tias qhov chaw nyob yuav tsum tau hloov lossis tsab ntawv yuav tsum tau hloov pauv rau lwm qhov system, nws tuaj yeem hloov pauv los ntawm ib qho chaw no. xav ua nyob rau hauv no. Kuv xav qhia koj lub npe html tsab ntawv "index.html" raws li qhov no yuav yooj yim qhov no thaum sim nrhiav nplooj ntawv no. Qhov tseem ceeb yog kom paub tseeb tias cov duab sizing yog tib yam li cov duab loj los ntawm Gnuplot. To saib nplooj ntawv no, koj tsuas yog yuav tsum nkag mus rau tus IP chaw nyob ntawm Raspberry Pi ua raws los ntawm /qhov kub (lossis yam koj puas tau sau koj lub npe) Kuv muaj ntau lub tshuab ntawm kev ua haujlwm tshuaj xyuas ntau yam sib txawv thiab lawv txhua tus tsim tawm cov duab ntawm lawv cov txiaj ntsig. Yog li kuv tsim ib nplooj ntawv uas muaj txuas rau txhua nplooj ntawv no yog li kuv tsis tas yuav txhawj xeeb txog kev nkag mus rau qhov chaw nyob txhua lub sijhawm kuv xav nkag mus rau cov nplooj ntawv no.

Kauj Ruam 7: Kuv Ciaj sia…

Kuv tau siv qhov no los ntsuas qhov ntsuas kub hauv chav khoos phis tawj tab sis qhov no tuaj yeem yog cov ntaub ntawv zoo nkauj los ntawm txhua qhov chaw. Thaum nws tuaj yeem khaws cia hauv cov ntawv sau thiab koj paub nws yog hom ntawv Gnuplot tuaj yeem ua tus so. One yam kuv ntxiv tsis ntev los no rau txoj haujlwm no yog xa "lub plawv dhia" email ntawm yam. Qhov ntawd yog thawj lub hlis thaum 9 teev sawv ntxov Kuv muaj tsab ntawv sau uas email cov npe xa tuaj qhia rau lawv paub tias lawv lub kaw lus ua haujlwm zoo li nws yuav tsum tau thiab txhua yam zoo nyob hauv chav.

Siv cov npe cronjob ua:

Pom zoo: