Cov txheej txheem:

Raspberry Pi Smart NightLight: 5 Kauj Ruam
Raspberry Pi Smart NightLight: 5 Kauj Ruam

Video: Raspberry Pi Smart NightLight: 5 Kauj Ruam

Video: Raspberry Pi Smart NightLight: 5 Kauj Ruam
Video: Night Light using Raspberry Pi 2024, Kaum ib hlis
Anonim
Raspberry Pi Smart NightLight
Raspberry Pi Smart NightLight

Tsis ntev los no kuv tau sawv ntxov, ntau zaus hnub sab nraum tseem tsaus ntuj, tab sis kuv tsis xav qhib lub teeb kom cuam tshuam rau kuv tus poj niam so, yog li kuv tau xav txog kev yuav lub teeb hmo ntuj. Kuv tshawb nrhiav ntau lub khw hmo ntuj, tab sis kuv tsis xav tias nws yog kuv xav tau, tab sis kuv pom lub teeb hmo ntuj hu ua DockerPi hauv khw hauv Amazon, uas yog tswj los ntawm Raspberry Pi. Nws zoo heev thiab tuaj yeem muab cov yam ntxwv DIY. Kuv nyeem cov lus piav qhia wiki ntawm cov khoom no, nws tuaj yeem tswj tau ncaj qha los ntawm kab hais kom ua, raws li tus programmer siv Linux system, Kuv xav tias qhov no zoo heev, yog li kuv yuav nws rov qab thiab pib qhov haujlwm no.

Kauj Ruam 1: Kauj Ruam 1: Npaj Txhua Yam Khoom

Kauj Ruam 1: Npaj Txhua Yam Khoom
Kauj Ruam 1: Npaj Txhua Yam Khoom

Tom qab unboxing thiab tom qab ntawd kuv tshem daim npog tiv thaiv ntawm cov phaj acrylic, thiab tom qab ntawd teeb tsa DockerPi tus qauv rau kuv Raspberry Pi nrog cov ntsia hlau thiab tooj liab lo. nws ruaj khov.

Kauj Ruam 2: Kauj Ruam 2: Nyem Qhov Tseeb Rasbpian OS Duab rau SD Card

Kauj Ruam 2: Nyem Qhov Tseeb Rasbpian OS Duab rau SD Card
Kauj Ruam 2: Nyem Qhov Tseeb Rasbpian OS Duab rau SD Card
Kauj Ruam 2: Nyem Qhov Tseeb Rasbpian OS Duab rau SD Card
Kauj Ruam 2: Nyem Qhov Tseeb Rasbpian OS Duab rau SD Card
Kauj Ruam 2: Nyem Qhov Tseeb Rasbpian OS Duab rau SD Card
Kauj Ruam 2: Nyem Qhov Tseeb Rasbpian OS Duab rau SD Card

Kuv rub cov duab Raspbian tshiab los ntawm:

thiab tom qab ntawd nyem cov duab ntawm lub software hu ua: etcher

koj tuaj yeem rub tawm ntawm no:

unzip daim ntawv duab los ntawm pob gzip thiab koj yuav tau txais *.img cov ntaub ntawv, xaiv cov duab thiab xaiv tsav uas koj lub PC lees paub daim npav TF, tsuas yog nyem "Flash" thiab tos ob peb feeb, nws yuav ua tiav.

thiab tom qab ntawd tshem daim npav TF thiab ntxig nws rau koj li Raspberry Pi thiab txhawb nws.

Kauj Ruam 3: Kauj Ruam 3: Qhib I2C Function Los ntawm Raspi-teeb tsa

Kauj Ruam 3: Qhib I2C Function Los ntawm Raspi-teeb tsa
Kauj Ruam 3: Qhib I2C Function Los ntawm Raspi-teeb tsa
Kauj Ruam 3: Qhib I2C Function Los ntawm Raspi-teeb tsa
Kauj Ruam 3: Qhib I2C Function Los ntawm Raspi-teeb tsa
Kauj Ruam 3: Qhib I2C Function Los ntawm Raspi-teeb tsa
Kauj Ruam 3: Qhib I2C Function Los ntawm Raspi-teeb tsa
Kauj Ruam 3: Qhib I2C Function Los ntawm Raspi-teeb tsa
Kauj Ruam 3: Qhib I2C Function Los ntawm Raspi-teeb tsa

Thaum Raspberry pi pib, kuv qhib lub davhlau ya nyob twg thiab ntaus cov lus txib no: sudo raspi-config

thiab mus rau "Cov Kev Sib Txuas" thiab xaiv "I2C" thiab qhib nws. vim li cas kuv thiaj yuav tsum siv cov lus txib no?

Vim tias DockerPi lub teeb hmo ntuj siv I2C raws tu qauv sib tham nrog Raspberry Pi.

Kauj Ruam 4: Kauj Ruam 4: Txuas lub Acrylic Panel rau ntawm lub qhov

Kauj Ruam 4: Txuas lub Acrylic Panel rau ntawm lub qhov
Kauj Ruam 4: Txuas lub Acrylic Panel rau ntawm lub qhov
Kauj Ruam 4: Txuas lub Acrylic Panel rau ntawm lub qhov
Kauj Ruam 4: Txuas lub Acrylic Panel rau ntawm lub qhov
Kauj Ruam 4: Txuas lub Acrylic Panel rau ntawm lub qhov
Kauj Ruam 4: Txuas lub Acrylic Panel rau ntawm lub qhov

Nws haum rau lub qhov zoo heev, thiab koj tuaj yeem pom daim duab uas lub vaj huam sib luag acrylic tuaj yeem nyob twj ywm hauv qhov.

cov kauj ruam tom ntej yog khiav cov cai ntsuas los xyuas seb nws ua haujlwm zoo.

Kuv tau rub tus lej piv txwv los ntawm github ntawm kev ntaus cov lus txib no hauv davhlau ya nyob twg ntawm raspberry Pi.

cd ~ ib

git clone

cd dockerpi/Hmo ntuj/

sudo./Nightligh.sh

thiab tom qab ntawd kuv lub teeb hmo ntuj tig thiab ci.

Kuv nyeem cov lus qhia ntawm nws lub wiki thiab pom tag nrho cov teeb pom kev ntawm LED lub npe daim ntawv qhia chaw.

cov kauj ruam tom ntej yuav yog qhov lom zem tshaj plaws, Kuv xav ntxiv tib neeg lub cev infrared pyroelectric sensor, cia nws kuaj pom tias kuv tau teeb rau lub teeb hmo hmo no ~

Kauj Ruam 5: Kauj Ruam 5: Teeb Infrared Pyroelectric Sensor

Kauj Ruam 5: Teeb Infrared Pyroelectric Sensor
Kauj Ruam 5: Teeb Infrared Pyroelectric Sensor
Kauj Ruam 5: Teeb Infrared Pyroelectric Sensor
Kauj Ruam 5: Teeb Infrared Pyroelectric Sensor
Kauj Ruam 5: Teeb Infrared Pyroelectric Sensor
Kauj Ruam 5: Teeb Infrared Pyroelectric Sensor

Ntawm no, peb tab tom siv lub PIR tsab ntawv tsa suab sensor. PIR sawv rau passive infrared. Qhov ntsuas lub suab no suav nrog lub iav fresnel, lub ntsuas hluav taws xob pom, thiab txhawb nqa kev tshawb nrhiav hluav taws xob. Lub lens ntawm lub sensor tsom mus rau ib qho hluav taws xob hluav taws xob tam sim no nyob ib puag ncig nws mus rau lub ntsuas hluav taws xob. Peb lub cev tsim hluav taws xob cua sov, thiab vim li ntawd, qhov cua sov no tau khaws los ntawm lub suab txav. Lub ntsuas hluav taws xob tso tawm 5V teeb liab rau ib pliag ntawm ib feeb sai li sai tau thaum nws pom tias muaj tus neeg. Nws muaj qhov ntsuas qhov ntsuas ntawm kwv yees li ntawm 6-7 meters thiab muaj kev nkag siab zoo. Thaum PIR lub suab ntsuas pom ib tus neeg, nws tso tawm 5V teeb liab rau Raspberry Pi los ntawm nws GPIO thiab peb txheeb xyuas dab tsi Raspberry Pi yuav tsum ua raws li nws pom tus neeg nkag los ntawm Python coding. Ntawm no peb tsuas yog luam tawm "Tus neeg nkag nkag pom".

Tom qab koj tau teeb tsa koj li Raspberry Pi, tam sim no peb tuaj yeem pib cuam tshuam nrog nws GPIO koob. Ntawm no, peb yuav sim ntsais ib qho LED siv tus ntawv Python. Luam thiab muab cov cai hauv qab no tso rau hauv koj li Raspberry Pi. Koj tuaj yeem ua qhov no los ntawm kev qhib cov ntawv sau "leafpad" ntawm koj li Raspberry Pi thiab luam cov cai no rau hauv nws, thiab khaws qhov no ua Python cov ntaub ntawv: nightlight.py:

#import cov tsev qiv ntawv.

ntshuam RPi. GPIO ua GPIO

lub sij hawm ntshuam

ntshuam smbus

DEVICE_BUS = 1

DEVICE_ADDR = 0x15

GPIO.setwarnings (Cuav)

GPIO.setmode (GPIO. BOARD)

GPIO.setup (11, GPIO. IN) #Nyeem cov zis los ntawm PIR tsab ntawv tsa suab sensor

npav = smbus. SMBus (DEVICE_BUS) # piv txwv ntawm smbus rau i2c ntaus ntawv, txhais tau tias hmo ntuj.

thaum Muaj Tseeb:

sim:

kuv = GPIO.input (11)

yog tias kuv == 0: #Thaum lub zog tso tawm los ntawm lub suab sensor LOW

print ("Tsis muaj neeg nkag los", kuv)

rau kuv hauv ntau (1, 25):

bus.write_byte_data (DEVICE_ADDR, kuv, 0x00) #Tua OFF LED

sijhawm.s pw (0.2)

sijhawm.s pw (0.1)

elif i == 1: #Thaum cov zis los ntawm lub suab sensor yog HIGH

print ("Intruder kuaj pom", i)

rau kuv hauv ntau (1, 25):

bus.write_byte_data (DEVICE_ADDR, kuv, 0xFF) #Tua OFF LED

sijhawm.s pw (0.2)

sijhawm.s pw (0.1)

tshwj tsis yog KeyboardInterrupt li e:

print ("Tawm lub voj")

thiab tom qab ntawd khaws nws thiab ua kom nws khiav thaum lub raspberry pi khau raj.

sudo vim.tiny /etc/rc.local

thiab ntxiv kab no ua ntej tawm 0:

sudo nab hab sej /home/pi/nightlight.py &

thiab tom qab ntawd khaws nws thiab rov pib dua koj Pi, nws yuav ua haujlwm tau zoo …

Tsaug rau saib ~

Pom zoo: