Cov txheej txheem:
- Khoom siv
- Kauj ruam 1: Kev thaiv kab
- Kauj Ruam 2: Ua Kom Koj Li Load Cell Siv Tau
- Kauj ruam 3: Normalized Database
- Kauj Ruam 4: Coding Load Cell
- Kauj Ruam 5: Coding Dej Sensor
- Kauj Ruam 6: Coding Qhov Sib Cais Sensor
- Kauj Ruam 7: Coding Stepper Motors
- Kauj Ruam 8: Coding LCD
- Kauj Ruam 9: Qhov Kawg
Video: AUTOMATIC PET FOOD DISPENSER: 9 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
Puas tau xav zoo li nkim sijhawm ntau dhau rau koj tus tsiaj? Puas tau hu xov tooj rau ib tus neeg los pub koj cov tsiaj thaum koj nyob rau hnub so? Kuv tau sim kho ob qho teeb meem no nrog kuv qhov haujlwm tam sim no hauv tsev kawm ntawv: Petfeed!
Khoom siv
Raspberry Pi 3b
Bar Load Cell (10kg)
HX711 Load Cell Amplifier
Waterlevel Sensor (https://www.dfrobot.com/product-1493.html)
Ultrasonic sib thooj Sensor
LCD 16-pin
2x stepper tsav 28byj-48
2x stepper tsav tsav ULN2003
Kauj ruam 1: Kev thaiv kab
ntau cabling ntawm no. Tawm koj cov jumper cables thiab pib pinning!
Kauj Ruam 2: Ua Kom Koj Li Load Cell Siv Tau
txhawm rau siv lub nra thauj khoom, thawj zaug peb yuav tsum txuas nws rau ob daim phiaj: hauv qab phaj, thiab phaj uas peb yuav ntsuas peb cov zaub mov.
Cov ntsia hlau uas koj xav tau yog ib khub M4 ntsia hlau nrog cov ntsia hlau sib dhos thiab ib khub ntawm M5 ntsia hlau nrog cov ntsia hlau sib dhos. Kuv siv lub laum me me los ua qhov.
(pic:
Kauj ruam 3: Normalized Database
cov ntaub ntawv los ntawm peb cov sensors yuav tsum tau khaws tseg hauv lub database. Txog cov nab nab cov ntaub ntawv txuas rau lub hauv paus: saib hauv qab no.
ces koj kuj xav tau cov ntaub ntawv teeb tsa:
[connector_python] neeg siv = * yourusername * host = 127.0.0.1 #if chaw nres nkoj hauv zos = 3306 tus password = * yourpassword * database = * yourdb * [application_config] driver = 'SQL Server'
Kauj Ruam 4: Coding Load Cell
ntshuam RPi. GPIO li GPIOimporting ntshuam lub sijhawm los ntawm hx711 ntshuam HX711 los ntawm helpers.stepperFood ntshuam StepperFood los ntawm pab. LCDWrite ntshuam LCDWrite los ntawm cov chaw khaws khoom.
Tom qab ntshuam tag nrho peb cov tsev qiv ntawv (nco ntsoov, peb siv HX711 Lub Tsev Qiv Ntawv los tsav lub xov tooj ntawm tes) peb tuaj yeem pib sau peb cov lej tiag
TARRA_CONSTANT = 80600
GRAM_CONSTANT = 101
Txhawm rau nrhiav tawm peb qhov tsis sib xws, xub teeb tsa TARRA_CONSTANT = 0 thiab GRAM_CONSTANT = 1.
Tom ntej no peb yuav tsum nrhiav kom paub tus nqi peb lub xov tooj ntawm tes nyeem thaum tsis muaj dab tsi raug hnyav. Tus nqi no yuav yog TARRA_CONSTANT.
Raws li rau GRAM_CONSTANT, tsuas yog coj yam khoom koj paub qhov hnyav ntawm (kuv siv pob ntawm spaghetti's), ntsuas nws thiab faib cov load cell nyeem nrog qhov hnyav ntawm qhov khoom. Rau kuv qhov no yog 101.
chav kawm LoadCell (threading. Thread):
def _init _ (tus kheej, qhov (socket), lcd): threading. Thread._ init _ (self) self.hx711 = HX711 (dout_pin = 5, pd_sck_pin = 6, channel = 'A', nce = 64) self.socket = socket self.lcd lcd = lwd
nov peb pib qib LoadCell thiab qhia cov pins.
def khiav (tus kheej):
sim: thaum Muaj Tseeb: self.hx711.reset () # Ua ntej peb pib, rov pib dua HX711 (tsis ua raws qhov xav tau) ntsuas_avg = sum (self.hx711.get_raw_data ()) / 5 hnyav = puag ncig ((ntsuas_avg - TARRA_CONSTANT) / GRAM_CONSTANT, 0) print ("hnyav: {0}". Hom ntawv (hnyav)) DataRepository.insert_weight (hnyav) data_weight = DataRepository.get_data_sensor (3) historyId = data_weight ["SensorsHistory"] db_weight = data_weight ["tus nqi"] actionTime = data_weight ["actionTime"] self.socket.emit ('data_weight', {"id": historyId, "Weight": db_weight, "Sijhawm": DataRepository.serializeDateTime (actionTime)}) print ("zou moeten emitten") writeWeight = "qhov hnyav:" + str (db_weight) msg = "PETFEED" LCDWrite.message () yog int (db_weight [:-2]) <= 100: StepperFood.run () time.s pw (20) tshwj tsis yog kev zam raws li e: luam tawm ("Yuam kev nrog qhov hnyav" + str (e))
Kauj Ruam 5: Coding Dej Sensor
ntshuam sij hawm ntshuam xov xov los ntawm chaw cia khoom. DataRepository ntshuam DataRepository los ntawm RPi ntshuam GPIOGPIO.setmode (GPIO. BCM) GPIO.setwarnings (Cuav) GPIO_Water = 18 GPIO.setup (GPIO_Water, GPIO. IN) chav WaterSensor (threading. Thread): def _in tus kheej, qhov (socket): threading. Thread._ init _ (self) self.socket = socket self.vorige_status = 0 def run (self): sim: thaum Muaj tseeb: dej = self.is_water () print (dej) xwm txheej = dej [" xwm txheej "] ua = dej [" ua "] DataRepository.insert_water (str (xwm txheej), nqis tes ua) data_water = DataRepository.get_data_sensor (2) historyId = data_water [" SensorsHistory "] tus nqi = data_water [" tus nqi "] yog tus nqi == "0": value = "te weinig water" else: value = "genoeg water" actionTime = data_water ["actionTime"] self.socket.emit ('data_water', {"id": historyId, "value": tus nqi, "Sijhawm": DataRepository.serializeDateTime (actionTime), "action": action}) time.sleep (5) tshwj tsis yog Kev zam raws li ex: print (ex) print ('error bij watersensor') def is_water (self): status = GPIO.input (GPIO_Wate r) yog self.vorige_status == 0 thiab xwm txheej == 1: luam tawm ('dej gedetecteerd') sensorData = {"xwm txheej": xwm txheej, "nqis tes ua": "dej gedetecteerd"} self.vorige_status = xwm txheej xwm txheej = GPIO.input (GPIO_Water) yog tus kheej.vorige_status == 1 thiab xwm txheej == 1: luam tawm ('dej aanwezig') sensorData = {"xwm txheej": xwm txheej, "ua": "dej aanwezig"} xwm txheej = GPIO.input (GPIO_Water) yog self.vorige_status == 1 thiab xwm txheej == 0: print ('dej weg') sensorData = {"xwm txheej": xwm txheej, "ua": "dej weg"} self.vorige_status = xwm txheej xwm txheej = GPIO.input (GPIO_Water) yog self.vorige_status == 0 thiab xwm txheej == 0: print ('startpositie') xwm txheej = GPIO.input (GPIO_Water) sensorData = {"status": status, "action": "startpositie"} return sensorData
Kauj Ruam 6: Coding Qhov Sib Cais Sensor
ntshuam sij hawm ntshuam xov xov los ntawm chaw cia khoom. DataRepository ntshuam DataRepository los ntawm RPi ntshuam GPIO GPIO.setmode (GPIO. BCM) GPIO.setwarnings (Cuav) GPIO_Trig = 4 GPIO_Echo = 17 GPIO.setup (GPIO_Trig, GPIO. OUT) GPIO.setup (GPIO_Echo, GPIO_Echo,. IN) def tam sim no_milli_time (): rov qab int (puag ncig (sijhawm.time () * 1000)) chav kawm UltrasonicSensor (xov xov. Xov): def _init _ (tus kheej, qhov (socket)): threading. Thread._ init _ (self) self.socket = socket def run (tus kheej): sim: last_reading = 0 interval = 5000 thaum Tseeb: yog tam sim no_milli_time ()> last_reading + interval: dist = self.distance () print ("Ntsuas nrug = %.1f cm" % deb) DataRepository. insert_proximity (dist) data_prox = DataRepository.get_data_sensor (1) historyId = data_prox ["SensorsHistory"] prox = data_prox ["value"] actionTime = data_prox ["actionTime"] self.socket.emit ('data_proximity', {"id": historyId, "Proximity": prox, "Time": DataRepository.serializeDateTime (actionTime)}) last_reading = current_milli_time () tsuas yog Kev zam raws li ex: print (ex) de f nrug (tus kheej): # teeb tsa rau HIGH GPIO.output (GPIO_Trig, Tseeb) # teeb tsa tom qab 0.01ms rau LOW time.sleep (0.00001) GPIO.output (GPIO_Trig, Cuav) PibTime = time.time () StopTime = time.time () # txuag StartTime thaum GPIO.input (GPIO_Echo) == 0: StartTime = time.time () # txuag lub sijhawm tuaj txog thaum GPIO.input (GPIO_Echo) == 1: StopTime = time.time () # sijhawm sib txawv ntawm qhov pib thiab tuaj txog TimeElapsed = StopTime - StartTime # sib npaug nrog lub suab sonic (34300 cm / s) # thiab faib ua 2, vim tias muaj thiab nrug nrug = (TimeElapsed * 34300) / 2 rov qab nrug
Kauj Ruam 7: Coding Stepper Motors
ntshuam RPi. GPIO li GPIOimport lub sij hawm ntshuam threading GPIO.setmode (GPIO. BCM) GPIO.setwarnings (Cuav) control_pins = [12, 16, 20, 21] rau tus pin hauv control_pins: GPIO.setup (tus pin, GPIO. OUT) GPIO.output (pin, 0) halfstep_seq =
Txoj cai no rov siv tau rau lwm tus neeg tsav lub zog, tsuas yog teeb tus lej tus lej tswj rau lawv tus lej rov qab thiab hloov npe chav kawm rau StepperWater:
Kauj Ruam 8: Coding LCD
Ntau tus lej, tab sis peb yuav luag tiav.
Chav kawm LCD suav nrog ua cov ntaub ntawv LCD.py
los ntawm helpers. LCD ntshuam LCD
E = 26 RS = 25 D0 = 19 D1 = 13 D2 = 24 D3 = 22 D4 = 23 D5 = 8 D6 = 7 D7 = 10 lcd = LCD (E, RS, [D0, D1, D2, D3, D4, D5), D6, D7]) chav LCDWrite: def message (msg): sim: luam tawm ("sim") lcd.init_LCD () lcd.send_instruction (12) lcd.clear_display () lcd.write_message (msg, '1') tshwj tsis yog: print ("yuam kev LCDWrite")
Kauj Ruam 9: Qhov Kawg
qhov kawg: yuav ua li cas peb kos nws li vs. nws xaus li cas.
Pom zoo:
AUTOMATIC TOILET FLUSHER: 5 Kauj Ruam
AUTOMATIC TOILET FLUSHER: Cov chav dej yog thawj yam uas koj kov tom qab koj ua koj txoj kev lag luam feem ntau yuav ua rau cov yaug dej tej zaum yuav tsis huv heev. Qhov chaw zoo tshaj rau kis tus kabmob coronavirus. Txhawm rau daws qhov teeb meem no kuv tau tsim KEV TSHAWB XEEB-DAWB TOILET FLUSHER. Kuv yog
JCN: Vector Equilibrium Food Computer Lub Tswv Yim: 9 Kauj Ruam
JCN: Vector Equilibrium Food Computer Lub Tswv Yim: Peb qhib nrog lub trailer rau cov vis dis aus yuav los tom ntej " JCN thiab cov neeg ya saum ntuj ceeb tsheej; Epic Tale of Food and Fun in Outer Space " .Qhov kuv coj tawm ntawm qhov phiaj xwm kev sib tham video yog tias peb yuav tsom mus rau cov ntsiab lus dav thiab kom muaj kev lom zem! Kuv muaj
JCN: Vector Equilibrium Food Computer Concept V60.s: 10 Kauj Ruam
JCN: Vector Equilibrium Food Computer Concept V60.s: Nyob Zoo thiab Zoo Siab Txais Tos. Kuv qhov tseem ceeb tau los ntawm kev sib tham hauv xov tooj nrog NASA cov kws tshawb fawb thiab lwm tus. Kuv cov sijhawm tos los ntawm cov kev sib tham no yog thi
AUTOMATIC PILL DISPENSER: 14 Kauj Ruam (nrog Duab)
AUTOMATIC PILL DISPENSER: Nov yog lub tshuab xa tshuaj ntsiav neeg hlau tuaj yeem muab tus neeg mob kom raug thiab hom tshuaj noj. Kev noj cov ntsiav tshuaj tau ua tiav ntawm lub sijhawm raug ntawm hnub, ua ntej los ntawm lub tswb. Thaum khoob, lub tshuab yooj yim rov ua dua
IoT Food Feeder rau Tsiaj: 9 Kauj Ruam
IoT Food Feeder rau Tsiaj: Hauv qhov haujlwm no peb yuav tsim IOT cov khoom noj ua kua rau tsiaj thiab lwm yam tsiaj. Txoj haujlwm no yog siv rau kev noj qab haus huv ntawm cov tsiaj tsis zoo (dev, miv, noog thiab lwm yam) lossis tiv thaiv kev puas tsuaj ntawm biodiversity ces nws tuaj yeem pab peb kom ua tiav smar