Cov txheej txheem:

Cov Ntawv Txuas Txuas Hnub Ci Powered: 12 Cov Kauj Ruam (nrog Duab)
Cov Ntawv Txuas Txuas Hnub Ci Powered: 12 Cov Kauj Ruam (nrog Duab)

Video: Cov Ntawv Txuas Txuas Hnub Ci Powered: 12 Cov Kauj Ruam (nrog Duab)

Video: Cov Ntawv Txuas Txuas Hnub Ci Powered: 12 Cov Kauj Ruam (nrog Duab)
Video: Tseem Ev Lub Kawm - Koos Loos 2024, Hlis ntuj nqeg
Anonim
Txuas nrog Letterbox Solar Powered
Txuas nrog Letterbox Solar Powered
Txuas nrog Letterbox Solar Powered
Txuas nrog Letterbox Solar Powered

Rau kuv qhov Ible thib ob, Kuv yuav piav qhia koj txog kuv li haujlwm txog kuv lub thawv ntawv txuas.

Tom qab nyeem Cov Lus Qhia no (+ ntau lwm qhov ntxiv), thiab raws li kuv lub thawv ntawv tsis nyob ze kuv lub tsev, Kuv xav txhawb kuv ntawm Qhib Green Zog ua haujlwm los txuas kuv lub npov rau kuv Domoticz server.

Lub Hom Phiaj

  • Qhia los ntawm Telegram thaum cov ntawv tuaj;
  • Qhia los ntawm Telegram thaum pob khoom tuaj;
  • Txheeb xyuas yog tias tau khaws cov ntawv / pob ntawv.

Kuv qhov kev txwv loj

Lub npov xa ntawv nyob deb ntawm lub tsev, thiab nws tsis tuaj yeem rub lub xov hluav taws xob txuas mus rau nws kom muaj zog dab tsi.

Kuv yuav tsum nrhiav lwm txoj kev daws teeb meem: hnub ci zog yog ib qho kev daws teeb meem zoo!

Tus BOM

  • Raspberry Pi (los tuav MQTT thiab Domoticz qhov chaw - tsis tau hais tawm ntawm no)
  • Tus lej Telegram Bot
  • Lolin D1 mini (lossis Wemos…)
  • Plug-In Ntsia Hlau Terminal Thaiv Txuas
  • TP4056 Lithium Battery Charging Board
  • 6V 2W Photovoltaic Solar Vaj Huam Sib Luag
  • Li-Ion 18650 roj teeb
  • Li-Ion roj teeb tuav
  • PCB DIY Soldering Copper Prototype Luam Circuit Board
  • Analog Servo SG90 Cov
  • 3 Reed Hloov (ib qho rau cov tsiaj ntawv, ib qho rau pob thiab ib qho rau kev them nyiaj)
  • Hlau nplaum
  • Qee cov xov hlau
  • Ntoo crate: Raws li tsis tau txais lub tshuab luam ntawv 3D, Kuv paub kuv lub tsev me me nrog ntoo kom tau txais cov khoom siv hluav taws xob …
  • Spare Ethernet cable
  • RJ45 Ethernet Connector Breakout Board

  • J-B Kev
  • Ib co pob bearings
  • Screws, txiv ntseej, tshuab ntxhua khaub ncaws

Kauj Ruam 1: Cov Txheej Txheem Thoob Ntiaj Teb

Ntiaj teb Scheme
Ntiaj teb Scheme
Ntiaj teb Scheme
Ntiaj teb Scheme

Cov duab zoo nkauj yeej ib txwm zoo dua li cov lus hais ntev;-)

Tab sis ob peb qhov kev piav qhia txog MQTT, Domoticz thiab Telegram yeej ib txwm txais tos!

MQTT (Message Queuing Telemetry Transport), yog cov txheej txheem xa xov, siv los xa cov ntaub ntawv ntawm cov cuab yeej thiab lwm yam txheej txheem hauv ntiaj teb ntawm IoT (Internet ntawm yam).

Tsis tau mus rau hauv cov ntsiab lus ntau dhau, nws txoj haujlwm yog ua raws lub hauv paus ntsiab lus ntawm cov neeg siv khoom txuas rau lub server. Hauv MQTT, cov neeg siv khoom raug hu ua Subscriber lossis Publisher, thiab lub server hu ua Broker.

Hauv Cov Lus Qhia no, Kuv siv tsuas yog ib tus tshaj tawm, Lolin txuas mus rau kuv lub thawv ntawv: thaum pom cov ntawv lossis pob khoom ntawm tus reed hu rau hauv lub thawv ntawv (Kauj Ruam 1 hauv shematic), nws xa MQTT lus dhau WIFI rau tus broker (Kauj ruam 2)).

Qhov Broker ib feem yog ua los ntawm Mosquitto, uas tau teeb tsa ntawm Raspberry Pi (Kauj Ruam 3).

Txog Domoticz:

Raws li tau piav qhia ntawm nplooj ntawv nplooj ntawv, Domoticz yog "kev siv tshuab hauv tsev", tso cai rau koj los tswj ntau yam khoom siv thiab tau txais cov lus pom los ntawm ntau txoj cai: MQTT yog ib qho ntawm cov txheej txheem txhawb …

Sai li cov ntaub ntawv mus txog nws (Kauj Ruam 4), koj tuaj yeem txheeb xyuas cov xwm txheej: Hauv qhov xwm txheej ntawm lub thawv ntawv, Kuv tau xaiv xa Telegram ceeb toom (Kauj Ruam 5).

Thaum kawg, Telegram tus neeg siv tau teeb tsa hauv kuv lub xov tooj (thiab kuv tus poj niam ib yam! - Kauj Ruam 6): lub hom phiaj kawg tau mus txog …

Kauj ruam 2: Shematic / thaiv

Shematic / thaiv
Shematic / thaiv
Shematic / thaiv
Shematic / thaiv
Shematic / thaiv
Shematic / thaiv
Shematic / thaiv
Shematic / thaiv

Ib lo lus hais txog analog nyeem:

Ua ntej tshaj plaws, Kuv pom tom qab qee qhov kev tshawb fawb tias Lolin mini D1 (raws li Wemos qub), tau tsim hauv qhov faib hluav taws xob rau tus pin A0 (txiav txim siab 220KΩ rau R1 thiab 100KΩ rau R2 - saib sab xis ntawm cov ntawv txuas), tso cai 3.2 Volts raws li qhov siab tshaj plaws analog input voltage.

Xav txog qhov siab tshaj qhov hluav taws xob los ntawm lub roj teeb yog 4, 2v (txwv los ntawm lub rooj tsav xwm them nqi), thiab theorically, koj tsuas yog xav tau ntxiv tus neeg tawm sab nraud (hauv koob nrog R1) txhawm rau nce qhov siab tshaj qhov hluav taws xob ntau. Tom qab ntawd, yog tias koj ntxiv 100K hauv koob nrog R1, koj yuav muaj qhov txiaj ntsig no:

Vin * R1/(R1+R2) = Vout

4, 2 * 320K/(320K+100K) = 3,2

Hauv kuv qhov kev sib tham, Kuv tau xaiv kom tuaj yeem hloov kho nws tus nqi, yog vim li cas kuv thiaj li nyiam siv qhov hloov pauv hloov pauv hauv kuv qhov Circuit: tej zaum nws yuav tsis muaj txiaj ntsig rau koj, tab sis hauv kuv qhov xwm txheej, kuv teeb nws tus nqi li ntawm 10KΩ kom muaj Tus nqi sib xws hauv Domoticz…

Nco ntsoov tias tus pin A0 muaj 10 qhov kev daws teeb meem: qhov no txhais tau tias hauv koj daim duab, koj qhov kev nyeem analog yuav rov qab tus nqi nruab nrab ntawm 0 txog 1024.

Raws li kuv xav xa ib feem pua tus nqi rau Domoticz, Kuv yuav tsum faib qhov sib piv nyeem tau los ntawm 10, 24.

Kauj Ruam 3: Kev Tswj Fais Fab

Kev Tswj Fais Fab
Kev Tswj Fais Fab
Kev Tswj Fais Fab
Kev Tswj Fais Fab

Tau kawg, Kuv xav kom lub thawv ntawv ua tus kheej. Kom mus txog kuv lub hom phiaj, kuv siv cov ntsiab lus no:

  • Li-Ion 18650 roj teeb ntawm 4000mAh;
  • lub hnub ci vaj huam sib luag uas tuaj yeem xa 6V / 2W;
  • TP4056 Lithium Battery charging board.

