Cov txheej txheem:

Taug qab & taug qab rau Cov Khw Me Me: 9 Kauj Ruam (nrog Duab)
Taug qab & taug qab rau Cov Khw Me Me: 9 Kauj Ruam (nrog Duab)

Video: Taug qab & taug qab rau Cov Khw Me Me: 9 Kauj Ruam (nrog Duab)

Video: Taug qab & taug qab rau Cov Khw Me Me: 9 Kauj Ruam (nrog Duab)
Video: Nus Ham - Ntsuj Plig Tu Siab ❤️❤️(Nkauj Tawm Tshiab 2023)[Official MV] 2024, Hlis ntuj nqeg
Anonim
Taug qab & taug qab rau Cov Khw Me
Taug qab & taug qab rau Cov Khw Me

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

Ua kom muaj zog ntawm Circuit thiab Pi
Ua kom muaj zog ntawm Circuit thiab Pi
Ua kom muaj zog ntawm Circuit thiab Pi
Ua kom muaj zog ntawm 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

TIAB SA 6050
TIAB SA 6050

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:

  1. ntaus hauv "sudo raspi-config"
  2. Xaiv Configurations Interfacing
  3. Hauv kev xaiv cuam tshuam, Xaiv "I2C"
  4. Pab kom I2C teeb tsa
  5. 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

Adafruit Qhov Ua Phem Tshaj Tawm GPS
Adafruit Qhov Ua Phem Tshaj Tawm 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

16x2 LCD npo
16x2 LCD npo

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

Servo, Leds, Khawm thiab Hloov
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

Tag Nrho Circuit
Tag Nrho Circuit
Tag Nrho Circuit
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

Cov Database
Cov Database

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

Rooj plaub
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: