Cov txheej txheem:
- Kauj Ruam 1: Yam Koj Xav Tau..
- Kauj Ruam 2: Kev Sib Txuas:
- Kauj ruam 3: Code:
- Kauj Ruam 4: Cov ntawv thov:
Video: Raspberry Pi - ADXL345 3 -Axis Accelerometer Python Qhia: 4 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:24
ADXL345 yog qhov me me, nyias, lub zog loj, 3-axis accelerometer nrog kev ntsuas siab (13-ntsis) ntsuas txog li g 16 g. Cov ntaub ntawv tso tawm digital yog ua raws li 16-ntsis twos ua tiav thiab siv tau los ntawm I2 C digital interface. Nws ntsuas qhov kev nrawm nrawm ntawm lub ntiajteb txawj nqus hauv kev thov qaij-nkag siab, nrog rau kev nrawm nrawm los ntawm kev txav lossis poob siab. Nws qhov kev daws teeb meem siab (3.9 mg/LSB) ua rau ntsuas ntsuas qhov xav tau hloov qis dua 1.0 °. Nov yog nws ua qauv qhia nrog raspberry pi siv tus lej nab npawb.
Kauj Ruam 1: Yam Koj Xav Tau..
1. Raspberry Pi
2. ADXL345
3. I²C Cable
4. I²C Shield rau Raspberry Pi
5. Ethernet Cable
Kauj Ruam 2: Kev Sib Txuas:
Siv daim I2C daim thaiv rau raspberry pi thiab maj mam thawb nws hla gpio pins ntawm raspberry pi.
Tom qab ntawd txuas ib kawg ntawm I2C cable rau ADXL345 sensor thiab lwm qhov kawg rau I2C daim ntaub thaiv.
Kuj txuas Ethernet cable rau pi lossis koj tuaj yeem siv WiFi module.
Kev sib txuas tau qhia hauv daim duab saum toj no.
Kauj ruam 3: Code:
Tus nab npawb nab npawb rau ADXL345 tuaj yeem rub tawm los ntawm peb GitHub chaw cia khoom- Dcube Store
Nov yog qhov txuas rau tib yam:
github.com/DcubeTechVentures/ADXL345..
Peb tau siv SMBus lub tsev qiv ntawv rau sej code, cov kauj ruam rau nruab SMBus ntawm raspberry pi tau piav qhia ntawm no:
pypi.python.org/pypi/smbus-cffi/0.5.1
Koj tseem tuaj yeem luam cov cai los ntawm no, nws tau muab raws li hauv qab no:
# Faib nrog daim ntawv tso cai yuav dawb.
# Siv nws txhua txoj hauv kev uas koj xav tau, muaj txiaj ntsig lossis pub dawb, muab nws haum rau hauv daim ntawv tso cai ntawm nws cov haujlwm sib txuam.
# ADXL345
# Txoj cai no yog tsim los ua haujlwm nrog ADXL345_I2CS I2C Mini Module muaj nyob hauv Dcube Store.
ntshuam smbus
lub sij hawm ntshuam
# Tau I2C npav
npav = smbus. SMBus (1)
# ADXL345 chaw nyob, 0x53 (83)
# Xaiv tus lej bandwidth rau npe, 0x2C (44)# 0x0A (10) Hom ib txwm, Cov ntaub ntawv tawm tus nqi = 100 Hz
bus.write_byte_data (0x53, 0x2C, 0x0A)
# ADXL345 chaw nyob, 0x53 (83)
# Xaiv lub zog tswj npe, 0x2D (45)
# 0x08 (08) Pib Pw tsaug zog
bus.write_byte_data (0x53, 0x2D, 0x08)
# ADXL345 chaw nyob, 0x53 (83)
# Xaiv cov ntaub ntawv sau npe, 0x31 (49)
# 0x08 (08) Kev sim tus kheej tsis taus, 4-xaim interface
# Kev daws teeb meem tag nrho, Range = +/- 2g
bus.write_byte_data (0x53, 0x31, 0x08)
sijhawm.s pw (0.5)
# ADXL345 chaw nyob, 0x53 (83)
# Nyeem cov ntaub ntawv rov qab los ntawm 0x32 (50), 2 bytes
# X-Axis LSB, X-Axis MSB
data0 = npav.read_byte_data (0x53, 0x32)
data1 = npav.read_byte_data (0x53, 0x33)
# Hloov cov ntaub ntawv mus rau 10-ntsis
xAccl = ((data1 & 0x03) * 256) + data0
Yog tias xAccl> 511:
xAccl -= 1024
# ADXL345 chaw nyob, 0x53 (83)
# Nyeem cov ntaub ntawv rov qab los ntawm 0x34 (52), 2 bytes
# Y-Axis LSB, Y-Axis MSB
data0 = npav.read_byte_data (0x53, 0x34)
data1 = npav.read_byte_data (0x53, 0x35)
# Hloov cov ntaub ntawv mus rau 10-ntsis
yAccl = ((data1 & 0x03) * 256) + data0
Yog tias yAccl> 511:
yAccl -= 1024
# ADXL345 chaw nyob, 0x53 (83)
# Nyeem cov ntaub ntawv rov qab los ntawm 0x36 (54), 2 bytes
# Z-Axis LSB, Z-Axis MSB
data0 = npav.read_byte_data (0x53, 0x36)
data1 = npav.read_byte_data (0x53, 0x37)
# Hloov cov ntaub ntawv mus rau 10-ntsis
zAccl = ((data1 & 0x03) * 256) + data0
yog zAccl> 511:
zAccl -= 1024
# 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
Kauj Ruam 4: Cov ntawv thov:
ADXL345 yog qhov me me, nyias, lub zog loj, 3-axis accelerometer uas tuaj yeem ua haujlwm hauv Tes, Cov cuab yeej siv kho mob thiab lwm yam.
Pom zoo:
Cov Lus Qhia Qhia: 3 Kauj Ruam
Cov Lus Qhia Ua Ntej: Xijpeem koj ua haujlwm, nws taug kev, taug kev, caij tsheb kauj vab lossis txawm tias tsav tsheb, koj tuaj yeem sau cov kev uas koj taug. Tom qab ntawd koj tuaj yeem faib cov kev no nrog phooj ywg thiab tsev neeg. Ib qho ntxiv, koj tuaj yeem siv txoj hauv kev kaw tseg los ntxiv qhov chaw rau txhua daim duab uas koj tuaj yeem h
LED Qhov Taw Qhia Qhov Taw Qhia Tus Menyuam: 5 Kauj Ruam (nrog Duab)
LED Qhov Taw Qhia Qhov Taw Qhia Tus dev: Kuv ib txwm coj kuv tus dev Rusio mus taug kev thaum lub hnub poob qis kom nws tuaj yeem ua si yam tsis tau kub heev. Qhov teeb meem yog tias thaum nws tawm ntawm txoj hlua qee zaum nws tau zoo siab heev thiab ua haujlwm ntau dua li nws yuav tsum thiab nrog lub teeb qis thiab lwm tus dev
Lub Hom Phiaj Taw Qhia: Tsim Lub Hom Phiaj Kawm/Qhia Txoj Kev/Cov Txheej Txheem Siv Cov Duab Puncher: 5 Kauj Ruam
Lub Hom Phiaj Taw Qhia: Tsim Lub Hom Phiaj Kawm/Qhia Txoj Kev/Cov Qauv Siv Cov Duab Puncher: Kawm/qhia txoj hauv kev rau cov tub ntxhais kawm tshiab rau kev tsom mus rau lub hom phiaj. Nov yog txoj hauv kev tso cai rau lawv kom pom kev thiab pom cov txheej txheem ntawm kev tsim cov khoom los ntawm cov chav kawm. EkTools 2-nti loj punch; cov duab zoo tshaj plaws. 2. Daim ntawv los yog c
Kuv Me Me Whoop: Daim Ntawv Qhia Whoop + Cov Lus Qhia thiab Cov Lus Qhia: 8 Kauj Ruam
Kuv Me Me Whoop: Daim Ntawv Qhia Whoop + Cov Lus Qhia thiab Cov Lus Qhia: Kev Ceeb Toom: Tam sim no koj tab tom nkag mus rau kuv thawj qhov kev qhia, thiab koj yuav ntsib ntau yam kev ruam thiab tsis muaj phiaj xwm thiab/lossis txuj ci. Paub txog qhov no yog kuv tus kheej Tiny Whoop teeb tsa uas kuv siv txhua hnub, yog li kuv xav tias kuv yuav qhia nws. Nws yog phooj ywg mus ncig (tsis muaj
Yuav Ua Li Cas Ua Tus Qhia Qhia thiab Qhia: 8 Kauj Ruam
Yuav Ua Li Cas Nthuav Qhia Qhia thiab Qhia: Nov yog phau ntawv qhia rau kev ua Qhia Qhia thiab Qhia. Nws yog qhov tseem ceeb tshaj plaws ntawm cov xwm txheej muaj nyob rau Hnub Friday, Peb Hlis 9, 2007, tab sis kuj tseem yog qhov tshwm sim yav dhau los ntawm qhov xwm txheej no, Squid Labs Lub Teeb Pom Kev Zoo. Lub hom phiaj ntawm Kev Qhia thiab Xov Tooj