Cov txheej txheem:

IoT Mains Controller. Ntu 9: IoT, Kev Ua Haujlwm Hauv Tsev: 10 Kauj Ruam (nrog Duab)
IoT Mains Controller. Ntu 9: IoT, Kev Ua Haujlwm Hauv Tsev: 10 Kauj Ruam (nrog Duab)

Video: IoT Mains Controller. Ntu 9: IoT, Kev Ua Haujlwm Hauv Tsev: 10 Kauj Ruam (nrog Duab)

Video: IoT Mains Controller. Ntu 9: IoT, Kev Ua Haujlwm Hauv Tsev: 10 Kauj Ruam (nrog Duab)
Video: Технический разговор TUDev с профессором Борой Озкан - Финтех и будущее финансов 2024, Hlis ntuj nqeg
Anonim
IoT Mains Controller. Ntu 9: IoT, Kev Ua Haujlwm Hauv Tsev
IoT Mains Controller. Ntu 9: IoT, Kev Ua Haujlwm Hauv Tsev

Tsis lees paub

Nyeem qhov no thawj zaug

Cov lus qhia ntxaws ntxaws txog qhov haujlwm uas siv lub zog loj (hauv qhov piv txwv UK 240VAC RMS), txawm tias txhua qhov kev saib xyuas tau raug coj los siv kev nyab xeeb thiab kev tsim qauv zoo muaj ib txwm muaj kev pheej hmoo ua rau muaj hluav taws xob ua rau tuag thaum ua haujlwm nrog cov khoom siv hluav taws xob no thiab rau uas tus sau tsis tuaj yeem lees paub ib qho kev lav phib xaub yog raug mob lossis ua rau muaj kev puas tsuaj rau vaj tse thaum ua raws nws cov ntsiab lus. Thiaj li, koj ua qhov haujlwm no ntawm koj tus kheej txoj kev pheej hmoo.

Zaj lus piv txwv

Kab lus no, thib 9 hauv kab lus ntawm kev siv tshuab hauv tsev, cov ntaub ntawv yuav tsim thiab koom ua ke Sonoff 10A IoT lub tshuab hluav taws xob tseem ceeb rau hauv kev siv tshuab hauv tsev uas muaj tam sim no suav nrog txhua qhov tsim nyog software ua haujlwm kom ua tiav kev xa tawm tau zoo hauv ib puag ncig hauv tsev.

Taw qhia

Raws li tau hais los saum no Cov lus qhia ntxaws yuav ua li cas thiab ua ke nrog IoT lub ntsiab tswj hwm siv Sonoff 10A los ntawm iTead. Cov cuab yeej nws tus kheej tau hais tias yog ntsuas rau 10amps @ 90 ~ 250VAC, txawm li cas los xij qhov kev nqis tes ua de-tus nqi nws rau ntawm 5amps ntawm lub fuse ntsaws muab rau UK UK cov khoom tseem ceeb ntawm 240VAC RMS.

Tus txheej txheem tsim ua ke ua ke tsis sib xws rau hauv MQTT/OpenHAB raws IoT network ntxaws ntxaws hauv kab ntawv no ntawm kev tsim kho vaj tsev hauv tsev ntawm kev rov siv cov cai coj los ntawm no. Nws kuj tseem tuaj yeem daws qhov poob ntawm ib qho IoT network ntsiab lus thiab muaj peev xwm ua haujlwm ib leeg. Whilst nyob rau hauv hom ib leeg, kev tswj hwm lub cuab yeej ua tiav los ntawm kev yooj yim nias lub khawm tswj nyob rau sab saum toj ntawm lub thawv ntawv, uas toggles cov khoom xa mus ntxiv.

Txhawm rau ua kom muaj kev tswj hwm hauv cheeb tsam ntawm Sonoff cov cuab yeej, GPIO14 raug coj tawm ntawm rooj plaub thiab siv los ua lub hauv paus ntsiab lus. Txhawm rau kom muaj kev nyab xeeb, cov tswv yim no tau pub los ntawm cov kab hluav taws xob opto-coupler thiab nyob hauv lub thawv yas xws li tsis muaj sijhawm yog tus neeg teb xov tooj nthuav tawm lub zog hluav taws xob.

Thaum kawg, kab lus tseem piav qhia yuav ua li cas rov ua haujlwm ESP8266 cov cuab yeej hauv Sonoff 10A siv Arduino IDE thiab muab cov ntsiab lus tseem ceeb ntawm lub cuab yeej uas tuaj yeem siv tau rau kev ntseeg tau lub hom phiaj phiaj xwm.

Yam twg kuv xav tau?

Sonoff Mains Tswj

  1. 1 tawm Sonoff 10A ntawm no
  2. 1 tawm 7805L 5v qhov ntsuas hluav taws xob ntawm no
  3. 1 tawm 240/6VAC 1.5VA Transformer ntawm no
  4. 2 tawm 0.1 ceramic capacitors ntawm no
  5. 1 tawm 1000uF @25v Electrolytic Capacitor ntawm no
  6. 1 tawm Choj rectifier 2W01 ntawm no
  7. 2 tawm 4K7 resistors ntawm no
  8. 1 tawm 330R resistor ntawm no
  9. 1 tawm SPST khawm ntawm no
  10. 1 tawm Mulitcomp BM12W ABS Enclosure ntawm no
  11. 1 tawm TIL111 opto-coupler ntawm no
  12. 1 tawm ntawm 3-Txoj Kev davhlau ya nyob twg thaiv ntawm no
  13. 1 tawm 2-Txoj kev coded molex txuas ntawm no/ntawm no
  14. 1 tawm 3-Txoj kev coded molex txuas ntawm no/ntawm no
  15. 1 tawm 5-Txoj kev coded molex txuas ntawm no/ntawm no
  16. 1 tawm 5-Txoj Kev molex pins ntawm no
  17. 1 tawm Winbond SPI Flash (W25Q32FVSIG) ntawm no
  18. 1 tawm 20mm fuse yas dhos + hau ntawm no
  19. 1 tawm 20mm nrawm tshuab 500mA fuse ntawm no
  20. 2 tawm Polyamide cable qog ntawm no
  21. 1 tawm UK Mains plug (BS1363/A) ntawm no
  22. 1 tawm UK lub qhov (socket) BS1363/A) ntawm no
  23. 7 tawm M3 16mm CS nylon screws, (suav nrog 10 tawm txiv ntoo) ntawm no/ntawm no
  24. 2 tawm Zip kev sib txuas ntawm no
  25. 1 tawm ntawm veroboard (0.1 "suab) ntawm no
  26. 1 tawm Ntau qhov ntev 22swg tinned tooj liab hlau ntawm no
  27. 1 tawm 3M Dawb UK lub xov tooj tseem ceeb ntawm no
  28. 10 tawm Molex qhov ntsaws qhov ntsaws ntawm no

Sonoff Tus Kws Ua Haujlwm

  1. 1 tawm LD33CV 3v3 qhov ntsuas hluav taws xob ntawm no
  2. 1 tawm TO-220 heatsink ntawm no
  3. 1 tawm Heatsink muab tshuaj txhuam ntawm no
  4. 1 tawm 10uF @16v Electrolytic capacitor ntawm no
  5. 1 tawm 0.1 ceramic capacitor ntawm no
  6. 1 tawm SPDT khawm ntawm no
  7. 1 tawm 4K7 resistor ntawm no
  8. 1 tawm 2-Txoj kev coded molex txuas ntawm no/ntawm no
  9. 1 tawm 3-Txoj kev coded molex txuas ntawm no/ntawm no
  10. 5 tawm Molex qhov ntsaws qhov ntsaws ntawm no
  11. 1 tawm 6-Txoj Kev molex lub qhov (socket) ntawm no
  12. 1 tawm SPST khawm ntawm no
  13. 1 tawm 2.1mm PSU lub qhov (socket) ntawm no
  14. 1 tawm ntawm veroboard (0.1 "suab) ntawm no
  15. 1 tawm USB rau cov txuas txuas (FTDI) ntawm no

Kuv xav tau software twg?

  1. Arduino IDE 1.6.9 ntawm no
  2. Arduino IDE teeb tsa los ua haujlwm ESP8266. Saib ntawm no; Teeb tsa Arduino IDE rau Program ESP8266-01

Kuv xav tau cov cuab yeej twg?

  1. Soldering Hlau,
  2. Laum & ntau yam khoom me me (suav nrog lub qhov txiav tawm rau cov qog qog thiab tswj khawm),
  3. Screwdrivers (ntau yam),
  4. Kho qhov dav dav (ob qho tawm, lub puab tsaig dav> 25mm, rau cov qog qog),
  5. Cov ntaub ntawv (ntau yam),
  6. Ruaj khov kho,
  7. Rab phom,
  8. DMM (nyiam dua CAT IV).

Kuv xav tau txuj ci dab tsi?

  1. Kev nkag siab zoo ntawm cov khoom siv hluav taws xob thiab kev nyab xeeb hluav taws xob hauv tsev/tsim/thaiv thiab lwm yam,
  2. Paub txog Arduino thiab nws yog IDE,
  3. Kev tsim cov txuj ci zoo (cov laug, ua ntawv, drilling thiab lwm yam),
  4. Ib txhia ua siab ntev,
  5. Qee qhov nkag siab txog koj lub network hauv tsev.

Cov ncauj lus npog

  • Taw qhia
  • Txheej txheem cej luam
  • Sonoff RetroMods
  • Kev Tsim Kho thiab Kev Sib Tham Cov Lus Qhia
  • Sonoff Programming Adapter
  • Software System Txheej Txheem
  • Software Txheej Txheem
  • OpenHAB Configuration
  • Kuaj Koj IoT Device
  • Xaus
  • References Siv

Series Txuas

Ntu 8: WiFi IoT Kub thiab Vaum Sensor. Ntu: 8 IoT, Kev Siv Tsev Hauv Tsev

Ntu 10: IR Kev Tswj Chaw Taws Teeb Ntawm IoT. Ntu 10 IoT, Kev Siv Tsev Hauv Tsev

Kauj Ruam 1: Txheej Txheem Txheej Txheem

Txheej txheem cej luam
Txheej txheem cej luam
Txheej txheem cej luam
Txheej txheem cej luam
Txheej txheem cej luam
Txheej txheem cej luam
Txheej txheem cej luam
Txheej txheem cej luam

Txheej txheem cej luam

Raws li tau hais hauv cov lus taw qhia saum toj no, txhawm rau txhawm rau tuaj yeem hloov pauv lub tshuab hluav taws xob rau thiab tawm hauv zos cov lus tawm tswv yim rau Sonoff's on-board ESP8266 tau xav tau. Kev qhia tawm qhov kev tawm tswv yim sab nraud xav kom Sonoff ABS cov ntaub thaiv raug ua txhaum thiab yog li tsim kom muaj kev phom sij txaus ntshai. Txhawm rau kov yeej qhov no kuv siv qhov kev cais qhov muag xws li tsis muaj peev xwm kis tau hluav taws xob sab nraud ntawm lub tshuab hluav taws xob tswj qhov system.

Dab tsi hauv qab no yog kev piav qhia ntawm kev sib cais opto-circuitry (hauv daim duab 1 saum toj no).

Cov lus qhia hauv Circuit

Qhov kev sib cais opto tau txais nws cov khoom siv ncaj qha los ntawm lub hauv paus tau thov rau chav tsev. 240VAC RMS tau thov rau theem qis/cais kev hloov pauv TR1 ntawm J1 pheonix hu rau MKDSN2, 5/3-5.08 polyamide 3-Way davhlau ya nyob twg ntsuas ntawm 16A ntawm 400V tuaj yeem nqa cov kab ntawm 2.5mm (sq) CSA thiab F1 a 500mA 20mm ceev tshuab fuse. 6VAC muaj nyob rau ntawm qhov txuas thib ob ntawm TR1 yog nthwv dej kho tau los ntawm tus choj diode B1.

Qhov kev hloov pauv tag nrho yoj tom qab no tau ruaj khov thiab tswj hwm los ntawm C1, C2 C3, R3 thiab IC1 7805L series shunt tus tswj hwm, muab qhov zoo, huv 5v muab cov tsheb nqaj hlau.

5v txoj kev tsheb nqaj hlau yog tom qab ntawd siv los tswj cov tswv yim rau OK1 TIL111 opto-isolator ntawm sab nrauv sab nrauv teeb tsa SPST khawm dawb txuas nrog hla J3. Qhov tso tawm ntawm TIL111 tau txuas nrog Sonoff GPIO14 cov tswv yim ntawm R2 a 4K7 rub tawm tus tiv thaiv. Yog li zoo dua 340V ntawm kev rho tawm yog ua tiav (piv txwv li Peak voltage = (240VAC*sqroot (2))).

Kauj ruam 2: Sonoff RetroMods

Sonoff RetroMods
Sonoff RetroMods
Sonoff RetroMods
Sonoff RetroMods
Sonoff RetroMods
Sonoff RetroMods

Txhawm rau koom ua ke Sonoff 10A lub cuab yeej nws yog qhov tsim nyog los ua qee qhov kev hloov kho yav tom ntej.

Thawj yog ntxiv 5-txoj kev 0.1 lub suab molex txuas raws li tau hais hauv daim duab 1 saum toj no. Qhov no tso cai nkag mus rau GPIO14 ntawm Sonoff thaum lub npog tiv thaiv tau hloov pauv zoo li hauv duab 2 thiab 3 saum toj no.

Txawm hais tias tsis tau hais los saum toj no Kuv tseem tau nthuav tawm cov kab ntawv TX/RX cov kab ntawv kom tso cai rau hauv-qhov phiaj xwm (xa mus rau cable sam SK1..3 hauv Kauj Ruam 1 saum toj no).

Qhov kev hloov kho zaum thib ob yog txhawm rau nce qhov loj me ntawm SPI Flash ntaus ntawv los ntawm lub neej ntawd 1MByte mus rau 4MBytes, qhov no yog tso cai rau chav txaus rau IoT web server cov ntaub ntawv los tuav hauv SPIFFS.

Kuv yuav lub SMD SPI flash device (W25Q32FVSIG) los ntawm Ebay ntawm no

Txhawm rau hloov lub flash Kuv tshem tawm ib ntus Sonoff LED zoo li hauv daim duab 4 kom nkag tau zoo dua rau SMD ntaus ntawv. Txhawm rau de-solder lub flash Kuv siv rab phom cua sov raws li qhia hauv daim duab 5 saum toj no. Tom qab ntawd rov muag dua ob qho tib si 4MByte Flash thiab LED feem (daim duab 6).

Kauj Ruam 3: Kev Tsim Kho thiab Cov Lus Qhia Ua Ke

Kev Tsim Kho thiab Kev Sib Tham Cov Lus Qhia
Kev Tsim Kho thiab Kev Sib Tham Cov Lus Qhia
Kev Tsim Kho thiab Kev Sib Tham Cov Lus Qhia
Kev Tsim Kho thiab Kev Sib Tham Cov Lus Qhia
Kev Tsim Kho thiab Kev Sib Tham Cov Lus Qhia
Kev Tsim Kho thiab Kev Sib Tham Cov Lus Qhia
Kev Tsim Kho thiab Kev Sib Tham Cov Lus Qhia
Kev Tsim Kho thiab Kev Sib Tham Cov Lus Qhia

Kuv tau kaw cov tswj hluav taws xob hauv Mulitcomp BM12W ABS Box (Daim duab 1 saum toj no). Cov ntaub ntawv no tau cais cov tooj dag M3 tso rau tso rau ntau qhov nkag mus rau hauv chav tsev yam tsis muaj kev cuam tshuam cov xov txuas xws li lub fuse sab hauv tuaj yeem hloov tau yog tias tsim nyog lossis kev tshuaj xyuas sab hauv tuaj yeem ua rau lub sijhawm (tib yam tsis tuaj yeem hais rau Sonoff ntaus ntawv, uas ua tau zoo ib zaug tsuas yog kaw siv tus kheej tappers).

Kev pab daws teeb meem thawj zaug rau lub hauv paus nqa nqa cov xov hluav taws xob tau ua tiav ntawm M16 Nylon/Polyamide 6/6 cov kab hluav taws xob dawb txhawb nqa cable OD Min/Max 5mm/10mm.

Kev kho kab mob siab thib ob yog dhau los ntawm ib tus zauv khi khi rau ntawm txoj hlua yuav tsum tau siv ntau txoj hlua khi thiab cov kab txuas tsis ua haujlwm, txoj hlua khi yuav khaws cov hlua nyob hauv qhov chaw.

Txhawm rau kom haum cov kab hluav taws xob thiab muab qhov chaw txaus los teeb tsa Sonoff thiab kho qhov muag-cais cov khoom siv hluav taws xob Kuv hle sab hauv PCB mounting tav raws li tau hais los saum no (Duab 2).

Txhua lub tshuab hluav taws xob tau ruaj ntseg teeb tsa ntawm M3 nylon CS screws kom ntseeg tau tias muaj kev sib cais nrog sab nrauv ntawm lub thawv ntawv. Cov cuab yeej hluav taws xob opto-cais tau teeb tsa nrog 5 kho cov ntsiab lus kom ntseeg tau lub suab lub zog yuav tsum tau ua rau lub tsev poob qis, yog li tiv thaiv qhov loj ntawm kev sib cais hloov pauv los ntawm kev ua txhaum lub veroboard Circuit Court.

Kev muab khoom rau chav tsev tau ua tiav ntawm UK Tus qauv xim xim dawb 3 core PVC insulated mains multi-strand (32/0.2mm sq) cable 1mm (sq) CSA. nrog OD ntawm 7.2mm muaj peev xwm nqa 10A.

Chav nyob tau txuas nrog UK cov khoom siv hluav taws xob (240VAC RMS) ntawm tus qauv 3 tus pin kev nyab xeeb ntsaws (BS 1363/A) pom zoo. Lub ntsaws tau fused ntawm 5A.

Txhua qhov hluav taws xob xa hluav taws xob txuas mus rau qhov kev sib txuas opto-isolation tau txuas nrog ntawm pheonix hu rau MKDSN2, 5/3-5.08 polyamide terminals ntsuas ntawm 16A ntawm 400V tuaj yeem nqa cov kab ntawm 2.5 hli (sq) CSA, yog li muab cov peev txheej txaus rau ob txoj hlua hauv txhua txoj haujlwm.

Tsis muaj cov kab hluav taws xob tau xaim, tsuas yog sib tw los tiv thaiv kev ua si ntawm cov cores ua ntej tso rau hauv qhov txuas txuas. Tinning cov xov hluav taws xob yog ib qho kev phom sij raws li cov laug 'so' dhau lub sijhawm nws thiaj li ua rau lub xov tooj poob hauv qhov txuas txuas.

Nco tseg:

  • OD = Sab nraum txoj kab uas hla.
  • VAC = Volts Alternating Tam sim no
  • RMS = Root Mean Square
  • CSA = Hla Sectional Area
  • CS = Counter Sunk

Kauj Ruam 4: Sonoff Programming Adapter

Sonoff Programming Adapter
Sonoff Programming Adapter
Sonoff Programming Adapter
Sonoff Programming Adapter
Sonoff Programming Adapter
Sonoff Programming Adapter
Sonoff Programming Adapter
Sonoff Programming Adapter

Muaj ob txoj hauv kev los txiav txim siab thaum rov tsim kho lub Sonoff 10A ntawm Arduino IDE;

  1. Kho koj li Arduino IDE rau program ESP8266,
  2. Txoj cai ntawm kev ua haujlwm kho vajtse nws tus kheej.

Kho koj li Arduino IDE rau program ESP8266

Txhawm rau teeb tsa koj li Ardino IDE ua raws cov lus qhia ntawm no teeb tsa Arduino IDE rau Txoj Haujlwm ESP8266-01

Khoos phis tawj khoos phis tawj

Nov yog txheej txheem txheej txheem ntau yam zoo li hauv txhua kis nrog ESP8266. Ntawm no, Sonoff lub zog tau siv rau lub rooj tsavxwm ntawm sab nraud ruaj khov 3v3 DC khoom thiab TSIS los ntawm cov khoom siv hluav taws xob. USB rau cov khoom siv yuav tsum tau xa thiab txais cov ntaub ntawv mus thiab los ntawm Sonoff. Txuas TX thiab RX raws li qhia hauv Pic 2 & 4.

Cov Txheej Txheem Txheej Txheem (dav dav)

  1. Ua ntej kom ntseeg tau tias tsis muaj lub zog hluav taws xob sab nraud siv rau Sonoff,
  2. Nias thiab tuav lub pob ntawm Sonoff ntaus ntawv. (daim duab 1 saum toj no, cim rov nyem khawm),
  3. Thov sab nraud DC 3v3 muab rau tus pin 1. (daim duab 2 saum toj no),
  4. Tso lub Sonoff khawm,
  5. Tam sim no lub cuab yeej tuaj yeem rov ua dua tshiab hauv txoj kev ib txwm dhau los ntawm Arduino IDE.

Txhawm rau ua kom yooj yim me ntsis Kuv tsim cov phiaj xwm ntaus ntawv saum toj no (duab 3 thiab 4) uas cuam tshuam rau Sonoff ntawm txoj hlua khi SK1 … 3 (raws li tau piav qhia hauv Kauj Ruam Qhia 1.). Qhov no tau tso cai rau kev yooj yim dua ntawm ESP8266. Nws kuj tseem muab txoj hauv kev ntsuas GPIO14 raws li kev nkag los ntawm kev siv R1 a 4K7 rub tawm tus tiv thaiv thiab khawm S1.

Siv lub tshuab ntaus ntawv saum toj no (Duab 3 & 4) Cov Txheej Txheem Txheej Txheem yog,

  1. Nias thiab tuav khawm rov nyem rau ntawm Sonoff,
  2. Pulse cov khoom siv 3v3 los ntawm ib ntus nias S2,
  3. Tso lub khawm rov nyem,
  4. Tam sim no lub cuab yeej tuaj yeem tsim kho.

CEEB TOOM - CEEB TOOM

Nyob rau hauv tsis muaj xwm txheej yuav tsum tau muab lub zog los ntawm Mains thaum lub sijhawm Sonoff rov ua haujlwm

Kauj Ruam 5: Txheej Txheem Txheej Txheem Software

Software System Txheej Txheem
Software System Txheej Txheem
Software System Txheej Txheem
Software System Txheej Txheem

Qhov IoT Mains Controller ntaus ntawv rau feem ntau muaj tib lub rau yam tseem ceeb software sib xws raws li qhia hauv WiFi IoT Kub thiab Vaum Sensor. Ntu: 8 IoT, Kev Siv Tsev Hauv Tsev thiab qhia hauv daim duab 1 saum toj no, nrog qee qhov kev hloov kho.

SPIFFS

Nov yog (hloov kho rau 4MBytes) ntawm-board SPI Flash Filing System thiab siv los tuav cov ntaub ntawv hauv qab no (saib daim duab 2 saum toj no);

  • Icons thiab 'Mains Controller Configuration Home Page' html: Ua los ntawm IoT ntaus ntawv thaum nws tsis muaj peev xwm txuas rau koj li IoT WiFi network (feem ntau yog los ntawm cov ntaub ntawv ruaj ntseg tsis raug) thiab muab cov neeg siv nrog txoj hauv kev teeb tsa lub hauv paus tswj tsis tau qhov xav tau rov ua haujlwm lossis tshaj tawm cov ntsiab lus SPIFFS tshiab.
  • Cov Ntaub Ntawv Ruaj Ntseg: Qhov no tuav cov ntaub ntawv siv los ntawm IoT ntaus ntawv txuas rau koj li IoT WiFi network thiab MQTT Broker. Cov ntaub ntawv xa los ntawm 'Mains Controller Configuration Home Page' tau sau rau hauv cov ntawv no ('secvals.txt').

Nco tseg: Txhawm rau teeb tsa lub cuab yeej pom ntawm no kom paub meej txog yuav siv SPIFFS nrog Arduino IDE li cas.

mDNS neeg rau zaub mov

Qhov kev ua haujlwm no tau thov thaum IoT lub cuab yeej ua tsis tau txuas rau koj li WiFi network ua chaw nres tsheb WiFi thiab hloov pauv tau dhau los ua WiFi nkag mus rau qee yam uas zoo ib yam li WiFi router hauv tsev. Nyob rau hauv rooj plaub ntawm tus router koj yuav ib txwm txuas rau nws los ntawm kev nkag mus rau IP Chaw nyob ntawm qee yam xws li 192.168.1.1 (feem ntau luam tawm ntawm daim ntawv lo sau rau ntawm lub npov) ncaj qha rau hauv koj tus browser URL bar qhov twg koj yuav tau txais tus ID nkag mus nplooj ntawv tus username thiab password tso cai rau koj teeb tsa lub cuab yeej. Rau ESP8266 hauv AP hom (Access Point mode) lub cuab yeej tsis raug rau IP chaw nyob 192.168.4.1, txawm li cas los nrog mDNS server khiav koj tsuas yog yuav tsum nkag mus rau tib neeg tus phooj ywg lub npe 'MAINSCON.local' rau hauv qhov browser URL bar kom pom 'Mains Controller Configuration Home Page'.

MQTT Cov Neeg Siv Khoom

MQTT tus neeg siv khoom muab txhua txoj haujlwm tsim nyog rau; txuas rau koj IoT network MQTT broker, sau npe rau cov ncauj lus uas koj xaiv thiab tshaj tawm cov nyiaj them rau cov ncauj lus. Hauv ntej nws hais txog IoT cov haujlwm tseem ceeb.

HTTP Web Server

Raws li tau hais los saud, yog tias IoT lub cuab yeej tsis tuaj yeem txuas rau WiFi network uas nws SSID, P/W thiab lwm yam tau hais tseg hauv Cov Ntaub Ntawv Ruaj Ntseg Cov Ntaub Ntawv tuav tseg hauv SPIFFS lub cuab yeej yuav dhau los ua Access Point. Thaum txuas nrog WiFi network muab los ntawm Kev Nkag Mus, qhov muaj ntawm HTTP Web Server tso cai rau koj txuas ncaj qha rau lub cuab yeej thiab hloov nws cov kev teeb tsa los ntawm kev siv HTTP Web Browser nws lub hom phiaj yog los ua haujlwm 'Mains Controller Configuration Home Page 'nplooj ntawv web uas tseem muaj nyob hauv SPIFFS.

Chaw nres tsheb WiFi

Lub luag haujlwm no ua rau IoT ntaus ntawv muaj peev xwm txuas mus rau lub network WiFi hauv tsev siv cov ntsuas hauv Cov Ntaub Ntawv Kev Ruaj Ntseg, tsis muaj qhov no koj li cuab yeej IoT yuav tsis tuaj yeem sau npe/tshaj tawm rau MQTT Broker

WiFi Access Point

Lub peev xwm dhau los ua WiFi Access Point yog lub ntsiab lus uas IoT ntaus ntawv tso cai rau koj txuas rau nws thiab teeb tsa kev hloov pauv ntawm lub chaw nres tsheb WiFi thiab browser (xws li Safari ntawm Apple iPad). Qhov chaw nkag no tshaj tawm SSID = "MAINSCON" + 6 tus lej kawg ntawm MAC chaw nyob ntawm IoT ntaus ntawv. Lo lus zais rau lub network kaw no yog lub npe xav tias 'PASSWORD'.

Kauj Ruam 6: Software Txheej Txheem

Software Txheej Txheem
Software Txheej Txheem
Software Txheej Txheem
Software Txheej Txheem
Software Txheej Txheem
Software Txheej Txheem
Software Txheej Txheem
Software Txheej Txheem

PreambleTo kom ua tiav qhov ua tiav cov cai no koj yuav xav tau cov tsev qiv ntawv ntxiv hauv qab no;

PubSubClient.h

  • Los ntawm: Nick O'Leary
  • Lub Hom Phiaj: Ua kom lub cuab yeej tshaj tawm lossis sau npe rau MQTT cov ncauj lus nrog tus muab khoom plig
  • Los ntawm:

Thauj2.h

  • Los ntawm: Thomas O Fredericks
  • Lub hom phiaj: Cov tswv yim hloov de-bounce hauv software
  • Los ntawm:

Txoj Cai Txheej Txheem

Lub software siv lub xeev-tshuab raws li qhia hauv daim duab 1 saum toj no (daim ntawv theej tag nrho ntawm qhov chaw muab hauv qab no). Muaj 5 lub xeev tseem ceeb raws li hauv qab no;

  • INIT

    Lub xeev pib ua ntej no yog thawj lub xeev nkag mus tom qab lub zog nce

  • NOCONFIG

    Lub xeev no tau nkag mus yog tias tom qab siv lub zog tsis raug lossis ploj lawm secvals.txt cov ntaub ntawv raug kuaj pom

  • PENDING NWS

    Lub xeev no hla dhau, nkag mus thaum tsis muaj WiFi txuas txuas

  • Qhib MQTT

    Lub xeev no tau hla dhau, nkag mus tom qab kev sib txuas hauv WiFi tau ua thiab txawm tias tsis muaj kev sib txuas rau MQTT tus tswv lag luam ntawm lub network ntawd

  • QAUV

    Qhov no yog lub xeev kev ua haujlwm ib txwm nkag mus ib zaug ob qho kev sib txuas hauv WiFi thiab tau tsim MQTT Broker txuas. Nws yog nyob rau lub xeev no Mains Controller yuav tshaj tawm rau MQTT Broker thiab tau txais cov lus txib ntawm cov ncauj lus sau npe

Cov xwm txheej tswj kev hloov pauv ntawm cov xeev tau piav qhia hauv daim duab 1 saum toj no. Kev hloov pauv ntawm cov xeev tseem raug tswj hwm los ntawm cov hauv qab no SecVals;

  • 1st MQTT Broker IP Chaw Nyob. Hauv daim ntawv zauv zauv zauv AAA. BBB. CCC. DDD
  • 2nd MQTT Broker Port. Hauv daim ntawv Integer.
  • 3rd MQTT Broker kev sib txuas sim ua ua ntej hloov pauv ntawm STA hom mus rau AP hom. Hauv daim ntawv Integer.
  • 4th WiFi Network SSID. Hauv daim ntawv dawb.
  • Qhov 5 WiFi Network Password. Hauv daim ntawv dawb.

Raws li tau hais los saud yog tias IoT lub cuab yeej tsis tuaj yeem txuas ua Chaw Nres Nkoj WiFi mus rau WiFi network uas yog SSID thiab P/W tau hais tseg hauv secvals.txt tuav hauv SPIFFS lub cuab yeej yuav dhau los ua Chaw Nkag Mus. Thaum txuas nrog qhov chaw nkag no nws yuav ua haujlwm 'Mains Controller Configuration Home Page' raws li qhia saum toj no hauv Pic 2 (los ntawm kev nkag mus 'MAINSCON.local' lossis 192.168.4.1 rau hauv koj tus browser URL chaw nyob bar). Cov nplooj ntawv hauv tsev no tso cai rov teeb tsa ntawm cov tswj hluav taws xob dhau ntawm HTTP browser.

MQTT Cov ncauj lus npe lub rooj sib tham

Cov kab ke teev tseg hauv daim duab 3 saum toj no yog lub npe kev pom zoo siv rau MQTT cov ncauj lus thiab zoo ib yam nrog cov qauv siv hauv kuv li Kev Qhia Ua Ntej (ntawm no Kauj Ruam 5).

MQTT Cov ncauj lus siv los ntawm cov cuab yeej IoT no

Kom meej dua Kuv tau sau tseg (daim duab 4) cov ncauj lus thiab cov lus sib txuas ua ntu zus cov cuab yeej no tshaj tawm/sau npe rau. Daim duab no tseem piav qhia txog kev cuam tshuam nrog khawm tswj dawb ntawm sab nrauv ntawm lub thawv ntawv (txawm hais tias tsis txaus ntseeg lub pob tau pom liab).

Kev Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag Nkag mus rau lwm qhov

Thaum txuas nrog MQTT Broker nws tuaj yeem rov kho dua qhov kev teeb tsa kev nyab xeeb rau lub cuab yeej ntawm MQTT cov ntawv tshaj tawm. Cov ntaub ntawv cuam tshuam secvals.txt tau sau tsuas yog nkag mus nthuav tawm.

Neeg siv debug

Thaum lub sijhawm pib ua ntu zus Sonoff ntaus ntawv coj cov lus tawm tswv yim hauv qab no, txawm hais tias nws yuav tsum tau sau tseg, txhawm rau saib qhov no koj yuav xav tau tshem lub npog thiab nthuav tawm cov xov hluav taws xob yog li nws tsuas yog qhia kom ua li ntawd thaum tsim koj cov cai thiab ua kom lub zog ntaus ntawv nrog 3v3 khoom;

  • 1 Flash nyem luv: Tsis muaj teeb tsa cov ntaub ntawv nyob hauv SPIFFS (secvals.txt),
  • 2 Cov teeb nyem luv: IoT ntaus ntawv tau sim txuas rau WiFi network,
  • Kev teeb pom kev txuas mus ntxiv: Sonoff IoT ntaus ntawv tau sim txuas rau MQTT Broker,
  • Tawm: Ntaus tau siv thiab txuas nrog MQTT Broker.

Nco tseg 1: Qhov 'Mains Controller Configuration Home Page' tsis siv qhov chaw ruaj ntseg thiab yog li tso siab rau koj lub network kom ruaj ntseg.

Nco tseg 2: Txhawm rau ua haujlwm ntau IoT cov cuab yeej MQTT txoj hlua yuav xav tau kev kho ua ntej rub tawm mus rau txhua lub cuab yeej. Qhov no yog vim tus lej naj npawb ntawm tus tswj hwm lub hauv paus tau muab tso rau hauv MQTT lub ntsiab lus hlua. yog ie. hauv software luam tawm Kuv tau xaiv tus nqi 100: 'WFD/MainsCont/100/Relay/Command/1' thiab rau kuv 2 lub cuab yeej lawv suav 1 & 2 feem.

  • 'WFD/MainsCont/1/Relay/Command/1'
  • 'WFD/MainsCont/2/Relay/Command/1'

Nco tseg 3: Rau kev ua tiav thaum nyob hauv lub xeev ACTIVE IoT software tso cai rau kev tswj ntawm Sonoff LED thiab tshaj tawm cov xwm txheej ntawm khawm rov nyem. Txawm hais tias cov no tsuas yog muaj txiaj ntsig thaum lub sijhawm ua haujlwm debug raws li tsis cuam tshuam rau tus neeg siv thaum lub sijhawm ua haujlwm ib txwm muaj.

Kauj ruam 7: OpenHAB Configuration

OpenHAB Configuration
OpenHAB Configuration
OpenHAB Configuration
OpenHAB Configuration
OpenHAB Configuration
OpenHAB Configuration

Txog kev ntsuas lub hom phiaj Kuv txiav txim siab los siv lub tswv yim ob lub hauv paus tswj hauv 'Chav Nyob' ntawm kuv lub tsev. Nplooj ntawv OpenHAB no tuaj yeem mus txog ntawm nplooj ntawv tseem ceeb zoo li hauv daim duab 1.

Kuv hloov kho OpenHAB.sitemap teeb tsa muab rau hauv kuv li Kev Qhia Ua Ntej (ntawm no) thiab ntxiv ib tus neeg nkag rau 'Mains Controller 1' thiab 'Mains Controller 2' (daim duab 2 saum toj no). Kuv kuj tau ntxiv cov nkag (Chav Nyob Mains Cont. 1 & 2) los tso saib RSSI Cov Kev Ntsuas ntsuas ntawm tus txais ntawm ob lub IoT tshiab (duab 3).

Thaum kawg, Kuv tau ntxiv rau hauv cov ntaub ntawv.rules thiab.items cov ntaub ntawv los tso cai rau lub xeev hloov pauv ntawm Sonoff thiab hloov kho/ua kom pom tseeb ntawm kuv qhov kev sim tsis zoo ntawm kev hloov duab (qhov hloov pauv thaum ua haujlwm thiab qhib thaum tsis ua haujlwm). Daim duab 2 muab piv txwv ntawm MC1 nquag thiab MC2 tsis ua haujlwm.

Nco tseg 1: Yog tias koj tsis paub yuav siv OpenHAB li cas ntawm no 'Kev teeb tsa thiab teeb tsa OpenHAB. Ntu 6: IoT, Kev Ua Haujlwm Hauv Tsev '

Nco tseg 2: Ib daim qauv ntawm qhov hloov pauv sitemap, cov cai thiab cov ntaub ntawv, Icons thiab lwm yam yog muab rau hauv cov ntawv zip hauv qab no.

Nco tseg 3: RSSI = Tau Txais Lub Teeb Pom Kev Muaj Zog Nov yog ntsuas ntsuas qhov IoT ntaus ntawv tuaj yeem pom koj li WiFi network zoo li cas.

Kauj Ruam 8: Kuaj Koj Li IoT Device

Image
Image
Kuaj Koj IoT Device
Kuaj Koj IoT Device

Raws li tau piav qhia hauv WiFi Qhia IoT Kub thiab Vaum Sensor. Ntu: 8 IoT, Tsev Automation Kauj Ruam 7, kev sim thawj zaug ntawm IoT lub cuab yeej tau ua tiav ntawm MQTT kev sib txuas ntawm MQTT Spy (zoo li hauv kab ke kaw kab duab pic 1 saum toj no), saib xyuas cov zis, khawm nkag (ob leeg Sonoff rov nyem khawm thiab lub khawm sab nraud dawb) thiab debug cov tsheb khiav ntawm cov interface. Qhov no tau tso cai rau kuv siv tag nrho cov ncauj lus uas tau muaj npe thiab tshawb xyuas cov lus teb uas tau tshaj tawm. Txawm hais tias dua, qhov no tau nqa los ntawm tus kheej thiab siv sijhawm ntev, txawm hais tias nws tau pab 100% kev pab them nqi ntawm cov lus/ncauj lus tshaj tawm.

Raws li lub tshuab software tseem ceeb hauv lub xeev (Kauj Ruam 6 saum toj no) tau txais los ntawm Kev Qhia Ua Ntej Ua Ntej (Ntu: 8) uas tsis yog kev saib xyuas lub software yuav txuas rau WiFi N/W thiab MQTT Broker nws tau xav tias qhov no ua haujlwm tau raug.

Kev ntsuas tag nrho cov txheej txheem tau ua tiav siv tus tswj hluav taws xob thiab IoT cov txheej txheem (dua daim duab 1) lub sijhawm no siv OpenHAB los tswj kev cuam tshuam nrog IoT ntaus ntawv. IoT kho vajtse thiab dummy load teeb tsa tuaj yeem pom hauv daim duab 2 saum toj no.

Cov vis dis aus muab cov ntsiab lus ua tiav ntawm kev sim kab ke thiab qhia meej meej tias kev sib koom ua ke tau tswj hwm ntawm OpenHAB cov cuab yeej (PC/Chrome thiab iPad/OpenHAB APP) hauv lub sijhawm tiag. Nws kuj tseem qhia kev xa xov mus rau Mains Controllers ntawm MQTTSpy (saib ntawm no kom paub meej ntxiv Teem Up MQTT Broker. Part 2: IoT, Home Automation) thiab OpenHAB tailed system cav los ntawm raspberry pi server hla PuTTY SSH txuas (saib ntawm no kom txuas ntxiv) cov ntsiab lus Teeb thiab teeb tsa OpenHAB. Ntu 6: IoT, Tsev Automation).

Nco tseg: Debug tsheb tau muab tso ua ke rau qhov software tso tawm zaum kawg.

Kauj Ruam 9: Xaus

General

Txoj haujlwm tau yooj yim ua kom tiav thiab ua haujlwm tau zoo. Cov software uas tau teeb tsa tau yooj yim los tsim, ua ib qho kev txiav tawm ntawm cov cai uas siv rau Cov ntsuas kub thiab av noo ntawm Tshooj 8 hauv kab ntawv no.

Kuv xub npaj siab kom tau txais tsuas yog cov khoom sib xyaw dawb rau qhov zoo nkauj zoo nkauj. Kuv ua tiav qhov no hauv txhua qhov tab sis khawm tswj, sim raws li kuv tuaj yeem ua tau, Kuv tsis tuaj yeem nrhiav qhov zoo/pheej yig khawm dawb kiag li.

Sonoff 10A ntaus ntawv

Kuv tau teev tseg hauv qab no qhov kuv xav tias tsim nyog Pros thiab Cons ntawm Sonoff ntaus ntawv

Pros

  • Pheej yig.
  • Txhawb zej zog zoo.
  • Muaj peev xwm rov ua haujlwm ntawm Arduino IDE.

Cons

  • Cov ntaub thaiv npog yooj yim.
  • Tsawg kawg I/O (coj tawm mus rau qhov siv tau txuas).
  • Nws khiav kub hauv nws lub xeev quiescent.
  • Tsuas yog muaj 1MByte ntawm on-board SPI flash.
  • Puas yog PITA rau reprogram ib zaug wired hauv qhov chaw.
  • Thaum ua ke cov cai tshiab rau hauv Sonoff kuaj qhov kev xa tawm kaw tau muaj teeb meem muab qhov xa tawm yog 5v thiab cov khoom siv rau Sonoff rau kev ua haujlwm yog 3v3. Kev ua haujlwm sib txuas yog tsuas yog pom tau rau pob ntseg.

Kev txhawj xeeb

  • Nws tsis hloov txoj kab Neutral. Siv tus SPST relay.
  • Tsis yog fused.
  • Tsis zoo cable lim nyem.
  • PCB tsis ruaj ntseg nyob rau hauv Sonoff enclosure.

Tawm tswv yim txog kev tsim vaj tsev

Muab qhov cuab yeej IoT no tau siv los hloov pauv lub zog tseem ceeb hauv tebchaws Askiv (240VAC RMS) Kuv ua raws ob qho tib si kev siv tshuab thiab hluav taws xob zoo thiab ua kom muaj kev pheej hmoo ntawm kev poob siab tsawg dua los ntawm kev tsis nthuav tawm cov khoom siv hluav taws xob, tshaj qhov tshwj xeeb txhua yam khoom, tsis ntsuas tso tawm qhov tso tawm, thov fuse tiv thaiv ob qho tib si Mains Controller thiab Opto-Coupled Sub-System, suav nrog cov av tsis zoo, thiab siv kev sib cais kho qhov muag/galvanic.

Kev Txhim Kho Tau

Nrog kev pom tom ntej nws yuav tau txais txiaj ntsig los suav nrog qhov pom pom qhov Mains Controller cov zis tau ua haujlwm (LED lossis Neon). Txawm hais tias tsis yog teeb meem hauv kev siv niaj hnub, muab nws yog tus qauv coj los cais cov khoom thauj los ntawm kev muab khoom ua ntej ib qho kev saib xyuas tau ua tiav, lossis ib qho yooj yim nias ntawm lub pob tswj hauv cheeb tsam yuav hloov qhov tso tawm hauv rooj plaub uas lub teeb yuav ci thaum ntsaws.

Daim ntawv kawg

Yog tias koj xav pom ob qho piv txwv tsis zoo ntawm kev cuam tshuam nrog lub zog hluav taws xob kos tawm cov kab ntawv txuas hauv qab no. Lawv cov khoom plig Darwin yuav nyob rau hauv cov ntawv sai sai no, Kuv paub tseeb;

  • Mad Scientist Extension Qaum
  • Tswv Yim Zej Zog 03 - Kev txhawj xeeb txog Lub Hwj Chim Muaj Hwj Chim!

Kauj Ruam 10: Cov Lus Qhia Siv

Kuv siv cov peev txheej hauv qab no los tso Cov Lus Qhia no ua ke;

PubSubClient.h

  • Los ntawm: Nick O'Leary
  • Lub Hom Phiaj: Ua kom lub cuab yeej tshaj tawm lossis sau npe rau MQTT cov ncauj lus nrog tus muab khoom plig
  • Los ntawm:

Thauj2.h

  • Los ntawm: Thomas O Fredericks
  • Lub hom phiaj: Cov tswv yim hloov de-bounce hauv software
  • Los ntawm:

SPIFFS

https://esp8266.github.io/Arduino/versions/2.0.0/do…

Hloov kho Sonoff flash

  • https://www.andremiller.net/content/upgrading-sonof…
  • https://tech.scargill.net/32mb-esp01/
  • https://www.andremiller.net/content/upgrading-sonof…

Sonoff Circuit Diagram

https://www.itead.cc/wiki/images/6/6b/Sonoff_schmatic.pdf

USB UART Module (aka. FTDI)

https://www.ebay.co.uk/itm/6Pin-USB-2-0-to-TTL-UART-Module-Converter-CP2102-STC-Replace-FT232-CF-/272249732398?epid=503069058&hash=item3f63593d2e: g: QVUAAOSw71BXP92B

Darwin khoom plig (nyem nyem)

https://www.darwinawards.com/

TIL111 Opto-isolator cov ntaub ntawv

Pom zoo: