Cov txheej txheem:
- Kauj ruam 1: Yuav tsum kho vajtse
- Kauj ruam 2: Kho vajtse Hookup
- Kauj Ruam 3: Kev Sib Txuas Lus Siv I2C raws tu qauv
- Kauj ruam 4: Programming Module
- Kauj Ruam 5: Tsim Cov Ntaub Ntawv thiab Khiav Cov Cai
- Kauj Ruam 6: Cov ntawv thov
- Kauj Ruam 7: Cov peev txheej
Video: Tsev Automation Nrog Raspberry Pi Siv Relay Board: 7 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
Cov neeg suav coob xav tau kev nplij siab tab sis ntawm tus nqi tsim nyog. Peb xav tias tub nkeeg kom teeb lub tsev txhua hmo thaum lub hnub poob qis thiab sawv ntxov tom ntej, tig lub teeb dua lossis Hloov lub Cua Txias/Kiv cua/Cua sov rau/tawm raws li huab cua lossis chav sov.
Kev daws teeb meem pheej yig kom tsis txhob ua haujlwm ntxiv ntawm kev tua cov cuab yeej thaum xav tau yog ntawm no. Nws yog kom siv koj lub tsev nyob hauv qhov sib piv tsawg dua tus nqi siv cov khoom ntsaws yooj yim thiab ua si khoom. Nws ua haujlwm zoo li thaum qhov kub nce lossis nqis qis, nws tig lub tshuab cua txias lossis lub rhaub dej rau, feem. Tsis tas li, thaum xav tau, nws yuav pab qhib lossis teeb ntawm koj lub tsev yam tsis tau hloov lawv tus kheej. Thiab ntau yam khoom siv ntxiv tuaj yeem tswj tau. Cia peb pib koj lub tsev.
Kauj ruam 1: Yuav tsum kho vajtse
Peb yuav siv:
Raspberry Pi
Raspberry Pi yog pawg thawj coj saib xyuas Linux raws PC. Lub PC me me no tau ntim rau hauv kev sau npe lub zog, siv ua ib qho ntawm cov khoom siv hluav taws xob, thiab PC ua haujlwm zoo li daim ntawv nthuav dav, ua cov lus, ua haujlwm hauv web, thiab email, thiab ua si
I2C Shield lossis I2C Header
INPI2 (I2C adapter) muab Raspberry Pi 2/3 ib qho I²C chaw nres nkoj rau siv nrog ntau I2C khoom siv
I2C Relay maub los MCP23008
MCP23008 los ntawm Microchip yog Kev Sib Txuas ntawm qhov chaw nres nkoj uas tswj tau yim qhov kev xa mus los ntawm I²C npav. Koj tuaj yeem ntxiv ntau qhov xa tawm, digital I/O, analog rau cov hloov pauv digital, ntsuas, thiab lwm yam khoom siv siv I²C nthuav dav chaw nres nkoj
MCP9808 Kub Sensor
MCP9808 yog qhov ntsuas kub ntsuas qhov tseeb uas muab ntsuas, ntsuas qhov ntsuas qhov ntsuas hauv digital, I formatC hom
TCS34903 luminance sensor
TCS34903 yog xim xim tsev neeg cov khoom uas muab tus nqi ntawm RGB tivthaiv ntawm lub teeb thiab xim
I2C txuas cable
I2C txuas txuas cable yog 4-kab txuas uas yog lub ntsiab lus rau I2C kev sib txuas lus ntawm ob I2C cov cuab yeej txuas nrog los ntawm nws
Micro USB adapter
Txhawm rau txhawb nqa Raspberry Pi, peb xav tau Micro USB cable
12V fais fab adapter rau Relay board
MCP23008 Relay maub los ua haujlwm ntawm 12V lub zog sab nraud thiab qhov no tuaj yeem nkag tau siv 12V Power Adapter
Koj tuaj yeem yuav cov khoom los ntawm txhaj rau lawv. Tsis tas li, koj tuaj yeem pom cov khoom zoo ntxiv ntawm Dcube Store.
Kauj ruam 2: Kho vajtse Hookup
Cov kev sib txuas xav tau (xa mus rau cov duab) yog raws li hauv qab no:
- Qhov no yuav ua haujlwm dhau I2C. Siv I2C daim thaiv rau Raspberry pi thiab maj mam txuas nws mus rau GPIO pins ntawm Raspberry Pi.
- Txuas ib kawg ntawm I2C cable mus rau hauv-chaw nres nkoj ntawm TCS34903 thiab lwm qhov kawg rau I2C daim ntaub thaiv.
- Txuas MCP9808 lub ntsuas pa hauv lub lauj kaub rau TCS34903 tawm siv I2C cable.
- Txuas MCP23008 lub lauj kaub rau MCP9808 lub sensor tawm siv I2C cable.
- Kuj txuas Ethernet cable rau Raspberry Pi. Wi-Fi router kuj tseem tuaj yeem siv rau tib yam.
- Tom qab ntawd, fais fab Raspberry Pi siv Micro USB adapter thiab MCP23008 Relay board siv 12V adapter.
- Thaum kawg, txuas lub teeb nrog thawj qhov xa tawm thiab kiv cua lossis lub rhaub nrog kev xa xov thib ob. Koj tuaj yeem nthuav cov qauv lossis tuaj yeem txuas ntau lub cuab yeej nrog kev xa tawm.
Kauj Ruam 3: Kev Sib Txuas Lus Siv I2C raws tu qauv
Txhawm rau ua Raspberry Pi I2C qhib, ua raws li tau hais hauv qab no:
- Hauv davhlau ya nyob twg, ntaus cov lus txib hauv qab no kom qhib qhov teeb tsa kev teeb tsa: sudo raspi-config
- Xaiv "Advanced Options" nyob ntawm no.
- Xaiv "I2C" thiab Nyem "Yog".
- Rov pib dua lub system kom teeb tsa nws raws li qhov kev hloov pauv tau siv cov lus txib reboot.
Kauj ruam 4: Programming Module
Qhov khoom plig ntawm kev siv Raspberry Pi yog, uas yog muab rau koj qhov yooj yim los xaiv cov lus programming uas koj xav tau los ua haujlwm los cuam tshuam cov cuab yeej paub nrog Raspberry Pi. Kev siv cov txiaj ntsig zoo ntawm Raspberry Pi, peb tab tom qhia ntawm no nws cov haujlwm hauv Java.
Txhawm rau teeb tsa Java ib puag ncig, Txhim kho "pi4j libraby" los ntawm https://pi4j.com/1.2/index.html Pi4j yog Java Cov Lus Qhia/Tso Tawm Lub Tsev rau Raspberry Pi. lub tsev qiv ntawv "yog kom ua raws cov lus hais hauv qab no ncaj qha rau hauv koj li Raspberry Pi:
curl -s get.pi4j.com | sudo tsoo
LOS YOG
curl -s get.pi4j.com
ntshuam com.pi4j.io.i2c. I2CBus; ntshuam com.pi4j.io.i2c. I2CDevice; ntshuam com.pi4j.io.i2c. I2CFactory; ntshuam java.io. IOException; chav MCP23008 {pej xeem zoo li qub tsis muaj dab tsi tseem ceeb (Txoj hlua args ) cuam tshuam Kev zam {int xwm txheej, tus nqi, tus nqi 1 = 0x00; // Tsim I2C npav I2CBus npav = I2CFactory.getInstance (I2CBus. BUS_1); // Tau txais I2C ntaus ntawv, MCP23008 I2C chaw nyob yog 0x20 (32) I2CDevice ntaus ntawv = bus.getDevice (0x20); // Tau txais I2C ntaus ntawv, MCP9808 I2C chaw nyob yog 0x18 (24) I2CDevice MCP9808 = bus.getDevice (0x18); // Tau I2C ntaus ntawv, TCS34903 I2C chaw nyob yog 0x39 (55) I2CDevice TCS34903 = bus.getDevice (0x39); // Teeb Sijhawm Tos Sijhawm sau npe = 0xff (255), tos sijhawm = 2.78 ms TCS34903.write (0x83, (byte) 0xFF); // Pab kom nkag mus rau IR channel TCS34903.write (0xC0, (byte) 0x80); // Teeb tsa lub sijhawm sau npe rau 0x00 (0), suav ntau tshaj = 65535 TCS34903.write (0x81, (byte) 0x00); // Hwj chim ON, ADC qhib, Tos qhib TCS34903.write (0x80, (byte) 0x0B); Xov.sleep (250); // Nyeem 8 Bytes ntawm Cov Ntaub Ntawv nrog cov ntaub ntawv ntshiab/ir LSB thawj byte data1 = tshiab byte [8]; // Nyeem Cov Ntaub Ntawv Kub byte cov ntaub ntawv = tshiab byte [2]; xwm txheej = device.read (0x09); // Kho txhua tus pin li OUTPUT device.write (0x00, (byte) 0x00); Xov.sleep (500); thaum (muaj tseeb) {MCP9808.read (0x05, cov ntaub ntawv, 0, 2); // Hloov cov ntaub ntawv int temp = ((data [0] & 0x1F) * 256 + (data [1] & 0xFF)); yog (temp> 4096) {temp -= 8192; } ob cTemp = temp * 0.0625; System.out.printf (“Kub hauv c Celsius yog: %.2f C %n”, cTemp); TCS34903.read (0x94, data1, 0, 8); ob ir = ((data1 [1] & 0xFF) * 256) + (data1 [0] & 0xFF) * 1.00; ob npaug liab = ((data1 [3] & 0xFF) * 256) + (data1 [2] & 0xFF) * 1.00; ob npaug ntsuab = ((data1 [5] & 0xFF) * 256) + (data1 [4] & 0xFF) * 1.00; ob npaug xiav = ((data1 [7] & 0xFF) * 256) + (data1 [6] & 0xFF) * 1.00; // Xam lub teeb pom kev ob npaug = (-0.32466) * (liab) + (1.57837) * (ntsuab) + (-0.73191) * (xiav); System.out.printf (“Teeb pom kev zoo yog: %.2f lux %n“, teeb pom kev zoo); yog (qhov pom kev 30) {tus nqi = tus nqi 1 | (0x01); } lwm {tus nqi = tus nqi 1 & (0x02); } ntaus ntawv.write (0x09, (byte) tus nqi); Xov.sleep (300); }}}
Kauj Ruam 5: Tsim Cov Ntaub Ntawv thiab Khiav Cov Cai
- Txhawm rau tsim cov ntaub ntawv tshiab qhov twg cov cai tuaj yeem sau/luam, cov lus hais hauv qab no yuav raug siv: sudo nano FILE_NAME.javaEg. sudo nano MCP23008.java
- Tom qab tsim cov ntawv, peb tuaj yeem nkag mus rau cov lej hauv no.
- Luam cov cai uas tau muab hauv cov kauj ruam dhau los thiab muab nws tso rau ntawm lub qhov rais ntawm no.
- Nias Ctrl+X ces "y" kom tawm mus.
- Tom qab ntawv sau cov cai siv cov lus txib hauv qab no: pi4j FILE_NAME.javaEg. pi4j MCP23008.java
- Yog tias tsis muaj qhov yuam kev, khiav qhov program siv cov lus hais hauv qab no: pi4j FILE_NAMEEg. pi4j MCP23008.java
Kauj Ruam 6: Cov ntawv thov
Cov kab ke no tso cai rau koj los tswj cov cuab yeej yam tsis mus rau phab ntsa hloov. Qhov no muaj peev xwm nthuav dav raws li lub sijhawm tig cov cuab yeej rau lossis tua tau pib ua haujlwm. Muaj ntau daim ntawv thov ntawm cov qauv no los ntawm cov tsev mus rau kev lag luam, tsev kho mob, chaw nres tsheb ciav hlau thiab ntau qhov chaw tuaj yeem siv tau yooj yim hauv txoj kev pheej yig thiab yooj yim los ntawm nws cov khoom sib txuas thiab ua si.
Kauj Ruam 7: Cov peev txheej
Yog xav paub ntxiv txog TSL34903, MCP9808 MCP23008 Tus Tswj Tus Kheej, txheeb xyuas qhov txuas hauv qab no:
- TSL34903 Cov ntawv xov xwm
- Cov Ntaub Ntawv Keeb Kwm Dav Hlau rau MCP9808 los ntawm Kev Tshawb Dav Dav Dav
- Cov Ntaub Ntawv Keeb Kwm Dav Hlau rau MCP23008 los ntawm Kev Tshawb Dav Dav Dav
Pom zoo:
Tuchless Hloov rau Cov Khoom Siv Hauv Tsev -- Tswj Koj Cov Khoom Siv Hauv Tsev Tsis Muaj Tuch Ib qho Hloov: 4 Cov Kauj Ruam
Tuchless Hloov rau Cov Khoom Siv Hauv Tsev || Tswj Koj Cov Khoom Siv Hauv Tsev Tsis Muaj Tuch Ib qho Hloov: Nov Yog Qhov Tuchless Hloov Rau Cov Khoom Siv Hauv Tsev. Koj Siv Tau Qhov No Mus Rau Txhua Qhov Chaw Hauv Pej Xeem Kom Pab Tau Tawm Tsam Ib Yam Kab Mob. Lub Circuit Court Raws Li Tsaus Sensor Circuit Ua Los Ntawm Op-Amp Thiab LDR. Qhov Tseem Ceeb Thib Ob Ntawm Qhov Circuit Court SR Flip-Flop Nrog Sequencell
Yuav Ua Li Cas Ua IoT Raws Hauv Tsev Automation Nrog NodeMCU Sensors Control Relay: 14 Cov Kauj Ruam (nrog Duab)
Yuav Ua Li Cas Ua IoT Raws Hauv Tsev Automation Nrog NodeMCU Sensors Control Relay: Hauv qhov haujlwm IoT raws li no, Kuv tau ua Tsev Automation nrog Blynk thiab NodeMCU tswj kev xa xov module nrog cov lus tawm ntawm lub sijhawm. Hauv Phau Ntawv Hom, qhov kev hloov pauv no tuaj yeem tswj tau los ntawm Txawb lossis smartphone thiab, Hloov kev siv. Hauv Auto Hom, qhov smar
Yuav Ua Li Cas Ntse Tsev Siv Arduino Control Relay Module - Lub Tswv Yim Hauv Tsev Automation: 15 Kauj Ruam (nrog Duab)
Yuav Ua Li Cas Ntse Tsev Siv Arduino Control Relay Module | Lub Tswv Yim Ua Lag Luam Hauv Tsev: Hauv qhov haujlwm ua haujlwm hauv tsev no, peb yuav tsim lub tsev ntse hloov chaw uas tuaj yeem tswj tau 5 yam khoom siv hauv tsev. Qhov kev hloov pauv no tuaj yeem tswj tau los ntawm Txawb lossis smartphone, IR chaw taws teeb lossis TV nyob deb, Kev hloov pauv ntawm tes. Qhov kev tshaj tawm ntse no tseem tuaj yeem paub txog r
Tsev Automation Kauj Ruam ntawm Kauj Ruam Siv Wemos D1 Mini Nrog PCB Tsim: 4 Kauj Ruam
Tsev Automation Kauj Ruam Ib Leeg Siv Wemos D1 Mini Nrog PCB Tsim: Tsev Automation Kauj Ruam los ntawm Kauj Ruam siv Wemos D1 Mini nrog PCB Tsim cov tub ntxhais kawm ntawv qib siab. Tom qab ntawd ib tus ntawm peb cov tswv cuab tuaj
Tsev Automation: Tsis Siv Neeg Hloov Board Nrog Dimmer Tswj Via Bluetooth Siv Tiva TM4C123G: 7 Cov Kauj Ruam
Kev Siv Lub Tshuab Hauv Tsev: Tsis Siv Neeg Hloov Lub Rooj Tswjhwm Saib Nrog Dimmer Tswj Via Bluetooth Siv Tiva TM4C123G: Tam sim no, peb muaj kev tswj chaw taws teeb rau peb cov TV thiab lwm yam tshuab hluav taws xob, uas tau ua rau peb lub neej yooj yim heev. Koj puas tau xav tsis thoob txog kev siv tshuab hauv tsev uas yuav muab lub chaw tswj cov raj teeb, kiv cua thiab lwm yam khoom siv