Cov txheej txheem:

Teem Los Ntawm Khaub Ncaws Raspberry Pi rau Log Cov Ntaub Ntawv Los Ntawm Arduino: 5 Kauj Ruam
Teem Los Ntawm Khaub Ncaws Raspberry Pi rau Log Cov Ntaub Ntawv Los Ntawm Arduino: 5 Kauj Ruam

Video: Teem Los Ntawm Khaub Ncaws Raspberry Pi rau Log Cov Ntaub Ntawv Los Ntawm Arduino: 5 Kauj Ruam

Video: Teem Los Ntawm Khaub Ncaws Raspberry Pi rau Log Cov Ntaub Ntawv Los Ntawm Arduino: 5 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Teeb Los Ntawm Khaub Ncaws Raspberry Pi txhawm rau Log Cov Ntaub Ntawv Los Ntawm Arduino
Teeb Los Ntawm Khaub Ncaws Raspberry Pi txhawm rau Log Cov Ntaub Ntawv Los Ntawm Arduino

Cov ntawv qhia no yog rau cov uas tsis muaj kev paub nrog txhim kho kho vajtse tshiab, lossis software, cia nyob ib leeg Python lossis Linux.

Cia hais tias koj tau xaj rau Raspberry Pi (RPi) nrog daim npav SD (tsawg kawg 8GB, Kuv siv 16GB, hom I) thiab lub hwj chim muab (5V, tsawg kawg 2.5A). Hnub no, koj txiav txim siab teeb tsa nws thiab sau cov ntaub ntawv los ntawm Arduinos. Yog li cia pib!

Cov ntawv qhia suav nrog teeb tsa Raspberry Pi txij thaum pib, suav nrog Desktop Remote, npaj Arduino nrog 18B20 qhov ntsuas kub, thiab ua tiav Python tsab ntawv hauv Raspberry Pi txhawm rau khaws thiab khaws cov ntaub ntawv. Kuv hloov kho qhov tshaj tawm nrog ntxiv samba qhia kom hloov cov ntaub ntawv ntawm lub computer host (koj lub PC) thiab Raspberry Pi

Kauj Ruam 1: Npaj Raspberry Pi

Npaj Raspberry Pi
Npaj Raspberry Pi
Npaj Raspberry Pi
Npaj Raspberry Pi
Npaj Raspberry Pi
Npaj Raspberry Pi
Npaj Raspberry Pi
Npaj Raspberry Pi
  1. Rub lub operating system rau RPi. Kuv pom zoo tag nrho version ntawm Raspbian, zoo li no ntawm no.
  2. Xav tias koj muaj lub khoos phis tawj ua haujlwm ntawm Windows, rub tawm Rufus software los sau cov duab rau SD daim npav. Scroll cia thiab tau txais rufus 3.0 (Lub Rau Hli 2018)
  3. Unzip Raspbian cov ntaub ntawv (4.6 GB), thiab ua tib zoo xaiv koj lub hom phiaj SD daim npav. Nws yuav siv sijhawm li 3 feeb los sau daim duab rau daim npav.
  4. Ntxig daim npav SD daim npav, ntsaws rau hauv lub zog txuas mus rau lub micro USB chaw nres nkoj, Zaub nrog HDMI cable, keyboard, nas yog xaiv tau.
  5. Tos kom txog thaum RPi khau raj thiab qhia lub desktop, nias qhov tseem ceeb Qhov rai, mus rau Accessories/Terminal thiab Enter.
  6. Kho RPi los ntawm hom:

sudo raspi-teeb tsa

7. Hloov ob peb yam hauv RPi teeb tsa:

  • Hauv 1. Hloov tus password
  • Hauv 2. Network Xaiv: Hloov lub npe hostname (qee yam tshwj xeeb, kuv li yog rpi1001), thiab wifi SSID thiab tus password.
  • Hauv 4. Qhov Kev Xaiv Chaw Nyob: Hloov Sijhawm Zaum, Keyboard, thaj chaw
  • Hauv 5. Kev cuam tshuam kev sib txuas: Pab kom SSH (nkag mus ntawm kab hais kom ua), Pab kom VNC (rau lub desktop deb)
  • Hauv 7: Kev Xaiv Ua Ntej: Nthuav Tawm Cov Ntaub Ntawv:
  • Rov pib dua
  • Tom qab pib ua haujlwm: nco ntsoov IP chaw nyob los ntawm kev khiav

sudo ifconfig

Yog tias Ethernet tab tom siv, IP yuav tsum yog thawj qhov thaiv, yog siv Wifi, IP nyob ntawm ntu peb, qee yam zoo li 192.168.1.40, khiav cov lus txib no kom hloov kho Linux distro:

sudo apt-tau hloov tshiab && sudo apt-tau hloov tshiab –y && sudo poweroff

Qhov kawg yuav tshem tawm RPi tom qab ua tiav nrog qhov hloov tshiab

8. Yog tias koj tsis nco qab qhov cim IP ntawm RPi, lossis nws tau hloov pauv tsis ntev los no, siv PowerShell (ntaus PowerShell mus rau lub npov tshawb hauv Windows)

Hauv PowerShell txhawm rau ping Rpi: p ing rpi1001.local get4 tau txais qee yam zoo li no 192.168.1.40. rpi1001 yog kuv lub hostname rau kuv Rpi.

9. Nruab VNCViewer, cov software no ua haujlwm zoo li TeamViewer, lossis Desktop Remote ntawm Windows (tsuas yog Yeej 10 Pro muaj Desktop Remote feature).

Nruab rau ntawm koj lub tshuab Windows, hauv kab ntawv tshawb fawb nyob rau sab saum toj ntawm VNCViewer, ntaus hauv RPi tus IP (192.168.1.40) lossis RPi lub npe hostname (kuv yog rpi1001.local) thiab Enter. Sau koj lub npe RPi tus password, xaiv 'Nco tus password' yog tias xav tau. Yog tias txhua yam mus tau zoo, koj yuav tsum pom pop-up Rpi desktop.

10. Txhawm rau xa cov ntaub ntawv los ntawm lossis mus rau TeamView, txoj hauv kev yooj yim tshaj plaws los siv cov ntaub ntawv hloov chaw los ntawm VNCView:

Thiab qhov ntawd, koj tuaj yeem siv Raspberry los khaws cov ntaub ntawv rau koj, thiab nkag mus nkag tau cov ntaub ntawv thaum xav tau.

Kauj Ruam 2: Npaj Piv Txwv Yooj Yim Los Sau Cov Ntaub Ntawv Los Ntawm Arduino

Npaj Ua piv txwv yooj yim los sau cov ntaub ntawv los ntawm Arduino
Npaj Ua piv txwv yooj yim los sau cov ntaub ntawv los ntawm Arduino
Npaj Ua piv txwv yooj yim los sau cov ntaub ntawv los ntawm Arduino
Npaj Ua piv txwv yooj yim los sau cov ntaub ntawv los ntawm Arduino

Cia hais tias koj xav sau qhov ntsuas kub los ntawm 4 lub ntsuas. Hauv qhov piv txwv no, kuv siv 18B20, qhov ntsuas kub nrov. Lwm yam kev xaiv yog TMP35, 36 tsev neeg lossis lub ntsuas cua sov.

Cov hlua txuas nrog rau saum toj no. 18B20s qhia cov xov hlau (lossis tsheb npav), thiab ntawm no yog Arduino code ntawm Github. Cov ntawv txuas hauv qab no muaj cov lej thiab daim ntawv qhia kab txuas ib yam.

Tsis tas li, teeb tsa USB tsav tsheb rau Arduino hauv Windows. Feem ntau 'clone' Arduino siv CH341 USB tsav tsheb. Tus tsav tsheb nyob ntawm no.

Nruab tus tsav tsheb, thaum ntsaws Arduino rau koj lub Windows 'USB, nws yuav tsum paub txog tus tsav tsheb thiab muab lub chaw nres nkoj COM (kuv yog COM4)

Serial Monitor yuav tsum tso tawm zoo li daim duab saum toj no.

Kauj Ruam 3: Rho Tawm RPi los ntawm Tshem Tawm thiab ntsaws lub zog rau RPi. Pib VNCViewer, Nkag Mus Rau Koj RPi

Boot Up RPi los ntawm Unplug thiab ntsaws lub zog rau RPi. Pib VNCViewer, Nkag Mus Rau Koj RPi
Boot Up RPi los ntawm Unplug thiab ntsaws lub zog rau RPi. Pib VNCViewer, Nkag Mus Rau Koj RPi
Boot Up RPi los ntawm Unplug thiab ntsaws lub zog rau RPi. Pib VNCViewer, Nkag Mus Rau Koj RPi
Boot Up RPi los ntawm Unplug thiab ntsaws lub zog rau RPi. Pib VNCViewer, Nkag Mus Rau Koj RPi
Boot Up RPi los ntawm Unplug thiab ntsaws lub zog rau RPi. Pib VNCViewer, Nkag Mus Rau Koj RPi
Boot Up RPi los ntawm Unplug thiab ntsaws lub zog rau RPi. Pib VNCViewer, Nkag Mus Rau Koj RPi
Boot Up RPi los ntawm Unplug thiab ntsaws lub zog rau RPi. Pib VNCViewer, Nkag Mus Rau Koj RPi
Boot Up RPi los ntawm Unplug thiab ntsaws lub zog rau RPi. Pib VNCViewer, Nkag Mus Rau Koj RPi

Hloov Python tsab ntawv, siv VNCViewer cov cuab yeej. Muaj tus chij nyob ze rau sab saum toj ntawm VNCViewer, nrhiav ob lub xub khawm. Txhawm rau hloov cov ntaub ntawv los ntawm RPi rau Windows, siv Cov Ntaub Ntawv Hloov Chaw hauv VNC cim rau sab saum toj-sab xis (ze rau lub cim Wifi) ntawm RPi lub desktop.

Raspberry khiav ntawm Linux, thiab Python 2 thiab 3 tau teeb tsa los ntawm lub neej ntawd. Koj tsuas yog yuav tsum teeb tsa lub tsev qiv ntawv Python hu ua pyserial los sau cov ntaub ntawv luam tawm los ntawm kab ntawv txuas.

txhawm rau teeb tsa Python Serial, ntaus kab no rau Linux davhlau ya nyob twg

sudo apt-tau nruab python3-serial

  • hauv Windows: ntaus PowellShell no:
  • pip.exe nruab pyserlal

Tom qab ntawd rub tawm tsab ntawv thiab khaws nws rau RPi lub desktop

Txhawm rau khiav tsab ntawv, ua ntej nws ua tiav los ntawm:

sudo chown u+x recordSerial.py

Rub tus lej Arduino mus rau Arduino board, tom qab ntawd ntsaws koj lub xov tooj USB nrog USB rau hauv, txheeb xyuas qhov chaw nres nkoj los ntawm:

  • Ntawm Linux, ntaus qhov no rau lub davhlau ya nyob twg: ls /dev /ttyUSB*
  • Ntawm Wndows: mus rau Tus Thawj Tswj Ntaus Ntawv, kos COM #

Yog tias tsab ntawv raug hloov kho ntawm Windows, koj yuav xav tau khiav Python tsab ntawv rau dos2unix kom tshem kab kab txawv txawv cim los ntawm Windows. Nruab nws los ntawm

sudo apt-tau nruab dos2unix

thiab hloov tsab ntawv los ntawm kev khiav qhov no hauv lub davhlau ya nyob twg

dos2unix recordSerial.py

Hloov kho qhov chaw nres nkoj tiag hauv tsab ntawv los ntawm tus kws kho ntawv:

sudo nano recordSerial.py

ces khiav./recordSerial.py yourfilename.txt

Python tsab ntawv yuav txuag cov ntaub ntawv los ntawm RAM rau disk rau txhua 10 kab, uas tuaj yeem hloov kho.

Txhawm rau tsis kaw, nias Ctrl + C, Tsab ntawv tuaj yeem ua haujlwm ntawm Windows (nyem ob zaug), lub npe ntawm cov ntaub ntawv teev npe yog lub neej ntawd uas suav nrog lub sijhawm

Yog tias koj PowerShell, koj tuaj yeem nkag mus rau koj lub npe lub npe tshwj xeeb, python.exe recordSerial.py awesome.txt

Tsis yog txhua 18B20s zoo ib yam. Saib qhov nyeem tawm!

Kuv thawb tus lej rau GitHub ib yam.

Vam tias qhov kev qhia no muaj txiaj ntsig!

Kauj Ruam 4: Nruab Samba los Qhia Cov Ntawv

Nruab Samba los Qhia Cov Ntawv
Nruab Samba los Qhia Cov Ntawv
Nruab Samba los Qhia Cov Ntawv
Nruab Samba los Qhia Cov Ntawv
Nruab Samba los Qhia Cov Ntawv
Nruab Samba los Qhia Cov Ntawv

