Cov txheej txheem:

IoT Dej Tswb: 5 Kauj Ruam (nrog Duab)
IoT Dej Tswb: 5 Kauj Ruam (nrog Duab)

Video: IoT Dej Tswb: 5 Kauj Ruam (nrog Duab)

Video: IoT Dej Tswb: 5 Kauj Ruam (nrog Duab)
Video: Sib Hawm Dhau (Time Passed) Music Video by: Deeda/Dib Xwb 2024, Hlis ntuj nqeg
Anonim
IoT Dej Tswb
IoT Dej Tswb

Kuv tsis ntev los no tau ntsib kev thaub qab hauv chav ua noj. Yog tias kuv tsis tau nyob hauv tsev thaum lub sijhawm, nws yuav ua rau hauv pem teb thiab phab ntsa puas hauv kuv chav tsev. Hmoov zoo, Kuv tau paub txog qhov teeb meem thiab npaj txhij los daus cov dej tawm nrog lub thoob. Qhov no ua rau kuv xav txog kev yuav lub tswb ceeb toom dej nyab. Kuv pom muaj ntau cov khoom lag luam pheej yig ntawm Amazon, tab sis cov uas muaj kev sib txuas hauv is taws nem muaj qhov feem pua ntawm kev tshuaj xyuas tsis zoo, feem ntau yog vim muaj teeb meem nrog cov kev pabcuam tshwj xeeb ceeb toom. Tias yog vim li cas kuv txiav txim siab los ua kuv tus kheej IoT dej tswb uas yuav siv kev ceeb toom ntseeg tau txhais tau tias yog kuv xaiv.

Kauj Ruam 1: Lub hauv paus ntsiab lus ntawm Kev Ua Haujlwm

Ntsiab Cai ntawm Kev Ua Haujlwm
Ntsiab Cai ntawm Kev Ua Haujlwm

Lub tswb muaj AVR ATtiny85 microcontroller raws li nws lub hlwb. Nws yuav siv qhov ntsuas hluav taws xob los ntawm lub roj teeb thiab lub ntsuas dej thiab sib piv lawv nrog tus nqi ua ntej tau txheeb xyuas kom pom tias muaj dej lossis muaj roj teeb tsawg.

Lub ntsuas dej tsuas yog ob lub xov hlau tso ze li ntawm 1 hli sib nrug. Ib qho ntawm cov xov hlau txuas nrog 3.3 V, thiab lwm qhov txuas nrog lub ntsuas tus lej ntawm lub microcontroller, uas tseem txuas nrog hauv av los ntawm 0.5 MOhm resistor. Feem ntau, kev tiv thaiv nruab nrab ntawm lub xov tooj hluav taws xob tau siab heev (zoo tshaj 10 MOhm), yog li tus lej nkag siab tau rub tawm mus rau 0 V. thiab tus pin pom pom qee qhov hluav taws xob (hauv kuv qhov xwm txheej txog 1.5 V). Thaum ATtiny85 pom qhov ntsuas hluav taws xob ntawm tus lej nkag siab, nws ua kom MOSFET txhawm rau ua kom lub suab nrov nrov, thiab xa lub suab ceeb toom rau ESP8266 tus qauv uas yog lub luag haujlwm xa ntawv ceeb toom (email thiab thawb ceeb toom). Tom qab ib pliag buzzing, lub tswb raug tshem tawm, thiab tuaj yeem rov pib dua los ntawm kev siv fais fab.

Chav tsev no khiav tawm ntawm ob lub cev alkaline lossis NiMH. Lub microcontroller tau pw tsaug zog feem ntau kom txuag lub roj teeb, sawv los sib quas ntus los tshuaj xyuas lub ntsuas dej nrog rau qhov hluav taws xob ntawm lub roj teeb. Yog tias lub roj teeb qis, lub microcontroller tsa ESP8266 tus qauv kom xa lus ceeb toom roj teeb tsawg. Tom qab ceeb toom, lub tswb raug tshem tawm kom tiv thaiv roj teeb ntau dhau.

Txij li ESP8266 tus qauv yog lub luag haujlwm xa ob qho lus ceeb toom roj teeb qis nrog rau kev ceeb toom txog dej nyab, nws yuav tsum muaj lub teeb liab tswj los ntawm ATiny85. Vim tias muaj pes tsawg tus lej muaj, qhov kev tswj hwm no yog tsim los ntawm tib tus pin lub luag haujlwm rau roj teeb LED qhia. Thaum lub sijhawm ua haujlwm ib txwm muaj (lub tswb tau ua tub rog thiab them lub roj teeb), LED ntsais ntsais ib ntus. Thaum kuaj pom lub roj teeb qis, LED tig los muab lub teeb liab siab rau RX tus pin ntawm ESP module. Yog tias pom dej, lub roj teeb LED yuav tawm thaum ESP8266 tau tsaug zog.

Kauj Ruam 2: Tsim thiab Sib Dhos

Tsim thiab Los Ua Ke
Tsim thiab Los Ua Ke
Tsim thiab Los Ua Ke
Tsim thiab Los Ua Ke
Tsim thiab Los Ua Ke
Tsim thiab Los Ua Ke

Kuv tsim lub Circuit Court los ua rau ntawm ob tog ob tog 4x6 cm protoboard siv feem ntau 0805 SMD qhov chaw. Cov txheej txheem nthuav qhia yog ua raws qhov tsim no, tab sis nws tuaj yeem hloov kho tau yooj yim rau hauv cov khoom sib dhos (cov lus qhia: txhawm rau txo qhov chaw, cov kab laug sab dhau los ntawm lub qhov tiv thaiv kab rov tav).

Cov hauv qab no xav tau:

- Resistors: 330 Ω x 1; 470x1; ib. 680x1; ib. 1kx1; ib. 10 x3; 470x3; qw. - Ib qho 10 µF ceramic capacitor- Ib lub logic-qib N-channel MOSFET (piv txwv li RFP30N06LE lossis AO3400)- Ib qho liab thiab ib qho LED daj (lossis lwm yam xim yog tias koj nyiam).- Ob-hlau ntsia hlau dav hlau txuas x 3 (lawv tsis yog tsim nyog kiag li, tab sis lawv ua kom yooj yim txuas thiab tshem tawm ib puag ncig thaum ntsuas)- Lub suab nrov piezo buzzer uas zoo rau 3.3 V- Ib qho ATtiny85 microcontroller (PDIP version)- 8-pin PDIP qhov rau microcontroller- ESP-01 module (nws tuaj yeem hloov pauv tau los ntawm lwm qhov ESP8266-based module, tab sis yuav muaj kev hloov pauv ntau hauv qhov teeb tsa hauv qhov xwm txheej ntawd)-3.3 V DC-DC txhawb kev hloov pauv muaj peev xwm xa 200 mA (500 mA tawg) tam sim no ntawm 2.2 V tswv yim. (Kuv pom zoo https://www.canton-electronics.com/power-converter… vim tias nws qhov qis tshaj tam sim no)-Ib qho 3 tus pin poj niam lub taub hau-Ob tus poj niam 4-tus pin lub taub hau lossis ib lub 2x4 lub taub hau-22 AWG cov xov hlau rau cov ntsuas dej- 22 AWG tso tseg cov xaim (lossis lwm hom kab xaim pom los tsim cov cim)

Kuv pom zoo qhov ntsuas qhov ntsuas tau teev tseg saum toj no, tab sis koj tuaj yeem hloov pauv feem ntau ntawm lawv rau qhov zoo sib xws. Nyob ntawm seb hom LEDs koj xav siv, koj yuav xav tau kho qhov ntsuas qhov ntsuas tam sim no kom tau txais qhov xav tau ci ci. MOSFET tuaj yeem dhau los ntawm qhov lossis SMT (SOT23). Tsuas yog kev taw qhia ntawm 330 Ohm resistor cuam tshuam los ntawm hom MOSFET. Ib PTC fuse (piv txwv li ntsuas rau 1 A) raug pom zoo yog tias koj tab tom npaj yuav siv qhov Circuit Court no nrog cov roj teeb NiMH. Txawm li cas los xij, nws tsis xav tau nrog roj teeb alkaline. Ntsis: ntu uas xav tau rau lub tswb nrov no tuaj yeem yuav pheej yig los ntawm ebay lossis Aliexpress.

Ib qho ntxiv koj yuav xav tau lub khob cij, ntau qhov hla 10k tus tiv thaiv, ntau tus txiv neej-txiv neej thiab poj niam-txiv neej jumper ("dupont") cov xov hlau thiab USB-UART adapter txhawm rau txhawm rau teeb tsa ESP-01 module.

Lub ntsuas dej tuaj yeem ua ntau txoj hauv kev, tab sis qhov yooj yim tshaj yog ob 22 AWG xov hlau nrog qhov xaus (1 cm ntev) sib nrug kwv yees li 1 hli sib nrug. Lub hom phiaj yog kom muaj tsawg dua 5 MΩ kev tiv thaiv nruab nrab ntawm lub ntsuas sensor thaum muaj dej.

Lub Circuit Court yog tsim los rau kev siv roj teeb ntau tshaj. Nws tsuas yog 40-60 µA hauv kev saib xyuas kev tswj hwm (nrog lub zog LED tshem tawm ntawm ESP-01 module). Thaum lub tswb ceeb toom tshwm sim, lub Circuit Court yuav kos 300-500 mA (ntawm 2.4 V input) rau ib pliag lossis tsawg dua, thiab tom qab ntawd qhov tam sim no yuav poob qis dua 180 mA. Thaum ESP tus qauv ua tiav xa cov ntawv ceeb toom, kev siv tam sim no yuav poob qis dua 70 mA kom txog rau thaum lub suab nrov nrov tawm. Tom qab ntawv lub tswb yuav tshem nws tus kheej, thiab kev siv tam sim no yuav qis dua 30 µA. Yog li teeb tsa AA roj teeb yuav tuaj yeem siv hluav taws xob rau ntau lub hlis (zoo li ntau xyoo). Yog tias koj siv qhov hloov pauv sib txawv, hais nrog qhov tsis txaus ntseeg tam sim no ntawm 500 µA, cov roj teeb yuav xav tau hloov ntau dua.

Cov lus qhia los ua ke:

Siv tus cim cim tas mus li txhawm rau sau tag nrho cov kab thiab cov khoom tiv thaiv ntawm cov protoboard kom yooj yim dua. Kuv pom zoo kom ua raws li hauv qab no:

- sab saum toj SMT LEDs thiab cov hlua hlau thaiv

-sab saum toj MOSFET (ceeb toom: yog tias koj muaj SOT-23 MOSFET, tso nws kab pheeb ces kaum raws li hauv daim duab. Yog tias koj siv MOSFET hla qhov, tso nws kab rov tav nrog lub qhov rooj pin hauv txoj haujlwm I3.)

- sab saum toj los ntawm qhov ntu (ceeb toom: lub buzzer tsis soldered thiab tsis txawm tias yuav tsum tau teeb tsa rau PCB)

- thim rov qab sab SMT qhov chaw thiab cov cim (piv txwv li ib tus neeg los ntawm AWG22 xaim)

Kauj ruam 3: Firmware

C code rau ATtiny85

Main.c muaj cov cai uas yuav tsum tau muab tso ua ke thiab muab tso rau hauv lub microcontroller. Yog tias koj yuav siv Arduino pawg thawj coj los ua tus programmer, koj tuaj yeem pom daim duab kab hluav taws xob hauv qhov kev qhia no. Koj yuav tsum ua raws cov ntu hauv qab no (tsis quav ntsej qhov seem):

-Kev teeb tsa Arduino Uno ua ISP (Hauv-Qhov Txheej Txheem)

- Txuas ATtiny85 nrog Arduino Uno.

Txhawm rau suav thiab xa cov firmware, koj yuav xav tau CrossPack (rau Mac OS) lossis AVR toolchain (rau Windows). Cov lus txib hauv qab no yuav tsum tau ua kom ua tiav cov lej:

avr -gcc -Os -mmcu = attiny85 -c main.c; avr -gcc -mmcu = attiny85 -o main.elf main.o; avr -objcopy -j.text -j.data -O ihex main.elf main.hex

Txhawm rau rub tawm lub firmware, khiav cov hauv qab no:

avrdude -c arduino -p attiny85 -P /dev/cu.usbmodem1411 -b 19200 -e -U nyem: w: main.hex

Hloov chaw "/dev/cu.usbmodem1411" koj yuav zoo li yuav tsum ntxig qhov chaw nres nkoj uas koj Arduino txuas nrog (koj tuaj yeem pom nws hauv Arduino IDE: Tools Port).

Txoj cai muaj ntau txoj haujlwm. deep_sleep () ua rau lub microcontroller nkag mus rau lub zog qis heev rau kwv yees li 8 vib nas this. read_volt () yog siv los ntsuas lub roj teeb thiab lub ntsuas hluav taws xob. Lub roj teeb hluav taws xob tau ntsuas tawm tsam sab hauv qhov ntsuas hluav taws xob siv (2.56 V ntxiv lossis rho tawm ob peb feem pua) qhov ntsuas qhov ntsuas hluav taws xob tau ntsuas tawm tsam Vcc = 3.3 V. Kev nyeem ntawv tau muab piv rau BATT_THRESHOLD thiab SENSOR_THRESHOLD txhais raws li 932 thiab 102 feem, uas sib haum rau ~ 2.3 thiab 0.3 V. Koj tuaj yeem tuaj yeem txo tus nqi roj teeb rau kev txhim kho roj teeb lub neej, tab sis nws tsis pom zoo (xa mus rau Kev txiav txim roj teeb rau cov ntaub ntawv ntxaws).

activate_alarm () ceeb toom rau ESP module txog kev ntsuas dej thiab suab nrov nrov. low_batt_notification () ceeb toom rau ESP module lub roj teeb qis thiab tseem hnov lub suab nrov. Yog tias koj tsis xav kom sawv hauv nruab nrab hmo ntuj kom hloov roj teeb, tshem tawm "| 1 <" hauv low_batt_notification ().

Arduino kos duab rau ESP-01

Kuv tau xaiv los teeb tsa ESP module siv Arduino HAL (ua raws qhov txuas rau teeb tsa cov lus qhia). Tsis tas li ntawd kuv siv ob lub tsev qiv ntawv hauv qab no:

ESP8266 Xa Email los ntawm Górász Péter

ESP8266 Pushover los ntawm pab pawg Arduino Hannover

Thawj lub tsev qiv ntawv txuas rau SMTP server thiab xa ntawv ceeb toom rau koj tus email chaw nyob. Tsuas yog tsim gmail account rau koj ESP, thiab ntxiv cov ntawv pov thawj rau tus lej. Lub tsev qiv ntawv thib ob xa cov ntawv ceeb toom los ntawm Pushover cov kev pabcuam (ceeb toom tsis pub dawb, tab sis koj yuav tsum tau them ib zaug txhawm rau teeb tsa daim ntawv thov ntawm koj lub xov tooj/ntsiav tshuaj). Rub tawm ob lub tsev qiv ntawv. Muab cov ntsiab lus ntawm Xa Email lub tsev qiv ntawv rau hauv koj daim duab sketch (arduino yuav tsim nws thaum koj qhib qhov kos duab arduino thawj zaug). Nruab Pushover lub tsev qiv ntawv ntawm IDE (Sketch -> Xws li Lub Tsev Qiv Ntawv -> Ntxiv. ZIP tsev qiv ntawv).

Txhawm rau teeb tsa ESP-01 tus qauv koj tuaj yeem ua raws cov lus qhia hauv qab no: https://www.allaboutcircuits.com/projects/breadbo… cov xov hlau los txuas cov pins ntawm tus qauv rau lub khob cij. Tsis txhob hnov qab tias lub zog hloov pauv thiab USB-UART adapter yuav tsum sib qhia hauv av (ceeb toom: koj yuav tuaj yeem siv 3.3 V cov zis ntawm USB-UART adapter hloov chaw hloov pauv, tab sis feem ntau nws yuav tsis muaj peev xwm tso tawm tam sim no txaus).

Kauj Ruam 4: Kev Xav Txog Roj Teeb

Tus lej firmware tau muab ua ntej tau teeb tsa kom xa cov lus ceeb toom roj teeb qis thiab kaw ntawm ~ 2.3 V. Qhov pib no yog ua raws li kev xav tias ob lub roj teeb NiMH tau siv ua ke. Nws tsis pom zoo kom tso tawm ib tus neeg NiMH cell hauv qab 1 V. Piv txwv tias ob lub cell muaj peev xwm sib npaug thiab cov yam ntxwv tawm, ob qho ntawm lawv yuav raug txiav tawm ntawm ~ 1.15 V - zoo nyob hauv thaj tsam nyab xeeb. Txawm li cas los xij, NiMH cov hlwb uas tau siv rau ntau qhov kev tawm mus zoo li muaj peev xwm sib txawv. Txog li 30% qhov sib txawv hauv lub peev xwm tuaj yeem zam tau vim nws tseem yuav ua rau qhov qis tshaj ntawm tes txiav tawm ntawm ib puag ncig 1 V.

Thaum nws tuaj yeem txo qis cov roj teeb qis hauv lub khoos phis tawj, ua li ntawd yuav tshem tawm qhov kev nyab xeeb, thiab tuaj yeem ua rau roj teeb dhau-tawm thiab ua puas thaum tsuas yog nce me ntsis hauv lub roj teeb lub neej yog qhov xav tau (NiMH cell yog> 85% tawm ntawm 1.15 V).

Lwm qhov tseem ceeb uas yuav tsum tau coj mus rau hauv tus account yog lub peev xwm ntawm kev hloov pauv kom muab tsawg kawg 3.0 V (2.5 V raws li cov pov thawj tsis tseeb) ntawm 300-500 mA qhov siab tshaj tam sim no ntawm cov roj teeb qis. Kev tiv thaiv sab hauv qis ntawm NiMH cov roj teeb ua rau muaj qhov poob qis ntawm 0.1 V ntawm qhov siab tshaj tam sim no, yog li ib khub ntawm NiMH hlwb tso tawm rau 2.3 V (qhib Circuit) yuav tuaj yeem muab tsawg kawg 2.2 V rau lub zog hloov pauv. Txawm li cas los xij, nws nyuaj dua nrog cov roj teeb alkaline. Nrog ib khub ntawm AA roj teeb zaum ntawm 2.2-2.3 V (qhib hluav taws xob) qhov hluav taws xob poob ntawm 0.2-0.4 V yog qhov xav tau ntawm qhov siab tshaj plaws. Txawm hais tias kuv tau txheeb xyuas qhov Circuit ua haujlwm nrog kev pom zoo txhawb kev hloov pauv nrog me me li 1.8 V muab ntawm qhov siab tshaj tam sim no, qhov no yuav ua rau cov zis hluav taws xob poob qis ib ntus hauv qab tus nqi qhia los ntawm Espressiff. Yog li qhov txiav tawm ntawm 2.3 V tawm me ntsis kev nyab xeeb nrog cov roj teeb alkaline (nco ntsoov tias kev ntsuas hluav taws xob ntsuas los ntawm lub microcontroller yog qhov tseeb tsuas yog ntxiv lossis rho tawm ob peb feem pua). Txhawm rau kom ntseeg tau tias ESP module tsis cuam tshuam thaum cov roj teeb alkaline tsawg, Kuv pom zoo kom nce qhov txiav tawm qhov hluav taws xob mus rau 2.4 V (#define BATT_THRESHOLD 973). Ntawm 1.2 V (qhib Circuit) ib lub xov tooj ntawm alkaline yog li 70% tso tawm uas tsuas yog 5-10 feem pua cov ntsiab lus qis dua qib kev tso tawm ntawm 1.15 V rau ib lub xov tooj.

Ob lub NiMH thiab cov tshuaj alkaline muaj qhov zoo thiab qhov tsis zoo rau daim ntawv thov no. Cov roj teeb Alkaline muaj kev nyab xeeb dua (tsis txhob tua hluav taws yog tias luv), thiab lawv muaj tus nqi tso tus kheej qis dua. Txawm li cas los xij, NiMH cov roj teeb tau lees tias ua haujlwm tau zoo ntawm ESP8266 ntawm qhov txiav tawm qis dua ua tsaug rau lawv qhov kev tiv thaiv sab hauv qis. Tab sis thaum kawg, hom twg tuaj yeem siv nrog qee qhov kev ceev faj, yog li nws tsuas yog teeb meem ntawm kev nyiam tus kheej.

Kauj Ruam 5: Kev Tsis Pom Zoo Raws Cai

Lub voj voog no tau tsim los ntawm tus kws tshaj lij uas tsis yog kws tshaj lij rau kev nyiam ua haujlwm nkaus xwb. Qhov kev tsim no tau qhia tawm hauv kev ntseeg siab, tab sis tsis muaj kev lees paub dab tsi. Siv nws thiab qhia rau lwm tus ntawm koj tus kheej txoj kev pheej hmoo. Los ntawm kev rov tsim lub Circuit koj pom zoo tias tus neeg tsim khoom yuav tsis raug lav rau ib qho kev puas tsuaj (suav nrog tab sis tsis txwv rau kev puas tsuaj ntawm cov cuab tam thiab raug tus kheej) uas tuaj yeem tshwm sim ncaj qha lossis tsis ncaj qha los ntawm kev ua haujlwm tsis zoo lossis kev siv ib txwm muaj ntawm qhov Circuit no. Yog tias txoj cai ntawm koj lub tebchaws nullify lossis txwv qhov kev zam ntawm kev lav phib xaub, koj yuav tsis siv qhov kev tsim no. Yog tias koj qhia qhov kev tsim lossis hloov pauv Circuit Court raws li qhov tsim qauv no, koj yuav tsum tau txais txiaj ntsig thawj tus neeg tsim khoom los ntawm kev qhia qhov url ntawm cov lus qhia no.

Pom zoo: