Cov txheej txheem:
- Kauj Ruam 1: Yuav Tsum Kho Vajtse:
- Kauj ruam 2: Khoos phis tawj sib txuas:
- Kauj Ruam 3: Python Code rau Kev Ntsuas Kev Ntsuas:
- Kauj Ruam 4: Cov ntawv thov:
Video: Kev Ntsuas Kev Siv H3LIS331DL thiab Raspberry Pi: 4 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
H3LIS331DL, yog lub zog qis ua tau zoo 3-axis linear accelerometer koom nrog "nano" tsev neeg, nrog digital I²C cov lej sib txuas. H3LIS331DL muaj cov neeg siv xaiv tau cov nplai ntawm g 100g/± 200g/± 400g thiab nws muaj peev xwm ntsuas qhov nrawm nrog cov ntaub ntawv tso tawm tus nqi los ntawm 0.5 Hz txog 1 kHz. H3LIS331DL tau lees tias ua haujlwm dhau qhov ntsuas kub ntev los ntawm -40 ° C txog +85 ° C.
Hauv qhov kev qhia no peb yuav los qhia txog kev cuam tshuam ntawm H3LIS331DL nrog Raspberry Pi, siv nab hab sej ua cov lus programming.
Kauj Ruam 1: Yuav Tsum Kho Vajtse:
Cov ntaub ntawv uas peb xav tau kom ua tiav peb lub hom phiaj suav nrog cov khoom siv hauv qab no:
1. H3LIS331DL
2. Raspberry Pi
3. I2C Cable
4. I2C Shield rau raspberry pi
5. Ethernet Cable
Kauj ruam 2: Khoos phis tawj sib txuas:
Tshooj khoos phis tawj sib txuas ntu piav qhia qhov txuas txuas uas xav tau ntawm lub ntsuas cua thiab raspberry pi. Ua kom muaj kev sib txuas raug yog qhov tseem ceeb xav tau thaum ua haujlwm ntawm ib qho system rau qhov xav tau cov zis. Yog li, qhov xav tau kev sib txuas yog raws li hauv qab no:
H3LIS331DL yuav ua haujlwm dhau I2C. Nov yog qhov piv txwv kab hluav taws xob daim duab, qhia txog yuav ua li cas xaim txhua lub interface ntawm lub sensor.
Tawm-ntawm-lub thawv, lub rooj tsavxwm tau teeb tsa rau I2C interface, zoo li peb pom zoo siv qhov kev sib txuas no yog tias koj tsis ntseeg lwm yam. Txhua yam koj xav tau yog plaub lub xov hlau!
Tsuas yog plaub qhov kev sib txuas xav tau Vcc, Gnd, SCL thiab SDA tus pin thiab cov no txuas nrog kev pab ntawm I2C cable.
Cov kev sib txuas no tau qhia hauv cov duab saum toj no.
Kauj Ruam 3: Python Code rau Kev Ntsuas Kev Ntsuas:
nws qhov txiaj ntsig ntawm kev siv raspberry pi yog, uas yog muab rau koj qhov kev hloov pauv ntawm cov lus programming uas koj xav kom ua haujlwm rau lub rooj tsav xwm txhawm rau cuam tshuam lub sensor nrog nws. Kev siv cov txiaj ntsig zoo ntawm pawg thawj coj no, peb tab tom qhia ntawm no nws cov phiaj xwm hauv nab hab sej. Nab hab sej yog ib qho ntawm cov lus yooj yim programming nrog cov lus yooj yim tshaj plaws. Tus nab npawb nab npawb rau H3LIS331DL tuaj yeem rub tawm los ntawm peb lub zej zog github uas yog DCUBE Store.
Ntxiv rau qhov yooj yim ntawm cov neeg siv, peb tab tom piav qhia cov cai ntawm no thiab:
Raws li thawj kauj ruam ntawm kev sau koj yuav tsum rub lub SMBus lub tsev qiv ntawv thaum muaj nab nab, vim tias lub tsev qiv ntawv no txhawb nqa cov haujlwm uas siv hauv txoj cai. Yog li, txhawm rau rub lub tsev qiv ntawv koj tuaj yeem mus ntsib qhov txuas hauv qab no:
pypi.python.org/pypi/smbus-cffi/0.5.1
Koj tuaj yeem luam cov cai ua haujlwm los ntawm no kuj:
ntshuam smbus
lub sij hawm ntshuam
# Tau I2C busbus = smbus. SMBus (1)
# H3LIS331DL chaw nyob, 0x18 (24)
# Xaiv tswj npe 1, 0x20 (32)
# 0x27 (39) Hwj chim ON hom, Cov ntaub ntawv tawm tus nqi = 50 Hz# X, Y, Z-Axis qhib
bus.write_byte_data (0x18, 0x20, 0x27)
# H3LIS331DL chaw nyob, 0x18 (24)# Xaiv tswj npe 4, 0x23 (35)
# 0x00 (00) Hloov kho tas li, Kev ntsuas tag nrho = +/- 100g
bus.write_byte_data (0x18, 0x23, 0x00)
sijhawm.s pw (0.5)
# H3LIS331DL chaw nyob, 0x18 (24)
# Nyeem cov ntaub ntawv rov qab los ntawm 0x28 (40), 2 bytes
# X-Axis LSB, X-Axis MSB
data0 = npav.read_byte_data (0x18, 0x28)
data1 = npav.read_byte_data (0x18, 0x29)
# Hloov cov dataxAccl = data1 * 256 + data0
Yog tias xAccl> 32767:
xAccl -= 65536
# H3LIS331DL chaw nyob, 0x18 (24)
# Nyeem cov ntaub ntawv rov qab los ntawm 0x2A (42), 2 bytes
# Y-Axis LSB, Y-Axis MSB
data0 = npav.read_byte_data (0x18, 0x2A)
data1 = bus.read_byte_data (0x18, 0x2B)
# Hloov cov ntaub ntawv
yAccl = data1 * 256 + data0
Yog tias yAccl> 32767:
yAccl -= 65536
# H3LIS331DL chaw nyob, 0x18 (24)
# Nyeem cov ntaub ntawv rov qab los ntawm 0x2C (44), 2 bytes
# Z-Axis LSB, Z-Axis MSB
data0 = bus.read_byte_data (0x18, 0x2C)
data1 = bus.read_byte_data (0x18, 0x2D)
# Hloov cov ntaub ntawv
zAccl = data1 * 256 + data0
yog zAccl> 32767:
zAccl -= 65536
# Cov ntaub ntawv tso tawm rau lub vijtsam
luam "Kev nrawm hauv X-Axis: %d" %xAccl
luam "Kev nrawm hauv Y-Axis: %d" %yAccl
luam "Kev nrawm hauv Z-Axis: %d" %zAccl
Txoj cai tau ua tiav siv cov lus txib hauv qab no:
$> nab hab sej H3LIS331DL.py gt; nab hab sej H3LIS331DL.py
Cov zis ntawm lub ntsuas tau pom hauv daim duab saum toj no rau kev siv ntawm tus neeg siv.
Kauj Ruam 4: Cov ntawv thov:
Accelerometers zoo li H3LIS331DL feem ntau pom nws daim ntawv thov hauv kev ua si thiab tso saib qhov hloov pauv profile. Qhov ntsuas qhov ntsuas no tseem ua haujlwm hauv kev tswj hwm lub zog zoo rau kev siv mobile. H3LIS331DL yog triaxial digital acceleration sensor uas tau suav nrog lub ntse ntawm-nti cov lus tsa suab cuam tshuam kev tswj hwm.
Pom zoo:
Kev Ntsuas thiab Kev Ntsuas Kub Siv HIH6130 thiab Arduino Nano: 4 Cov Kauj Ruam
Kev Ntsuas thiab Kev Ntsuas Kub Siv HIH6130 thiab Arduino Nano: HIH6130 yog qhov ntsuas cua thiab ntsuas kub nrog cov zis digital. Cov ntsuas no muab qib raug ntawm ± 4% RH. Nrog kev lag luam-ua kom muaj kev ruaj ntseg mus sij hawm ntev, qhov tseeb kub-them nyiaj digital I2C, Kev lag luam ua rau muaj kev ntseeg siab, Kev siv hluav taws xob
Kev Ntsuas thiab Kev Ntsuas Kub Siv HTS221 thiab Arduino Nano: 4 Cov Kauj Ruam
Kev Ntsuas thiab Kev Ntsuas Kub Siv HTS221 thiab Arduino Nano: HTS221 yog lub ntsuas hluav taws xob me me uas muaj peev xwm ntsuas tau rau qhov txheeb ze thiab qhov kub thiab txias. Nws suav nrog lub hauv paus ntsiab lus thiab cov teeb liab sib xyaw daim ntawv thov tshwj xeeb kev sib txuas (ASIC) los muab cov ntaub ntawv ntsuas los ntawm cov lej
Kev Ntsuas thiab Kev Ntsuas Kub Siv HTS221 thiab Raspberry Pi: 4 Cov Kauj Ruam
Kev Ntsuas thiab Kev Ntsuas Kub Siv HTS221 thiab Raspberry Pi: HTS221 yog lub ntsuas hluav taws xob me me uas muaj peev xwm ntsuas tau rau qhov txheeb ze thiab qhov kub thiab txias. Nws suav nrog lub hauv paus ntsiab lus thiab cov teeb liab sib xyaw daim ntawv thov tshwj xeeb kev sib txuas (ASIC) los muab cov ntaub ntawv ntsuas los ntawm cov lej
Kev Ntsuas thiab Kev Ntsuas Kub Siv HIH6130 thiab Raspberry Pi: 4 Kauj Ruam
Kev Ntsuas Cov Ntsuas thiab Kub Siv HIH6130 thiab Raspberry Pi: HIH6130 yog qhov ntsuas cua thiab ntsuas kub nrog cov zis digital. Cov ntsuas no muab qib raug ntawm ± 4% RH. Nrog kev lag luam-ua kom muaj kev ruaj ntseg mus sij hawm ntev, qhov tseeb kub-them nyiaj digital I2C, Kev lag luam ua rau muaj kev ntseeg siab, Kev siv hluav taws xob
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: 6 Kauj Ruam
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: Cov lus qhia no piav qhia yuav ua li cas thiaj tsim tau Arduino Robot uas tuaj yeem txav mus raws qhov xav tau (Forward, Backward) , Sab laug, Txoj Cai, Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) xav tau Kev nrug deb hauv Centimeters siv lub suab hais kom ua. Neeg hlau kuj tseem tuaj yeem txav tau tus kheej