Cov kauj ruam no yuav taug koj los ntawm qee qhov teeb tsa yooj yim kom muaj cov ntawv tais ceev tseg sib koom ua ke ntawm Raspberry Pi uas tuaj yeem nkag mus los ntawm lwm lub khoos phis tawj.

Ua ntej, teeb tsa samba, ib txoj haujlwm los qhia thiab tswj kev sib faib cov ntawv hla lub network:

sudo apt-tau nruab samba

ua daim ntawv sib koom

mkdir ~/Desktop/sambaShare

hloov kho cov ntaub ntawv teeb tsa rau samba los ntawm:

sudo samba /etc/samba/smb.conf

ntxiv cov kab hauv qab no mus rau qhov kawg ntawm cov ntawv:

[sambaShare] tawm tswv yim = faib nplaub tshev ntawm Kev Tshawb Fawb RPI txoj kev =/tsev/pi/Desktop/sambaShare tuaj yeem tshawb pom = yog nyeem nkaus xwb = tsis tuaj yeem sau = muaj pej xeem = muaj tsim daim npog = 0777 daim npog qhov ncauj = 0777 qhua ok = yog

Yog tias koj muaj teeb meem nrog kev sau ntawv ntawm windows, yuam nws los ntawm kev ntxiv kab no mus rau qhov kawg ntawm cov ntawv: quab yuam neeg siv = pi

Ntawm Linux, koj yuav xav tau siv tus neeg siv hauv paus (Kuv yuav tshaj tawm qhov teeb meem thaum kuv pom tawm)

Tom ntej no, ntxiv tus neeg siv rau samba thiab tsim tus password ib yam nkaus:

sudo smbpasswd -a pib

tom qab ntawd nkag mus tus password rau samba (tuaj yeem zoo ib yam lossis txawv dua li lo lus zais rau pi tus neeg siv ntawm lub kaw lus)

sim yog tias cov ntaub ntawv teeb tsa zoo

testparm

nias Ctrl+X kom txuag, thiab tom qab ntawd rov ua haujlwm samba los ntawm:

sudo systemctl rov pib dua smbd

Ntawm lub computer host, cia hais Linux:

yog tias tsis yog nruab samba ntxiv rau sambaclient, thiab cifs los txhawb kev sib koom tsav, thov ua li ntawd los ntawm kev khiav:

sudo apt-tau nruab samba smbclient cifs-utils

Txheeb xyuas yog tias cov ntawv sib faib ntawm RPI tau npaj los ntawm:

sudo smbclient -L yourRPI_IP

yog tias koj pom qhov sib koom tsav, tom qab ntawd tsim qhov taw tes rau ntawm Linux:

sudo mkdir /mnt /researchRPi

sudo chown neeg siv: usergroup -R /mnt /researchRPI

neeg siv, usergroup yog koj li Linux siv thiab pab pawg npe

tom qab ntawd nce qhov sib faib los ntawm:

sudo mount -f cifs -o username = pi // your_rpi_IP/sambaShare/mnt/researchRPi

sau koj tus password, thiab ua qhov txuas txuas rau koj lub desktop:

sudo ln -s/mnt/researchRPi ~/Desktop/researchRPi

yog tias koj muaj teeb meem nrog kev tso cai nyeem-sau ntawm daim ntawv faib, sim nrog kev tso cai tsis muaj zog:

pe PI:

sudo chmod -R 776 ~/Desktop/sambaShare

Hauv Windows, nws yooj yim dua, Mus rau Kuv Lub Computer, thiab qhia daim nplaub tshev, tom qab ntawd nkag mus rau IP ntawm RPI, daim ntawv sib koom yuav tsum tshwm sim. Kuv ntseeg tias muaj qee yam ntawm Mac uas koj tuaj yeem tshawb xyuas cov ntawv sib faib ntawm lub network.

Kauj Ruam 5: Cov ntaub ntawv siv tau

Hauv qab no yog qee cov ntaub ntawv muaj txiaj ntsig:

  1. Muaj lwm txoj hauv kev ntawm no siv lub tsev qiv ntawv pyserial thiab lej
  2. Ua tib zoo saib ntawm kev sib txuas lus hluav taws xob pib los ntawm kev txhim kho Arduino IDE. Cov ntaub ntawv zoo yog tias koj xav tau kev dhia dej tob.
  3. Luv luv tab sis kev sau ntawv. Kev xaiv luv thiab txaus rau lwm txoj hauv kev los teev cov ntaub ntawv

Pom zoo: