Cov txheej txheem:
- Khoom siv
- Kauj Ruam 1: Ua kom lub Circuit thiab Pi
- Kauj Ruam 2: MPU6050
- Kauj Ruam 3: Adafruit Ultimate Breakout GPS
- Kauj Ruam 4: 16x2 LCD
- Kauj Ruam 5: Servo, Leds, Khawm thiab Hloov
- Kauj Ruam 6: Tag Nrho Circuit
- Kauj Ruam 7: Txoj Cai
- Kauj Ruam 8: Cov Ntaub Ntawv
- Kauj Ruam 9: Rooj plaub
Video: Taug qab & taug qab rau Cov Khw Me Me: 9 Kauj Ruam (nrog Duab)
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
Qhov no yog cov txheej txheem uas tau tsim rau cov khw me uas xav tias yuav nce mus rau e-tsheb kauj vab lossis e-scooters rau kev xa khoom luv luv, piv txwv li cov mov ci uas xav xa cov ncuav qab zib.
Track thiab Trace txhais li cas?
Taug qab thiab taug qab yog cov kab ke siv los ntawm cov neeg nqa khoom lossis cov tuam txhab xa ntawv los sau cov kev txav chaw ntawm cov pob lossis cov khoom thaum thauj mus los. Ntawm txhua qhov chaw ua haujlwm, cov khoom raug txheeb xyuas thiab xa cov ntaub ntawv mus rau lub hauv paus txheej txheem. Cov ntaub ntawv no yog siv los muab xwm txheej/hloov tshiab ntawm cov khoom lag luam rau cov neeg xa khoom.
Cov kab ke peb yuav ua kuj tseem yuav qhia txoj hauv kev tau txais thiab cov nyiaj poob haujlwm thiab pob tau txais.
nco tseg: qhov no tau ua rau tsev kawm ntawv txoj haujlwm, yog li vim lub sijhawm txwv muaj ntau chav rau kev txhim kho
Khoom siv
-Raspberry Pi 4 qauv B.
-Raspberry PI T-cobbler
-4x 3, 7V Li-ion roj teeb
-2x ob lub roj teeb tuav
-DC Buck Step-down Converter 5v
-2x loj txiv kab ntxwv coj
-on/off/on switch
-khawm
-adafruit qhov kawg gps v3
ua 6050
-16x2 lcd zaub
-servo tsav
Kauj Ruam 1: Ua kom lub Circuit thiab Pi
Thaum nws los txog rau lub zog hluav taws xob pi nrog lub roj teeb koj muaj ob peb txoj kev xaiv yuav ua li cas.
Koj tuaj yeem siv lub txhab nyiaj hluav taws xob thiab lub zog pi ntawm USB, tej zaum koj tau teeb tsa lub cuab yeej ntawm e-tsheb tuam lossis e-scooter uas muaj USB chaw nres nkoj, tej zaum koj muaj 5V lub xov tooj roj teeb nyob ib puag ncig tos kom siv lossis koj tuaj yeem siv 2 teeb tsa ntawm 3.7V roj teeb nyob rau hauv ua ke nrog cov kauj ruam nqis hloov pauv zoo li qhia hauv cov duab
Txhua yam zoo yog tias nws tuaj yeem muab txuas ntxiv 5V thiab muaj lub neej uas koj zoo siab nrog.
Kauj Ruam 2: MPU6050
Taw qhia MPU6050 sensor module yog kev koom ua ke 6-axis Motion tracking device.
- Nws muaj 3-axis Gyroscope, 3-axis Accelerometer, Digital Motion Processor thiab ntsuas kub, txhua yam hauv ib qho IC.
- Ntau yam tsis tuaj yeem pom los ntawm kev nyeem qhov tseem ceeb los ntawm chaw nyob ntawm qee qhov kev sau npe siv I2C kev sib txuas lus. Gyroscope thiab ntsuas kev ntsuas nrawm raws X, Y thiab Z txoj kab muaj nyob hauv 2 daim ntawv ntxiv.
- Gyroscope nyeem yog nyob rau qib ib ob (dps) chav; Accelerometer nyeem ntawv yog nyob rau hauv g chav.
Pab kom I2C
Thaum siv MPU6050 nrog Raspberry Pi, peb yuav tsum ua kom ntseeg tau tias I2C raws tu qauv ntawm Raspberry Pi tau qhib. Ua li no qhib lub pi lub davhlau ya nyob twg los ntawm putty lossis lwm yam softaware thiab ua cov hauv qab no:
- ntaus hauv "sudo raspi-config"
- Xaiv Configurations Interfacing
- Hauv kev xaiv cuam tshuam, Xaiv "I2C"
- Pab kom I2C teeb tsa
- Xaiv Yog thaum nws thov kom Reboot.
Tam sim no, peb tuaj yeem sim/tshuaj xyuas rau ib qho khoom siv I2C txuas nrog peb pawg Raspberry Pi los ntawm kev txhim kho cov cuab yeej i2c. Peb tuaj yeem tau txais cov cuab yeej i2c los ntawm kev siv apt pob tus thawj tswj hwm. Siv cov lus txib hauv qab no hauv Raspberry Pi davhlau ya nyob twg.
"sudo apt-tau nruab -y i2c-cuab yeej"
Tam sim no txuas ib qho I2C raws cov cuab yeej rau tus neeg siv-hom chaw nres nkoj thiab luam theej duab qhov chaw nres nkoj siv cov lus txib hauv qab no, "sudo i2cdetect -y 1"
Tom qab ntawd nws yuav teb nrog chaw nyob ntaus ntawv.
Yog tias tsis muaj chaw nyob raug xa rov qab kom paub tseeb tias MPU6050 tau txuas nrog kom raug thiab sim dua
Ua kom nws ua haujlwm
tam sim no peb paub tseeb tias i2c tau qhib thiab pi tuaj yeem ncav cuag MPU6050 peb tab tom yuav teeb tsa lub tsev qiv ntawv siv "sudo pip3 install adafruit-circuitpython-mpu6050" hais kom ua.
yog tias peb ua cov ntaub ntawv xeem nab thiab siv cov cai hauv qab no peb tuaj yeem pom tias nws ua haujlwm li cas:
lub sij hawm ntshuam
pawg thawj coj saib ntshuam
ntshuam busi
oimport adafruit_mpu6050
i2c = busio. I2C (board. SCL, board. SDA)
mpu = adafruit_mpu6050. MPU6050 (i2c)
thaum Muaj Tseeb:
print ("Kev nrawm: X: %. 2f, Y: %.2f, Z: %.2f m/s^2" %(mpu.acceleration))
print ("Gyro X: %. 2f, Y: %.2f, Z: %.2f degrees/s" %(mpu.gyro))
luam tawm ("Kub: %.2f C" % mpu.temperature)
luam tawm ("")
sijhawm.sleep (1)
thaum peb tam sim no xav tau nrawm hauv X/Y/Z-axis peb tuaj yeem siv cov hauv qab no:
accelX = mpu.acceleration [0] accelY = mpu.acceleration [1] accelZ = mpu.acceleration [2]
sib txuas qhov no nrog qhov yooj yim yog cov lus hais hauv lub voj tas li peb tuaj yeem suav qhov kev poob siab ntawm kev mus
Kauj Ruam 3: Adafruit Ultimate Breakout GPS
Taw qhia
Kev tawg tawm tau tsim nyob ib puag ncig MTK3339 chipset, tsis muaj qhov tsis zoo, qhov ua tau zoo GPS uas tuaj yeem taug qab txog 22 lub hnub qub ntawm 66 raws, muaj qhov ua tau zoo tshaj-siab txais (-165 dB taug qab!), Thiab ua hauv kav hlau txais xov. Nws tuaj yeem ua txog 10 qhov chaw hloov tshiab thib ob rau kev kub ceev, nkag siab nkag siab lossis nkag mus. Kev siv fais fab yog qhov tsawg kawg nkaus, tsuas yog 20 mA thaum lub sijhawm qhia.
Lub Rooj Tswjhwm Saib los nrog: qhov qis tshaj tawm 3.3V tus tswj hwm yog li koj tuaj yeem siv nws nrog 3.3-5VDC hauv, 5V qib kev nyab xeeb nkag mus, Lub LED ntsais li ntawm 1Hz thaum nws tab tom nrhiav rau lub hnub qub thiab ntsais muag ib zaug txhua 15 vib nas this thaum txhim kho pom kom txuag lub zog.
Kuaj gps nrog arduino
Yog tias koj tau nkag mus rau arduino nws yog lub tswv yim zoo los ntsuas qhov qauv nrog nws.
Txuas VIN rau +5VC txuas GND rau GroundConnect GPS RX (cov ntaub ntawv rau hauv GPS) rau Digital 0Connect GPS TX (cov ntaub ntawv tawm ntawm GPS) rau Digital 1
Cias khiav tus lej arduino dawb paug thiab qhib qhov ntsuas ntawm 9600 baud. Yog tias koj tau txais cov ntaub ntawv gps koj li gps module ua haujlwm.
Ua kom nws ua haujlwm
Pib txhim kho lub tsev qiv ntawv adafruit gps siv "sudo pip3 nruab adafruit-circuitpython-gps" hais kom ua.
Tam sim no peb tuaj yeem siv tus lej nab npawb hauv qab no los saib seb peb puas tuaj yeem ua haujlwm tau:
ntshuam lub sij hawm ntshuam pawg thawj coj saib busioimport adafruit_gpsimport serial uart = serial. Serial ("/dev/ttyS0", baudrate = 9600, timeout = 10)
gps = adafruit_gps. GPS (uart, debug = False) gps.send_command (b'PMTK314, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ') gps.send_command (b'PMTK220, 1000')
thaum Muaj Tseeb:
gps.update () thaum tsis gps.has_fix:
print (gps.nmea_sentence) print ('Tos rau kho …') gps.update () time.sleep (1) txuas ntxiv
print ('=' * 40) # Luam kab sib cais.print ('Latitude: {0:.6f} degrees'.format (gps.latitude)) print (' Longitude: {0:.6f} degrees'.format (gps.longitude)) print ("Kho kom zoo: {}". hom ntawv (gps.fix_quality))
# Qee tus cwj pwm dhau qhov latitude, longitude thiab timestamp yog xaiv tau# thiab yuav tsis muaj tam sim no. Txheeb xyuas yog tias lawv tsis muaj ua ntej sim siv! Yog gps.satellites tsis yog Tsis muaj:
print ("# satellites: {}". hom ntawv (gps.satellites))
yog tias gps.altitude_m tsis yog Tsis muaj:
print ("Qhov siab: {} meters".format (gps.altitude_m))
yog tias gps.speed_knots tsis yog Tsis muaj:
print ("Ceev: {} pob".format (gps.speed_knots))
yog gps.track_angle_deg tsis yog Tsis muaj:
print ("Lub kaum sab xis: {} degrees".format (gps.track_angle_deg))
yog gps.horizontal_dilution tsis yog Tsis muaj:
print ("Kab rov tav dilution: {}". hom ntawv (gps.horizontal_dilution))
yog gps.height_geoid tsis yog Tsis muaj:
print ("Qhov siab geo ID: {} meters".format (gps.height_geoid))
sijhawm.sleep (1)
Kauj Ruam 4: 16x2 LCD
Taw qhia
LCD cov qauv siv feem ntau siv hauv cov phiaj xwm ntau ntxiv, yog vim li cas nws thiaj li pheej yig tus nqi, muaj thiab muaj programmer tus phooj ywg. Peb txhua tus yuav tau hla cov lus no hauv peb lub neej niaj hnub, xws li ntawm PCO lossis lub laij lej. 16 × 2 LCD yog lub npe vim li ntawd; nws muaj 16 Kab thiab 2 Kab. Muaj ntau qhov kev sib txuas ua ke muaj xws li, 8 × 1, 8 × 2, 10 × 2, 16 × 1, thiab lwm yam. Tab sis feem ntau siv ib qho yog 16 × 2 LCD. Yog li, nws yuav muaj (16 × 2 = 32) 32 cim hauv tag nrho thiab txhua tus cim yuav ua los ntawm 5 × 8 Pixel Dots.
Txhim kho smbus
Kev Tswj Tsheb Npav (SMBus) ntau dua lossis tsawg dua los ntawm I2C npav. Tus txheej txheem tau tsim los ntawm Intel thiab tam sim no tau tswj hwm los ntawm SBS Rooj Sib Tham. Qhov kev thov tseem ceeb ntawm SMBus yog los tshuaj xyuas qhov tsis tseem ceeb ntawm PC motherboards thiab hauv cov kab ke. Piv txwv li muaj ntau qhov kev ntsuas hluav taws xob ntsuas, ntsuas kub, thiab kiv cua saib/tswj ICs nrog SMBus interface muaj.
Lub tsev qiv ntawv peb yuav siv xav tau smbus txhawm rau txhawm rau txhawm rau txhawm rau txhim kho smbus ntawm rpi siv "sudo apt install python3-smbus" hais kom ua.
Ua kom nws ua haujlwm
ua ntej ntawm nruab RPLCD lub tsev qiv ntawv siv "sudo pip3 install RPLCD" hais kom ua.
tam sim no peb sim lcd los ntawm kev qhia tus IP siv cov cai hauv qab no:
los ntawm RPLCD.i2c ntshuam CharLCDimport qhov (socket)
def tau_ip_address ():
ip_address = 's = socket.socket (socket. AF_INET, socket. SOCK_DGRAM) s.connect (("8.8.8.8", 80)) ip_address = s.getsockname () [0] s.close () rov ip_address
lcd = CharLCD ('PCF8574', 0x27)
lcd.write_string ('IP chaw nyob: / r / n'+str (get_ip_address ()))
Kauj Ruam 5: Servo, Leds, Khawm thiab Hloov
Taw qhia
Lub cav servo yog lub tshuab ua teb lossis lub cav uas tso cai rau kev tswj hwm qhov tseeb ntawm txoj haujlwm kaum, nrawm thiab nrawm, muaj peev xwm uas lub cev muaj zog ib txwm tsis muaj. Nws ua rau siv lub cev muaj zog ib txwm muaj thiab ua ke nrog lub sensor rau txoj haujlwm tawm tswv yim. Tus maub los yog qhov ntse tshaj plaws ntawm servo motor, raws li nws tau tsim tshwj xeeb rau lub hom phiaj.
LED luv rau lub teeb-emitting diode. Cov cuab yeej hluav taws xob semiconductor uas tso tawm lub teeb thaum hluav taws xob tam sim no hla nws. Lawv muaj txiaj ntsig ntau dua li cov teeb roj teeb, thiab tsis tshua muaj hlawv. LEDs tau siv nyob rau hauv ntau daim ntawv thov xws li lub tiaj-npo cov vis dis aus tso tawm, thiab nce ntxiv raws li qhov chaw pom kev ntawm lub teeb.
Lub laub-khawm lossis khawm yooj yim yog lub tshuab hloov pauv yooj yim los tswj qee yam ntawm lub tshuab lossis txheej txheem. Cov nyees khawm feem ntau yog ua los ntawm cov khoom tawv, feem ntau yog yas lossis hlau.
Ib qho ntawm/tawm/ntawm qhov hloov pauv muaj 3 txoj haujlwm nyob qhov twg ib nrab yog lub xeev tawm cov hom no feem ntau yog siv rau kev tswj lub cev yooj yim uas koj muaj rau pem hauv ntej, tawm thiab rov qab lub xeev.
Ua kom nws ua haujlwm: servo
Qhov kev pabcuam siv PWM teeb liab los txiav txim seb lub kaum ntse ntse nws yuav tsum yog qhov zoo rau peb GPIO muaj cov yam ntxwv no ua hauv. Yog li ntawd peb tuaj yeem yooj yim siv cov cai hauv qab no los tswj cov servo: ntshuam RPi. GPIO li GPIOimport lub sijhawm
servo_pin = 18duty_cycle = 7.5
GPIO.setmode (GPIO. BCM)
GPIO.setup (servo_pin, GPIO. OUT)
pwm_servo = GPIO. PWM (servo_pin, 50) pwm_servo.start (duty_cycle)
thaum Muaj Tseeb:
duty_cycle = float (input ("Enter Duty Cycle (Left = 5 to Right = 10):")) pwm_servo. ChangeDutyCycle (duty_cycle)
Ua kom nws ua haujlwm: coj thiab hloov
Vim yog txoj kev uas peb xaim tus coj thiab hloov peb tsis tas yuav tswj lossis nyeem cov leds thiab hloov nws tus kheej. Peb tsuas yog xa cov mem tes mus rau lub khawm dab yuav tig txoj hauv kev rau lub teeb uas peb xav tau.
Ua kom nws ua haujlwm: khawm
Rau khawm peb yuav tsum ua peb tus kheej chav kawm yooj yim li no peb pom yooj yim thaum nws nias yam tsis tas yuav ntxiv qhov xwm txheej pom rau nws txhua lub sijhawm peb siv nws.we yuav ua cov ntawv classbutton.py siv cov cai hauv qab no:
los ntawm RPi ntshuam GPIOclass Khawm:
def _init _ (self, pin, bouncetime = 200): self.pin = pin self.bouncetime = bouncetime GPIO.setmode (GPIO. BCM) GPIO.setup (tus pin, GPIO. IN, GPIO. PUD_UP) @property def nias (tus kheej):
ingedrukt = GPIO.input (tus kheej.pin) rov qab tsis ingedrukt
def on_press (tus kheej, call_method):
GPIO.add_event_detect (self.pin, GPIO. FALLING, call_method, bouncetime = self.bouncetime)
def on_release (tus kheej, call_method):
GPIO.add_event_detect (self.pin, GPIO. RISING, call_method, bouncetime = self.bouncetime)
Kauj Ruam 6: Tag Nrho Circuit
Tam sim no uas peb tau hla tag nrho cov khoom nws yog lub sijhawm los ua ke tag nrho lawv.
Thaum cov duab qhia cov khoom qhia txhua yam ntawm lub khob cij nws tus kheej nws zoo dua kom muaj lub lcd, adafruit GPS thiab khawm txuas nrog siv poj niam rau txiv neej xov hlau Tsuas yog muaj t-cobbler thiab mpu6050 ntawm lub khob cij. Thaum nws los txog ntawm tus coj thiab hloov siv cov xov hlau ntev dua kom ntseeg tau tias koj tuaj yeem ncav cuag lub qhov muag ntsais thiab tuav txoj hlua.
Kauj Ruam 7: Txoj Cai
Txhawm rau khaws cov lus qhia no kom huv kuv tau muab github chaw cia nrog ob lub backend thiab cov ntaub ntawv txuas rau yav tom ntej.sim yooj yim muab cov ntaub ntawv tso rau hauv daim nplaub tshev frontend hauv/var/www/html quav thiab cov ntaub ntawv hauv cov backend nplaub tshev hauv/home/ [username]/[foldname] nplaub tshev
Kauj Ruam 8: Cov Ntaub Ntawv
Vim tias txoj hauv kev no tau teeb tsa muaj qhov yooj yim webshop teeb tsa siv cov npe khoom lag luam hauv lub database, ntxiv mus peb muaj txhua txoj hauv kev cov ntsiab lus thiab xaj xaj khaws cia ntawm no. Tsim cov ntawv tuaj yeem pom ntawm github chaw cia khoom sib txuas hauv cov kauj ruam tom ntej
Kauj Ruam 9: Rooj plaub
Thaum peb paub cov khoom siv hluav taws xob ua haujlwm peb tuaj yeem muab lawv tso rau hauv lub thawv. thiab quav nws kom txog thaum koj muaj qee yam uas koj nyiam. Ntsuas thiab kos koj cov ntaub ntawv ntawm ib daim ntawv thiab ua los ntawm cov khoom ruaj khov zoo li ntoo, lossis yog tias tsis yog koj li 3d luam nws. Koj tsuas yog xyuas kom txhua yam khoom siv hluav taws xob haum sab hauv thiab koj muaj qhov rau khawm, xaim mus rau qhov hloov pauv, coj thiab lcd. Thaum koj tau ua koj cov ntaub ntawv nws tsuas yog teeb meem ntawm kev nrhiav txoj hauv kev los teeb nws ntawm koj lub tsheb kauj vab lossis lub scooter.
Pom zoo:
Hloov-Hloov Cov Khoom Ua Si: Dej-Taug Kev Taug Kev Zaj Ua Yooj Yim!: 7 Kauj Ruam (nrog Duab)
Hloov-Hloov Cov Khoom Ua Si: Dej-Taug Kev Taug Kev Zaj Ua Yooj Yim!: Qho khoom ua si hloov pauv qhib txoj hauv kev tshiab thiab kho cov kev daws teeb meem kom tso cai rau menyuam yaus uas muaj lub cev muaj peev xwm txwv lossis kev xiam oob khab kev cuam tshuam nrog cov khoom ua si ntawm nws tus kheej. Hauv ntau qhov xwm txheej, cov menyuam yaus uas xav tau cov khoom ua si hloov pauv tsis tuaj yeem nkag mus
DIY Smart Robot Taug Qab Cov Khoom Siv Tsheb Taug Kev Tsheb Photosensitive: 7 Kauj Ruam
DIY Smart Robot Tracking Tsheb Cov Khoom Siv Taug Kev Tsheb Photosensitive: Tsim los ntawm SINONING ROBOTKoj tuaj yeem yuav los ntawm kev taug qab neeg hlau tsheb TheoryLM393 nti sib piv ob lub photoresistor, thaum muaj ib sab photoresistor LED ntawm WHITE sab ntawm lub tshuab yuav nres tam sim ntawd, lwm sab ntawm lub cav tig rov qab, yog li ntawd
Cov Duab Duab Duab thiab Cov Duab 1: 4 Cov Kauj Ruam (nrog Duab)
Cov Duab Duab Cubes thiab Cov Duab 1: Thaum sim nrog qee cov ntoo ntoo thiab cov duab los qhia, kuv pom ob peb txoj hauv kev los ua cov voos thiab lwm yam duab los ntawm cov khoom siv yooj yim. Los ntawm kev muab cov no los ua Cov Ntawv Qhia, Kuv vam tias yuav txhawb nqa kev ua si thiab kev kawm. Kev hloov pauv ntawm qhov kev qhia no
Rov Qab Siv Cov Duab Duab Nrog Virtual Asistent: 7 Cov Kauj Ruam (nrog Duab)
Rov Qab Siv Cov Duab Duab Nrog Virtual Asistent: Nyob zoo txhua tus! Cov lus qhia no tau yug los ntawm lub laptop faib ua ib nrab, yuav los ntawm ib tus phooj ywg. Thawj qhov kev sim ntawm txoj haujlwm no yog kuv Lego Digital Photo Frame, txawm li cas los xij, yog ib tus neeg mob siab rau Siri thiab Google Tam sim no, Kuv txiav txim siab coj nws mus rau qhov tshiab
Tsheb kauj vab taug qab System nrog Tuag Tus Txiv Neej Alert Nrog Sigfox: 7 Cov Kauj Ruam (nrog Duab)
Tsheb kauj vab taug qab System Nrog Tuag Tus Txiv Neej Alert Nrog Sigfox: Kev ruaj ntseg rau cov neeg caij tsheb kauj vab nrog taug qab thiab xa cov yam ntxwv ceeb toom. Thaum muaj xwm txheej ceeb toom raug xa nrog GPS txoj haujlwm.Kev ruaj ntseg rau cov neeg caij tsheb kauj vab yog qhov yuav tsum tau, nrog kev tsheb kauj vab lossis tsheb kauj vab roob sib tsoo tshwm sim thiab sai li sai tau thaum muaj xwm txheej ceev