Cov txheej txheem:
- Kauj Ruam 1: Cov Khoom & Cov Khoom Siv
- Kauj Ruam 2: Nqe lus piav qhia: Sense Hat
- Kauj Ruam 3: Sib Sau Ua Ke: Cov Ntawv Cuam Tshuam
- Kauj Ruam 4: Sib Sau Ua Ke: Cov Ntawv Cuam Tshuam ntawm Dash Board ntawm Tsheb
- Kauj Ruam 5: Qhov cuam tshuam Recoder: Ua Haujlwm & Cov Ntawv Thov
- Kauj Ruam 6: Kev Piav Qhia Software: Node Liab
- Kauj Ruam 7: Node-red Basics
- Kauj Ruam 8: Node-liab: Txaus _1a
- Kauj Ruam 9: Node Liab: Flow_1b
- Kauj Ruam 10: Node Liab: Flow_2a
- Kauj Ruam 11: Node Liab: Flow_2b
- Kauj Ruam 12: Noob Liab; Txaus _3
- Kauj ruam 13: MQTT
- Kauj Ruam 14: MQTT: Cov neeg siv npe
- Kauj Ruam 15: MQTT: Kho Cov Khoom hauv Node-liab
- Kauj Ruam 16: Tus nab npawb Code:
- Kauj Ruam 17: Txoj Cai Kawg
- Kauj Ruam 18: Saib Xyuas Cov Yees Duab Nyob
Video: Cov Ntawv Cuam Tshuam Rau Cov Tsheb: 18 Kauj Ruam (nrog Duab)
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Impact Recorder tau tsim los sau cov kev cuam tshuam rau lub tsheb thaum tsav tsheb lossis nyob ruaj khov. Cov kev cuam tshuam tau muab khaws cia rau hauv lub hauv paus hauv daim ntawv ntawm kev nyeem nrog rau cov vis dis aus/duab. Thaum cuam tshuam rau cov neeg siv nyob deb tuaj yeem txheeb xyuas qhov tseeb ntawm lub sijhawm, thiab cov neeg siv nyob deb tuaj yeem tuaj yeem saib cov vis dis aus uas tau khaws tseg lossis siv cov chaw deb mus rau pi lub koob yees duab thiab saib cov xwm txheej raws li.
Kauj Ruam 1: Cov Khoom & Cov Khoom Siv
(1) Raspberry Pi 3 lossis zoo dua: Kev suav lub zog xav tau
(2) Raspberry pi kev nkag siab lub kaus mom
(3) Raspberry pi lub koob yees duab / Usb lub koob yees duab
(4) Daim npav nco nrog cov duab raspbian tseeb (Yuav tsum txhawb cov liab, yuav luag txhua daim duab tshiab ua)
(5) Lub zog siv hluav taws xob tsawg kawg 2.1 A (Kuv tau siv lub txhab nyiaj roj teeb rau kev ua haujlwm ib leeg hauv tsheb)
Kauj Ruam 2: Nqe lus piav qhia: Sense Hat
Sense HAT muaj 8 × 8 RGB LED matrix, tsib-khawm joystick thiab suav nrog cov ntsuas hauv qab no:
- Gyroscope
- Accelerometer
- Magnetometer
- Kub
- Barometric
- siab
- Vaum
Xav paub ntau ntxiv txog kev ua haujlwm nrog lub kaus mom zoo tuaj yeem muab los ntawm cov kab txuas hauv qab no: Sense_Hat
API rau kev nkag siab lub kaus mom tau tuav ntawm: Sense_hat_API
Txoj cai rau kev nkag siab lub kaus mom tau hais nyob hauv cov theem tom ntej. Kev paub lub kaus mom txoj cai kuj tseem tuaj yeem ua piv txwv ntawm tus tswv sim ntawm: Sense-hat simulator
Kauj Ruam 3: Sib Sau Ua Ke: Cov Ntawv Cuam Tshuam
- Kev sib sau ua ke yog yooj yim dua li lub kaus mom kev xav yuav tsum tau teeb tsa hla pi (xaiv cov ntsia hlau ntsia tau muab nrog lub kaus mom zoo).
- Lub koob yees duab USB lossis lub koob yees duab pi tuaj yeem txuas nrog. Hauv kev qhia, pi lub koob yees duab tau txiav txim siab thiab raws li kev sau npe yog ua rau tib yam.
- Ntxig daim npav nco thiab teeb tsa sej code thiab node -red (teeb tsa & code tau them rau hauv cov kauj ruam ntxiv)
Daim duab saum toj no qhia pi-lub koob yees duab txuas nrog los ntawm txoj hlua txuas ncaj qha rau pi
Kauj Ruam 4: Sib Sau Ua Ke: Cov Ntawv Cuam Tshuam ntawm Dash Board ntawm Tsheb
Rau kev teeb tsa lub kaw lus, kuv tau siv daim kab xev ob npaug, qhov zoo dua yog lub kaw suab tuaj yeem hloov pauv tau yooj yim hauv txoj haujlwm sib txawv, qhov twg yog qhov haum tshaj plaws rau koj lub tsheb.
Lub koob yees duab ntxiv tau teeb tsa ntsug raws li qhia, siv tib daim kab xev ib sab, Tom ntej hauv kab yog txhawm rau txuas lub zog siv hluav taws xob (10, 000 mAH lub txhab nyiaj fais fab) nrog rau kev npaj internet txuas
Kev sib txuas hauv Is Taws Nem yuav tsum tau thov rau MQTT daim ntawv thov (cov ntsiab lus rau MQTT tau them rau hauv cov kauj ruam ntxiv)
Kauj Ruam 5: Qhov cuam tshuam Recoder: Ua Haujlwm & Cov Ntawv Thov
Los ntawm kev nkag siab lub kaus mom, ua kom nrawm dua thiab ntsuas lub ntsej muag tau siv los tshuaj xyuas seb cov txiaj ntsig nyoos yog dhau qhov kev txwv hauv txoj cai.
Accelerometer: Tus ntsuas hluav taws xob qhia qhov ntau ntawm lub zog nqus (G-quab yuam) ua rau txhua ntawm x, y & z axis, yog tias ib lub axis ntsuas ntau dua 1G quab yuam, tshaj li qhov txav tau tuaj yeem kuaj pom. (thov nco ntsoov lub axis taw qhia qis yuav muaj 1g tus nqi thiab yuav tsum tau txiav txim siab raws li hauv sej chaws).
Gyroscope; Lub gyroscope tau siv los ntsuas kev txav lub kaum ntse ntse, piv txwv li thaum lub ntse tig lub sensor tuaj yeem qhib tau (nyob ntawm qhov teeb tsa hauv txoj cai), yog li tus neeg nrawm nrawm lub tsheb yuav raug ntes !!
Ib qho kev ua haujlwm ntawm kev txwv txwv kuj tseem tshwm ntawm qhov kev nkag siab lub kaus mom LED matrix li "!" liab rau kev nrawm & ntsuab rau kev ua haujlwm gyroscope
Kauj Ruam 6: Kev Piav Qhia Software: Node Liab
Node-RED yog cov cuab yeej ua haujlwm raws li txheej txheem, ib txwm tsim los ntawm IBM's Emerging Technology Servicesteam thiab tam sim no yog ib feem ntawm JS Foundation.
Xav paub ntau ntxiv ntawm qhov liab tuaj yeem tau txais los ntawm kab ntawv txuas hauv qab no: node-red
Rau peb cov ntaub ntawv peb yuav siv node -red rau cov haujlwm hauv qab no
(1) Sib cuam tshuam nrog cov joysticks kom pib lub koob yees duab ua haujlwm
(2) Saib xyuas qhov cuam tshuam ntawm lub tsheb thiab xa cov ntaub ntawv mus rau cov neeg siv kawg los ntawm kev siv MQTT thiab txuas ntxiv lees txais cov neeg siv kawg cov lus txib los ntawm MQTT thiab pib qhov kev thov tsim nyog ntawm pi
(3) Ua qee yam khoom yooj yim xws li kaw pi
Cov kauj ruam txuas ntxiv muab cov ntaub ntawv ntxaws ntxaws rau daim duab ntws siv rau ntawm node-liab
Thov nco ntsoov cov duab kab liab liab sib cuam tshuam nrog tus nab npawb nab npawb, yog li qhov tom kawg suav nrog tus nab npawb nab npawb
Kauj Ruam 7: Node-red Basics
Cov theem pib yooj yim tau hais qhia kom pib Node-liab nyob rau hauv nyem, tab sis yog node-liab yog yooj yim dhau los pib thiab ua haujlwm tawm daim ntawv thov.
- Pib Node-liab: https:// localhost: 1880.
- Pib Node-liab thaum pi txuas nrog internet https:// ip address>: 1880
Kauj Ruam 8: Node-liab: Txaus _1a
Flow _1a, saib xyuas txhua qhov kev hloov pauv hauv CSV cov ntaub ntawv thiab ntawm qhov hloov pauv, piv txwv li cuam tshuam pom, lub koob yees duab kaw suab tau teeb tsa rau ntawm hom thiab ntxiv rau tus neeg siv tau ceeb toom hauv is taws nem tias muaj kev cuam tshuam tshwm sim
Kauj Ruam 9: Node Liab: Flow_1b
Hauv qhov hais tawm, kaw cov vis dis aus tuaj yeem pib ntawm txhua lub sijhawm los ntawm kev nias lub joystick
Kauj Ruam 10: Node Liab: Flow_2a
Hauv qhov hais los no, thaum twg muaj cov duab tshiab lossis yees duab tshiab khaws cia/muab tso rau hauv cov npe cov ntaub ntawv raug xa mus rau tus neeg siv npe hauv internet
Kauj Ruam 11: Node Liab: Flow_2b
Cov dej ntws no tau tsim ua ntej rau cov neeg siv nyob deb, yog li txhawm rau tswj lub cuab yeej raws li hauv qab no
(a) kaw lub cuab yeej
(b) thaij duab
(c) Sau cov vis dis aus
(d) pib lub ntsiab cai (datalogger code yog lub chaws tseem ceeb uas suav qhov cuam tshuam)
Kauj Ruam 12: Noob Liab; Txaus _3
Cov dej ntws tau tsim los rau kev nkag mus hauv zos, yog li txhawm rau pib lub ntsiab cai lossis kaw lub cuab yeej
Kauj ruam 13: MQTT
MQTT (Message Queuing Telemetry Transport) yog TCP/IP raws tu qauv, nyob ntawm tus tshaj tawm thiab cov neeg siv khoom cuam tshuam.
Hauv Peb Cov Ntaub Ntawv Pi yog tus tshaj tawm, qhov uas daim ntawv thov teeb tsa hauv peb lub xov tooj/PC yuav tsum yog tus neeg siv.
Txoj hauv kev no ntawm kev tsim tawm ntawm kev cuam tshuam, cov ntaub ntawv raug xa mus nyob deb rau tus neeg siv (kev ua haujlwm internet txuas yuav tsum tau)
Xav paub ntau ntxiv txog MQTT tuaj yeem nkag los ntawm qhov txuas hauv qab no: MQTT
Txhawm rau pib siv MQTT, peb yuav tsum sau npe ua ntej, rau qhov kev qhia kuv tau siv cloudmqtt (www.cloudmqtt.com), muaj phiaj xwm pub dawb hauv qab "miv ntxim hlub", yog li ntawd.
Tom qab sau npe tsim ib qho piv txwv hais "pi" tom qab uas koj yuav tau txais cov ntsiab lus hauv qab no
- Lub npe neeg rau zaub mov
- chaw nres nkoj
- lub npe siv
- lo lus zais
Cov lus saum toj no yuav tsum tau ua thaum sau npe los ntawm mobile/pc
Rau kuv daim ntawv thov, kuv tau siv MQTT daim ntawv thov los ntawm google play store (Android version)
Kauj Ruam 14: MQTT: Cov neeg siv npe
MQTT daim ntawv thov khiav ntawm txawb (Android version)
Qhov cuam tshuam pom ntawm pi tau xa rov qab
Kauj Ruam 15: MQTT: Kho Cov Khoom hauv Node-liab
Hauv qhov-liab tom qab xaiv MQTT ntawm, "Lub npe neeg rau zaub mov" thiab "lub ncauj lus" kom hais. Qhov no yuav tsum zoo ib yam ntawm cov neeg siv kawg
Kauj Ruam 16: Tus nab npawb Code:
Txoj haujlwm ua haujlwm tau zoo yog raws li daim ntawv txuas nrog
Kauj Ruam 17: Txoj Cai Kawg
Nab hab sej chaws yog txuas
Txhawm rau ua kom peb cov ntawv sej khiav los ntawm lub davhlau ya nyob twg, peb yuav tsum ua kom lawv ua haujlwm tau raws li chmod +x datalogger.py, tshaj qhov saum toj kawg nkaus ntawm cov cai yuav tsum muaj cov kab lus hauv qab no "shebang" #! /usr/bin/python3 (qhov no xav tau txhawm rau txhawm rau ua haujlwm ntawm node-liab)
#!.
kev nkag siab = SenseHat ()
import cov
timestamp = datetime.now ()
ncua = 5 // ncua tau txhais los khaws cov ntaub ntawv hauv data.csv file liab = (255, 0, 0) ntsuab = (0, 255, 0) daj = (255, 255, 0)
#GPIO.setmode (GPIO. BCM)
#GPIO.setup (17, GPIO. OUT)
def tau_sense_impact ():
sense_impact = acc = sense.get_accelerometer_raw () sense_impact.append (acc ["x"]) sense_impact.append (acc ["y"]) sense_impact.append (acc ["z"])
gyro = sense.get_gyroscope_raw ()
sense_impact.append (gyro ["x"]) sense_impact.append (gyro ["y"]) sense_impact.append (gyro ["z"])
rov sense_impact
def cuam tshuam (): // ua haujlwm txhawm rau txheeb xyuas qhov cuam tshuam #GPIO.setmode (GPIO. BCM) #GPIO.setup (4, GPIO. OUT) nrawm = sense.get_accelerometer_raw () x = acceleration ['x'] y = acceleration ['y'] z = acceleration ['z'] x = abs (x) y = abs (y) z = abs (z)
gyro = sense.get_gyroscope_raw ()
gyrox = gyro ["x"] gyroy = gyro ["y"] gyroz = gyro ["z"]
gyrox = puag ncig (gyrox, 2)
gyroy = puag ncig (gyroy, 2) gyroz = puag ncig (gyroz, 2)
cuam tshuam = get_sense_impact ()
yog x> 1.5 lossis y> 1.5 lossis z> 1.5: // cov txiaj ntsig tau teeb tsa tom qab rov ua dua ntawm txoj kev tiag tiag tuaj yeem hloov pauv raws li hom sib txawv thiab kev tsav tsheb nrog qhib ('impact.csv', 'w', newline = ' ') as f: data_writer = writer (f) data_writer.writerow ([' acc x ',' acc y ',' acc z ',' gyro x ',' gyro y ',' gyro z ']) #GPIO. cov zis (4, GPIO. HIGH) sense.clear () sense.show_letter ("!", liab) data_writer.writerow (cuam tshuam)
elif gyrox> 1.5 lossis gyroy> 1.5 lossis gyroz> 1.5: // qhov tseem ceeb tau teeb tsa saib mus rau qhov nrawm uas tig tau pib nrog qhib ('cuam tshuam.csv', 'w', newline = '') raws li f: data_writer = writer (f) data_writer.writerow (['acc x', 'acc y', 'acc z', 'gyro x', 'gyro y', 'gyro z']) #GPIO.output (4, GPIO. HIGH) sense.clear () sense.show_letter ("!", Ntsuab) data_writer.writerow (cuam tshuam)
lwm tus:
# GPIO.output (4, GPIO. LOW) sense.clear ()
def get_sense_data (): // muaj nuj nqi los sau thiab khaws cov txiaj ntsig los ntawm sensor sense_data =
sense_data.append (sense.get_temperature ()) sense_data.append (sense.get_pressure ()) sense_data.append (sense.get_humidity ())
kev taw qhia = sense.get_orientation ()
sense_data.append (kev taw qhia ["yaw"]) sense_data.append (kev qhia ["suab"]) sense_data.append (kev taw qhia ["yob"])
acc = sense.get_accelerometer_raw ()
sense_data.append (acc ["x"]) sense_data.append (acc ["y"]) sense_data.append (acc ["z"]) mag = sense.get_compass_raw () sense_data.append (mag ["x"]) sense_data.append (mag ["y"]) sense_data.append (mag ["z"])
gyro = sense.get_gyroscope_raw ()
sense_data.append (gyro ["x"]) sense_data.append (gyro ["y"]) sense_data.append (gyro ["z"])
sense_data.append (datetime.now ())
xa sense_data
nrog qhib ('data.csv', 'w', newline = '') raws li f:
data_writer = kws sau ntawv (f)
data_writer.writerow (['temp', 'pres', 'hum', 'yaw', 'pitch', 'roll', 'acc x', 'acc y', 'acc z', 'mag x', ' mag y ',' mag z ',' gyro x ',' gyro y ',' gyro z ',' datetime '])
thaum Muaj Tseeb:
print (get_sense_data ()) rau qhov xwm txheej hauv sense.stick.get_events (): # Txheeb xyuas yog tias tus joystick raug nias yog event.action == "nias": # Txheeb xyuas qhov kev taw qhia yog event.direction == "nce": # kev nkag siab.show_letter ("U") # Up xub acceleration = sense.get_accelerometer_raw () x = acceleration ['x'] y = acceleration ['y'] z = acceleration ['z'] x = round (x, 0) y = puag ncig (y, 0) z = puag ncig (z, 0)
# Hloov kho qhov kev hloov pauv ntawm cov zaub nyob ntawm seb txoj kev nce yog tias x == -1: sense.set_rotation (90) elif y == 1: sense.set_rotation (270) elif y == -1: sense.set_rotation (180) lwm: sense.set_rotation (0) sense.clear () t = sense.get_temperature () t = round (t, 1) message = "T:" + str (t) sense.show_message (message, text_colour = liab, scroll_speed = 0.09) elif event.direction == "down": acceleration = sense.get_accelerometer_raw () x = acceleration ['x'] y = acceleration ['y'] z = acceleration ['z'] x = round (x, 0) y = round (y, 0) z = round (z, 0)
# Hloov kho qhov kev hloov pauv ntawm cov zaub nyob ntawm seb txoj kev nce yog tias x == -1: sense.set_rotation (90) elif y == 1: sense.set_rotation (270) elif y == -1: sense.set_rotation (180) lwm: sense.set_rotation (0) # sense.show_letter ("D") # Down xub sense.clear () h = sense.get_humidity () h = round (h, 1) message = "H:" + str (h) sense.show_message (message, text_colour = ntsuab, scroll_speed = 0.09) p = sense.get_pressure () p = round (p, 1) message = "P:" + str (p) sense.show_message (lus, text_colour = daj, scroll_speed = 0.09)
# elif event.direction == "sab laug":
#acceleration = sense.get_accelerometer_raw () #x = acceleration ['x'] #y = acceleration ['y'] #z = acceleration ['z'] #x = round (x, 0) #y = puag ncig (y, 0) #z = puag ncig (z, 0)
#Hloov kho qhov kev hloov pauv ntawm cov zaub nyob ntawm seb txoj kev mus rau qhov twg // Tsis siv thiab tswj los ntawm node -liab #if x == -1: sense.set_rotation (90) #elif y == 1: sense.set_rotation (270) #elif y == -1: sense.set_rotation (180) #else: sense.set_rotation (0) # sense.show_letter ("L") # Sab xub xub # elif event.direction == "txoj cai": # sense.show_letter ("K") # Txoj cai xub # elif event.direction == "nruab nrab": # sense.clear ()
cuam tshuam ()
data = tau_sense_data ()
dt = data [-1] - timestamp yog dt.seconds> ncua: data_writer.writerow (cov ntaub ntawv) timestamp = datetime.now ()
Kauj Ruam 18: Saib Xyuas Cov Yees Duab Nyob
Cov Ntawv Cuam Tshuam kuj tseem tuaj yeem siv los saib xyuas cov vis dis aus nyob, vim tias cov vis dis aus tuaj yeem pib txhua lub sijhawm nyob txhua qhov chaw los ntawm MQTT
peb yuav siv VLC player los tso cov vis dis aus, los ntawm qhov tseeb hauv raspbian tshiab VLC tau teeb tsa ua ntej, ntxiv rau nruab vlc raws li hauv qab no
Xav paub ntau ntxiv txog kev saib cov kwj network tuaj yeem nkag tau los ntawm VLC Network kwj
Ua tsaug koj nyeem !!
Muaj ntau ntau qhov cuam tshuam cov kaw suab tuaj yeem ua tau..
Saib xyuas qhov chaw tom ntej rau kev tshuaj xyuas thaj chaw sib nqus hauv kev ua daim phiaj teeb meem
Pom zoo:
HotKeys Keyboard Nrog Cov Ntawv Cuam Tshuam: 14 Cov Kauj Ruam (nrog Duab)
HotKeys Keyboard Nrog Cov Ntawv Cuam Tshuam: Kuv vam tias koj ua tau zoo thaum kis tus kabmob kis no. Nyob Nyab Xeeb. Ua Kom Muaj Zog. #COVID19Being yog tus tsim qauv tsim khoom, Kuv xav tau nkag mus ntau dua 7-8 software uas suav nrog Solidworks, Photoshop, Illustrator, Keyshot, Indesign, thiab lwm yam
RAWS LI COV NTAUB NTAWV NTSEEG NTAWV NTAWV MUAJ NTAWV TSHUAJ NTAWV TSO CAI RAU RASPBERRY PI: 6 Kauj Ruam (nrog Duab)
RAWS LI COV NTAUB NTAWV NTAWV MUAJ NTAWV TSHUAJ NTXIV RAU RASPBERRY PI: Hauv qhov haujlwm no, peb yuav txuas peb ntawm Atlas Scientific's EZO sensors (pH, yaj cov pa thiab kub) mus rau Raspberry Pi 3B+. Hloov chaw ntawm txuas cov kab hluav taws xob mus rau Raspberry Pi, peb yuav siv Whitebox Labs Tentacle T3 daim ntaub thaiv. T
Luam Tawm Cov Ntawv Cuam Tshuam - Ua tiav Cov Txheej Txheem: 14 Cov Kauj Ruam (nrog Duab)
Luam Tawm Cov Ntawv Cuam Tshuam - Ua tiav Cov Txheej Txheem: Cov hauv qab no piav qhia cov txheej txheem uas kuv tsim PC lub rooj tsav xwm hauv PC rau ib zaug thiab ua qauv siv. Nws tau sau rau tus neeg uas tau tsim lawv tus kheej cov laug cam yav dhau los thiab tau paub txog cov txheej txheem dav dav. Txhua qhov ntawm kuv cov kauj ruam yuav tsis ua haujlwm
Yuav Ua Li Cas Tsheb Tsheb RC Los Ntawm Cov Duab Duab thiab Ntawv Ntawv: 9 Kauj Ruam (nrog Duab)
Yuav Ua Li Cas RC Tsheb Log Los Ntawm Cardboard thiab Kraft Paper: RC log yog qhov tseem ceeb rau txhua lub tsheb RC. Muaj ntau ntau pawg thiab hom RC log thiab tau txais txoj kev xaiv lub log yog ib qho tseem ceeb tshaj plaws thaum cuam tshuam nrog cov tsheb no. Thaum kuv pib DIYing RC tsheb, ib qho ntawm cov maj
Tus Cuam Tshuam Cuam Tshuam (ntsuas phoo Cam Cuam Tshuam Cuam Tshuam): 4 Cov Kauj Ruam
Solder Saver (txhav tas Cam Cuam Tshuam Cuam Tshuam): "Yuav ua li cas kuv thiaj yuav tsum qhia ua ntej Cov Lus Qhia no?" Kuv nug kuv tus kheej. Zoo li, txij li thaum pib ntawm lub sijhawm, tus txiv neej muaj qhov xav kom lo lo rau hauv tus cwj mem thiab tshaj tawm cov duab online. Zoo, Kuv tau txiav txim siab luv luv delving rau hauv keeb kwm loj dua ntawm tus cwj mem yaj, b