Txhawm rau xaiv lub vaj huam sib luag uas tsim nyog tshaj plaws, kuv tau saib qee qhov piv txwv, suav nrog qhov no: hauv qhov piv txwv no, siv 5.5V / 0.66W hnub ci vaj huam sib luag, thiab tej zaum yuav txaus rau lub hom phiaj. Hauv kuv qhov xwm txheej, thiab raws li ESP8266 yuav tsum nyob ON thaum nruab hnub thiab yuav tsum muaj peev xwm khiav lub cav servo kom lub tsev lub ntsej muag rau lub hnub, Kuv tau xaiv lub hnub ci vaj huam sib luag uas muaj zog dua (6V / 2W) - Nws tseem tso cai rau kuv cia siab rau lub caij ntuj no tsaus ntuj thiab hnub pos huab;-)

Tsis tas li, thiab txhawm rau txo qis kev siv hluav taws xob mus rau qhov siab tshaj plaws, Kuv tau xaiv cov xwm txheej hauv qab no:

  • paub tias tus neeg xa ntawv yav dhau los tsuas yog thaum 7 teev sawv ntxov txog 8 teev tsaus ntuj, ESP tau muab tso rau hauv DeepSleep tag hmo;
  • Qhov tseem ceeb tsis dhau ntawm hnub Saturday tav su thiab hnub Monday sawv ntxov: ESP tseem tau muab tso rau hauv DeepSleep hom nyob rau lub sijhawm no.
  • Rau lub sijhawm nruab nrab ntawm 7 teev sawv ntxov txog 8 teev tsaus ntuj, thiab txhawm rau txo qis kev siv hluav taws xob, Kuv yooj yim kaw lub network sib txuas ntawm ESP: network tau rov pib dua tsuas yog tuaj txog ntawm pob khoom lossis ntawv, tsuas yog sijhawm txaus los xa cov ntaub ntawv mus rau Domoticz. Kuv tsis tas yuav ceeb toom tam sim thiab ob peb feeb ntxiv uas yuav tsum tau rov pib dua lub network interface tsis muaj teeb meem!

Qee tus nqi hais txog kev noj nyob rau hauv hom sib txawv uas kuv siv rau Lolin - saib ntawm cov ntawv teev tseg, p18:

  • Hauv ib txwm muaj (nrog RF ua haujlwm), kev siv hluav taws xob tuaj yeem nce mus txog 170mA! Raws li kuv daim ntawv nyob deb li 50 metres los ntawm kuv lub tsev (thiab ntawm qhov txwv ntawm WIFI teeb liab …) Kuv xav tias lub zog siv los tswj kev sib txuas yog nyob ntawm nws qhov siab tshaj …
  • Hauv Modem-pw tsaug zog, kev siv hluav taws xob poob rau 15mA. Tab sis raws li koj tuaj yeem pom hauv cov ntawv teev tseg, nws tsis tau tso tseg kiag li lub modem, raws li ESP yog "tswj kev sib txuas Wi-nkaus uas tsis muaj kev xa cov ntaub ntawv".
  • Hauv Kev pw tsaug zog, lub zog poob rau 20uA.

Txhawm rau kom paub tseeb tias lub wifi tsis nyob twj ywm yam tsis tsim nyog, Kuv nyiam kom xiam nws nrog cov lus txib hauv qab no. Nco tseg ntau ncua () hu… Yog tsis muaj lawv, ESP sib tsoo:

WiFi.disconnect ();

ncua (1000); WiFi.mode (WIFI_OFF); ncua (1000); WiFi.forceSleepBegin (); ncua (1);

Zuag qhia tag nrho, tom qab ob peb hnub ntawm kev ua haujlwm, nws zoo li ua haujlwm thiab tshwj xeeb tshaj yog kom thauj khoom kom raug:

  • qhov no tso cai rau kuv kom khiav lub servomotor txhua teev los tso lub tsev rau hnub ci;
  • Kuv tseem tuaj yeem tso cai rau kuv tus kheej kom rov qhib lub network sib tham txhua teev dhau los xa mus rau Domoticz qib roj teeb.

Kauj Ruam 4: Txhim Kho Cov Hlau nplaum thiab Reeds Contacts

Txhim kho Magnets thiab Reeds Contacts
Txhim kho Magnets thiab Reeds Contacts
Txhim kho Magnets thiab Reeds Contacts
Txhim kho Magnets thiab Reeds Contacts
Txhim kho Magnets thiab Reeds Contacts
Txhim kho Magnets thiab Reeds Contacts

Raws li ib txwm muaj, Kuv siv kuv Proxxon los kho qhov chaw ntawm Reed hauv ib daim ntoo.

Txhawm rau txhim kho qhov sib cuag reed hauv nws lub qhov, Kuv tau siv me ntsis ntawm J-B weld.

Txog cov pob khoom thiab cov khoom tsim tawm, daim kab xev me me, me ntsis ntawm hacksaw, thiab lub hom phiaj tau mus txog!

Qhov zoo ntawm kuv lub thawv ntawv yog tias nws yog hlau, uas pab tswj qhov chaw ntawm cov hlau nplaum kom nws sib cuam tshuam kom raug nrog cov neeg sib tham.

Kauj Ruam 5: Txuas nrog Kuv Lub Tsev Me

Txuas mus rau Kuv Lub Tsev Me
Txuas mus rau Kuv Lub Tsev Me
Txuas mus rau Kuv Lub Tsev Me
Txuas mus rau Kuv Lub Tsev Me

Txhawm rau kom tuaj yeem txuas tau yooj yim thiab txuas lub xov tooj uas mus rau reed hu los ntawm cov ntawv xa mus rau lub tsev, Kuv tau xaiv siv Ethernet txuas.

Koj tuaj yeem siv tus qauv no lossis zoo ib yam li kuv, siv daim qub Arduino Ethernet daim thaiv uas dai rau hauv kuv lub tub rau khoom: Nws tsis raug kev txom nyem, nws ua siab tawv ua ntej pom, nws tuag sai heev ^^

Tsuas yog lo lus hais txog qhov thaiv Arduino Ethernet no: tsis txhob cia siab tias yuav muaj 8 tus tsav sib cais … Cables tau ua khub los ntawm 2 sab hauv daim ntaub thaiv … Nws ua rau kuv vwm rau ntev heev !!!

Kauj Ruam 6: Hauv Tsev…

Hauv Tsev…
Hauv Tsev…
Hauv Tsev…
Hauv Tsev…

Tsuas yog qhov chaw txaus los kho lub roj teeb tuav, teeb tsa lub servo, thiab RJ45 poj niam txuas.

Kauj Ruam 7: Cia Nws Turntable …

Cia Nws Turntable…
Cia Nws Turntable…
Cia Nws Turntable…
Cia Nws Turntable…
Cia Nws Turntable…
Cia Nws Turntable…
Cia Nws Turntable…
Cia Nws Turntable…

Lub hom phiaj yog ua kom nws ntsej muag rau lub hnub…

Txhawm rau kom muaj peev xwm tig tau, Kuv tau siv cov ntsia hlau ntev ua lub qag, nrog qee cov txiv ntseej thiab ob lub npas kabmob …

Txog tam sim no, Kuv siv SG90 servo (lub zog: 1.8kg/cm ntawm 4.8v).

Tig lub tsev (thiab nws ob peb grams) yog txaus. Ntawm qhov tod tes, Kuv tsis paub tseeb tias nws cov yas yas tiv thaiv tau ntev lub sij hawm muaj cua hlob heev uas muaj nyob hauv kuv cheeb tsam.

Kuv xaj lwm qhov (MG995 lub zog: 9.4kg/cm ntawm 4.8v), tsis kim heev ib yam, tab sis nrog cov hlau iav.

Nws yuav yog qhov yuav tsum ua tom ntej thaum kuv tau txais nws: Kuv vam khom kuv cov ntawv sib txuas los ceeb toom rau kuv txog nws tuaj txog!

Kauj Ruam 8: Qee Qhov Kev Xeem

Image
Image

Ob peb sau ntawv:

Cov duab kos no tsuas yog ua raws cov kev hloov pauv ntawm ib teev thaum nruab hnub kom tso cai rau kuv los tswj txoj haujlwm ntawm servo.

  • Nrog SG90: tsis muaj kev xav tau ntxiv, nws tuaj yeem ua haujlwm nrog OUT qhov hluav taws xob los ntawm lub roj teeb tswj.
  • Tab sis, nrog MG 995:

    • Tag nrho lub kaum sab xis ntawm kev sib hloov tsis zoo ib yam (dav dua): Kuv yuav tsum tau siv txoj haujlwm ntxiv los txo nws (Servo_Delta ()).
    • Xav tau DC/DC Kauj Ruam nce ntxiv kom muaj hluav taws xob txaus rau servo … txuas ntxiv mus …

/*

- TEST nrog SG90: tsis muaj kev xav tau ntxiv, nws tuaj yeem ua haujlwm nrog OUT qhov hluav taws xob tuaj ntawm tus tswj lub roj teeb - RAU MG 995: - siv Servo_Delta () muaj nuj nqi… yuav txuas ntxiv mus: */ #include bool Logs = tseeb; Servo tswj; #define PIN_SERVO D2 // servo txoj haujlwm rau: 7h, 8h, 9h, 10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h, 18h, 19h, 20h, 21h // int Arr_Servo_Pos = {177, 173, 163, 148, 133, 118, 100, 80, 61, 41, 28, 15, 2, 2, 2}; int Arr_Servo_Pos = {180, 175, 165, 150, 135, 120, 102, 82, 63, 43, 30, 15, 0, 0, 0}; koj laus; koj pos; koj i; teeb tsa tsis muaj dab tsi () {Serial.begin (115200); } void loop () {rau (kuv = 7; kuv <= 22; kuv ++) {qub = kuv; if (i == 7) {if (Logs) Serial.println ("Positionne le servo pour 7 Heure"); myservo.attach (PIN_SERVO); rau (int index = Arr_Servo_Pos [(sizeof (Arr_Servo_Pos) / sizeof (Arr_Servo_Pos [0])) -1]; index 7 && i = Arr_Servo_Pos [i-7]; index-) {if (Logs) Serial.println (qhov ntsuas); yog (Logs) Serial.print ("Kho tus nqi:"); yog (Logs) Serial.println (Servo_Delta (index)); ncua (200); //myservo.write(Servo_Delta(index)); myservo.write (qhov ntsuas); } ncua (15); myservo.write (Arr_Servo_Pos [i-7]); // rov sau tus nqi kawg kom tsis txhob txav txav thaum datach myservo.detach (); }}} ncua (2000); }} int Servo_Delta (tus nqi) {int Temp_val; Temp_val = (tus nqi*0.80) +9; rov Temp_val; }

Kauj Ruam 9: Lub Tsev Me

Lub Tsev Me
Lub Tsev Me
Lub Tsev Me
Lub Tsev Me
Lub Tsev Me
Lub Tsev Me

Raws li kuv tau hais ua ntej, Kuv tsis tau txais lub tshuab luam ntawv 3D. Yog li kuv txiav txim siab siv cov zaub zaub qub …

Tej zaum nws yuav tsis dhau huab cua ntev, tab sis los ntawm qhov ntawd, kuv yuav muaj sijhawm los txiav txim siab lwm txoj kev daws teeb meem (lossis tus phooj ywg uas muaj lub tshuab luam ntawv 3D): los tiv thaiv ntoo, kuv tau ntxiv ntau cov kua roj vanish nyob txhua qhov chaw …

Koj tuaj yeem pom "daim ntaub zoo nkauj" … Qhov ntawd tshwm sim thaum koj nug koj tus poj niam kom ua txoj haujlwm ^^

Kauj ruam 10: Sketch

Nyob rau hauv kev kawm … Tab sis zoo li yuav ruaj khov

Kuv tseem tab tom ua haujlwm ntawm txoj cai: vim qhov no tsis yog qhov tseeb version, koj cov lus / lus qhia tau txais tos;-)

Qee cov lus hais:

  • Lawv muaj ntau qhov qeeb () hauv cov cai: qhov no yog kom tsis txhob muaj kev sib tsoo ntau ntawm Lolin, tshwj xeeb tshaj yog thaum nres lub network pib …
  • Kuv tsis pom txoj hauv kev yooj yim thiab ntseeg tau kom tau txais lub hnub azimuth: yog vim li cas kuv thiaj kho qhov txiaj ntsig servo hauv kev ua haujlwm ntawm qhov kuv pom … Kuv muaj txoj hauv kev zoo (thiab yooj yim) kom tau nws, kuv txaus siab! ib txoj hauv kev los kawm ntawm no, txawm tias kuv nyiam API online muab rau kuv azimuth ncaj qha raws li hnub tim, teev, thiab thaj chaw nyob …
  • Txog kev pw tsaug zog txuj ci: raws li Lolin yog 32-ntsis Tensilica Processor, nws qhov txiaj ntsig siab tshaj plaws rau 32-ntsis tus lej tsis kos npe yog 4294967295 … Tias yog vim li cas kuv thiaj tsaug zog l'ESP ntau zaus txog 60 feeb …

Hloov kho - 2018-10-08:

Kuv pom tias qhov kev pabcuam muaj ntau qhov txav txav, tshwj xeeb tshaj yog ua ntej txuas (), tshem tawm () thiab txhua lub sijhawm Lolin sawv los ntawm kev tsaug zog tsaug zog ().

Thaum kawm me ntsis ntxiv cov ntawv teev npe, Kuv pom ob yam:

  • Ntawm Lolin cov ntaub ntawv, D4 cov ntawv twb tau txuas nrog BUILTIN_LED…
  • Ntawm ESP8266ex cov ntawv, peb kawm D4 cov zis yog siv ua UART 1/U 1 TXD (Universal Asynchronous Receiver Transmitter). Nws kuj tau teev tseg tias UART1 no yog siv rau kev luam cav.

Los ntawm kev nyeem cov ntaub ntawv no, Kuv pom tau tias D4 cov zis tsis yog lub tswv yim zoo, tshwj xeeb tshaj yog los tswj lub cav servo!

Yog li, tam sim no cov zis siv los tswj cov servomotor yog D2, cov cai hauv qab no tau hloov tshiab raws li.

//****************************************

Hnub tsim tawm: 08/Hnub tsis txaus ntseeg: 08/Version: 0.9.4 Version IDE Arduino: 1.8.6 Upload nrawm: 921600 Hom de carte dans l'IDE: "LOLIN (WEMOS) D1 R2 & mini" Carte lub cev ua haujlwm: LOLIN (WEMOS) D1 R2 & mini (https://www.amazon.fr/gp/product/B01ELFAF1S/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1) Pin Function ESP-8266 Tus Pin Siv Hauv Zos ------- ----------------------------------------------------------------------- ------------------------------------ TX TXD TXD RX RXD RXD A0 Analog input, max 3.3V input A0 Tension d'alimentaion D0 IO GPIO16 Connecté à RST (pour le deep.sleep) D1 IO, SCL GPIO5 D2 IO, SDA GPIO4 Servo moteur D3 IO, 10k Rub-up GPIO0 D4 IO, 10k rub tawm, BUILTIN_LED GPIO2 D5 IO, SCK GPIO14 Reed relève D6 IO, MISO GPIO12 Reed lettre D7 IO, MOSI GPIO13 Reed colis D8 IO, 10k rub-down, SS GPIO15 G GND GND 5V 5V-3V3 3.3V 3.3V RST Reset RST Connecté à D0 (pour le deep.sleep) ****************************************/ #include bool Logs = tseeb; // wifi const char* ssid = "LOL"; const char* password = "LOL"; Tus IP chaw nyob IP (192, 168, 000, 000); IPAddress dns (192, 168, 000, 000); IPAddress rooj vag (192, 168, 000, 000); IPAddress subnet (255, 255, 000, 000); WiFiClient tus thov kev pab; // Servo #include #define PIN_SERVO D2 Servo myservo; // servo txoj haujlwm rau: 7h, 8h, 9h, 10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h, 18h, 19h, 19h, 20h, 21h int Arr_Servo_Pos = {179, 175, 165, 150, 150, 135, 120, 102, 82, 63, 43, 30, 15, 1, 1, 1}; // Reeds #define PIN_SWITCH_OUT D5 byte Old_Switch_State_OUT; byte Hloov_State_OUT; #define PIN_SWITCH_IN_PARCEL D6 byte qub_Switch_State_IN_PARCEL; byte Hloov_State_IN_PARCEL; #define PIN_SWITCH_IN_LETTER D7 byte qub_Switch_State_IN_LETTER; byte Hloov_State_IN_LETTER; unsigned ntev switchPressTime; const unsigned ntev DEBOUCE_TIME = 200; // Analog #define PIN_ANALOG A0 // MQTT #include const char* MQTT_Server_IP = "Koj MQTT chaw nyob"; const int MQTT_Server_Port =; int IDX_Letter_Box =; int IDX_Parcel_Box =; int IDX_Letter_Box_Battery =; PubSubClient ClientMQTT (tus neeg siv khoom); char MQTT_Message_Buff [70]; Txoj hlua MQTT_Pub_String; // Nyuaj ntab vcc; // NTP #include time_t tnow; int Old_Time = 0; int Int_Heures = 0; int Int_Minutes = 0; int Int_Sleep_Duration = 63; teeb tsa tsis muaj dab tsi () {Serial.begin (115200); network (muaj tseeb); pinMode (PIN_SWITCH_OUT, INPUT_PULLUP); Old_Switch_State_OUT = digitalRead (PIN_SWITCH_OUT); pinMode (PIN_SWITCH_IN_LETTER, INPUT_PULLUP); Old_Switch_State_IN_LETTER = digitalRead (PIN_SWITCH_IN_LETTER); pinMode (PIN_SWITCH_IN_PARCEL, INPUT_PULLUP); Old_Switch_State_IN_PARCEL = digitalRead (PIN_SWITCH_IN_PARCEL); SendBatteryLevel (); network (cuav); // NTP teeb tnow = sijhawm (nullptr); Int_Heures = Txoj hlua (ctime (& tnow)). Substring (11, 13).toInt (); Int_Minutes = Txoj hlua (ctime (& tnow)). Substring (14, 16).toInt (); // Deeps pw rau hmo ntuj yog tias (! ((Int_Heures> = 7) && (Int_Heures <= 20))) {Serial.print ("Pw tsaug zog la la nuit ("); Serial.print (Int_Sleep_Duration - Int_Minutes); Serial. println ("feeb)"); pw tsaug zog (Int_Sleep_Duration - Int_Minutes); }} void loop () {// NTP teeb tnow = sijhawm (nullptr); Int_Heures = Txoj hlua (ctime (& tnow)). Substring (11, 13).toInt (); Int_Minutes = Txoj hlua (ctime (& tnow)). Substring (14, 16).toInt (); //Serial.println(String(ctime(&tnow))); //Serial.println ("Heure:" + String (ctime (& tnow)). Substring (11, 13)); //Serial.println (String (ctime (& tnow)). Substring (11, 13).toInt ()); // Servo tswj yog (Old_Time! = Int_Heures) {Old_Time = Int_Heures; if (Int_Heures == 7) {if (Logs) Serial.println ("Positionne le servo pour 7 Heure"); myservo.attach (PIN_SERVO); rau (int index = Arr_Servo_Pos [(sizeof (Arr_Servo_Pos) / sizeof (Arr_Servo_Pos [0])) -1]; index 7 && Int_Heures = Arr_Servo_Pos [Int_Heures-7]; index-) {if (Logs) Serial.println (qhov ntsuas); ncua (200); myservo.write (qhov ntsuas); } ncua (15); myservo.write (Arr_Servo_Pos [Int_Heures-7]); // rov sau tus nqi kawg kom tsis txhob txav txav thaum tshem myservo.detach (); } network (tseeb); SendBatteryLevel (); network (cuav); }}} // Deeps pw yog hnub Saturday tom qab 13h yog ((String (ctime (& tnow)). Substring (0, 3) == "Sat") &&& Int_Heures> = 13)) {if (Logs) Serial.print ("Pw tsaug zog pour le samedi aprés midi ("); yog (Logs) Serial.print (Int_Sleep_Duration - Int_Minutes); yog (Logs) Serial.println ("feeb)"); pw tsaug zog (Int_Sleep_Duration - Int_Minutes); } // Deeps pw yog hnub sunday yog (String (ctime (& tnow)). Substring (0, 3) == "Sun") {if (Logs) Serial.print ("Sleep pour le dimanche ("); if (Logs) Serial.print (Int_Sleep_Duration - Int_Minutes); yog (Logs) Serial.println ("feeb)"); pw tsaug zog (Int_Sleep_Duration - Int_Minutes); } // Reeds kev tswj Switch_State_OUT = digitalRead (PIN_SWITCH_OUT); yog (Switch_State_OUT! = Old_Switch_State_OUT) {yog (millis () - switchPressTime> = DEBOUCE_TIME) {switchPressTime = millis (); yog (Switch_State_OUT == HIGH) {Serial.println ("kev xa xov xa tuaj!"); network (muaj tseeb); ncua (5000); MQTT_Pubilsh (IDX_Letter_Box, 0, "0"); ncua (5000); MQTT_Pubilsh (IDX_Parcel_Box, 0, "0"); ncua (5000); network (cuav); }} Old_Switch_State_OUT = Switch_State_OUT; } Switch_State_IN_LETTER = digitalRead (PIN_SWITCH_IN_LETTER); yog (Switch_State_IN_LETTER! = Old_Switch_State_IN_LETTER) {yog (millis () - switchPressTime> = DEBOUCE_TIME) {switchPressTime = millis (); yog (Switch_State_IN_LETTER == HIGH) {Serial.println ("xa tuaj tuaj!"); network (muaj tseeb); ncua (5000); MQTT_Pubilsh (IDX_Letter_Box, 1, "Courrier"); ncua (5000); network (cuav); }} Old_Switch_State_IN_LETTER = Hloov_State_IN_LETTER; } Switch_State_IN_PARCEL = digitalRead (PIN_SWITCH_IN_PARCEL); yog (Switch_State_IN_PARCEL! = Old_Switch_State_IN_PARCEL) {yog (millis () - switchPressTime> = DEBOUCE_TIME) {switchPressTime = millis (); yog (Switch_State_IN_PARCEL == HIGH) {Serial.println ("colis arrivé!"); network (muaj tseeb); ncua (5000); MQTT_Pubilsh (IDX_Parcel_Box, 1, "Colis"); ncua (5000); network (cuav); }} Old_Switch_State_IN_PARCEL = Hloov_State_IN_PARCEL; }} void SendBatteryLevel () {ncua (5000); vcc = analogRead (PIN_ANALOG) /10.24; if (Logs) Serial.println ("\ tTension relevée:" + String (vcc, 0)); MQTT_Pubilsh (IDX_Letter_Box_Battery, 0, Txoj hlua (vcc, 0)); ncua (5000); } void pw tsaug zog (int Min_Duration) {ESP.deepSleep (Min_Duration * 60e6); } void network (bool UpDown) {yog (UpDown) {Serial.print ("Network pib"); WiFi.forceSleepWake (); ncua (1); // init WIFI WiFi.config (ip, dns, rooj vag, subnet); WiFi.begin (ssid, password); thaum (WiFi.status ()! = WL_CONNECTED) {ncua (500); Serial.print ("."); } ncua (5000); Serial.println ("."); Serial.print ("\ tConnected - IP chaw nyob:"); Serial.println (WiFi.localIP ()); // init MQTT ClientMQTT.setServer (MQTT_Server_IP, MQTT_Server_Port); // Init NTP Serial.print ("\ tTime Synch."); configTime (0, 0," fr.pool.ntp.org "); setenv (" TZ "," CET-1CEST, M3.5.0, M10.5.0/3 ", 0); thaum (sijhawm (nullptr) <= 100000) {Serial.print ("."); Ncua (100);} Serial.println (".");} Lwm {Serial.println ("Network nres."); WiFi.disconnect (); ncua (1000); WiFi.mode (WIFI_OFF); ncua (1000); WiFi.forceSleepBegin (); ncua (1);}} void txuas dua () {thaum (! ClientMQTT.connected ()) {Serial.print (" / simTxhua qhov txuas MQTT… "); // Sim txuas mus yog (ClientMQTT.connect (" ESP8266ClientBAL ")) {Serial.println (" txuas ");} lwm {Serial.print (" ua tsis tiav, rc = "); Serial.print (ClientMQTT.state ()); Serial.println ("sim dua hauv 5 vib nas this"); // Tos 5 vib nas this ua ntej rov sim qeeb (5000);}}} tsis muaj nuj nqis MQTT_Pubilsh (int Int_IDX, int N_Value, hlua S_Value) (yog (! (Int_IDX) + ", \" Roj teeb / ":" + String (vcc, 0) + ", \" nvalue / ":" + N_Value + ", \" svalue / ": \" " + S_Value +" / "}"; MQTT_Pub_String.toCharArray (MQTT_Message_Buff, MQTT_Pub_String.length ()+1); ClientMQTT.publish ("domoticz/hauv", MQTT_Message_Buff); ClientMQTT.disconnect (); }

Kauj ruam 11: Domoticz

Domoticz
Domoticz
Domoticz
Domoticz
Domoticz
Domoticz

Hauv Domoticz:

Rau kev siv dav:

  • Tsim ob "Dummy (Tsis muaj dab tsi, siv rau kev hloov pauv virtual)":

    1. Thawj rau cov ntawv…
    2. Qhov thib ob rau pob khoom…
  • Rau txhua tus ntawm lawv, qhia tus kheej cov ntawv ceeb toom;
  • Tau kawg, koj yuav tsum teeb koj Tegegram token.

Xaiv tau:

Koj tuaj yeem ntxiv "Qhov ntsuas hluav taws xob" los saib xyuas koj qib roj teeb.

Cov Lus Qhia: ntawm no koj tuaj yeem pom ntau ntau cov cim kev cai pub dawb …

Kauj Ruam 12: Xaus

Xaus
Xaus
Xaus
Xaus

Vam tias Cov Lus Qhia no yuav pab koj:

  • seb puas yuav ua koj tus kheej cov ntawv txuas nrog;
  • lossis tsuas yog muab qee lub tswv yim rau koj cov phiaj xwm!

Yog tias koj muaj tswv yim rau kev txhim kho, Kuv mloog!

PS: thov txim rau kuv cov lus Askiv, Google txhais lus pab kuv ntau tab sis tej zaum tsis zoo tag nrho;-)

Pom zoo: