Home >Documents >Esp8466 Rusky Navod

Esp8466 Rusky Navod

Date post:07-Jul-2018
Category:
View:214 times
Download:0 times
Share this document with a friend
Transcript:
  • 8/18/2019 Esp8466 Rusky Navod

    1/16

    Выключатель

    сетевого

    питания на ESP8266

    http://kirill1985.ru/pokupka/3522-vyklyuchatel-setevogo- pitaniya-na-esp8266.html 

    A!" #$%&'A( )"")'% * +,!

    "0ecn vahy: !oto a4en e vho7n poue pro o - spnn o7porov t;e

    http://kirill1985.ru/pokupka/3522-vyklyuchatel-setevogo-pitaniya-na-esp8266.html http://kirill1985.ru/pokupka/3522-vyklyuchatel-setevogo-pitaniya-na-esp8266.html http://kirill1985.ru/pokupka/3522-vyklyuchatel-setevogo-pitaniya-na-esp8266.html http://kirill1985.ru/pokupka/3522-vyklyuchatel-setevogo-pitaniya-na-esp8266.html

  • 8/18/2019 Esp8466 Rusky Navod

    2/16

    "?3@B ako 4i7iC a spot4e0a prou7u triak sluDn= uDet4it msto na 7esce. "0vykle 25A vho7n= pro vDechny 7omc pot4e0yE neapomeFte si vy0rat ten sprvn= chla7iC.

    #ro 0;nho 7omcho osvtlenE p4i prou7 8A a 99G 7o0y provou a 7enE co; e vce ne; 7ost. e7en kanl. #oku7 e vD 7omov - mek s o0rovsk=mi lustryE tento re;im prav7po7o0n ne0u7e it. :H !riaky ne0;ni pou;van polovo7iCov=ch souCstek pro 4en v=konu a p4epnn potore0iteley. !ato regulace v=konu systmy mohou 0=t pou;ity pro 7lkov napen elektrick=ch a4en ne0o pro automatick spnaCe energieE k7y; se parametryE ako

     e teplota ne0o intenity svtla a p4e7em stanovenou roveF. !riaky I!1BB t47a o7 B# nik7y neklamou. en to en pou;it= v osv7Cenm istiCem triak s iolac na optosimistore >"?3@BE kontrolovan= 7igitln signl @/1:

    elpe po47it I!1BB o7 B# a po47it ho se spolehlivho

    7roe.

    TRIAC

    I! 136 6@@< - A I! 138 6@@< - 12A I! 139 6@@< - 16A I!A 23 8@@< - 12A I!A 22 8@@< - 1@A I!A @ 8@@< - @A I!A 1 8@@< - @A

    #oku7 e pot4e0a spnat in7ukCn t;E tak n;e uve7en apoen s 1@@J o7porem a kon7entorem 1@@nK/@@

  • 8/18/2019 Esp8466 Rusky Navod

    3/16

    0y 0yla ve vypnutm stavuE a0y spot4e0itel 0yl

     en neutrln vo7iCH.

    !ento typ schmatu Mvi v=DeH e 7ost

    7o0r en proo7porov t;e.  k7y;

     e p4stro ovl7 in7ukCn t;e napt

    a prou7 t;e nesou ve i. "meit sklon napt novu a aistit 47n !+A? oE o0vykle pou;vny v paralelnm

    apoen s kapacitn t;. !ento systm mN;e 0=t tak pou;it pro lepDen o7olnosti proti triakov rychle p4echo7ov napt. #4kla7y apoen pro pou;it k7y; chcete p4epnout horkou linku:

  • 8/18/2019 Esp8466 Rusky Navod

    4/16

  • 8/18/2019 Esp8466 Rusky Navod

    5/16

    #roces p4eprogramovn irmOare na >#P> o7e>?: ># P> ?onnect 7esky na PI a7aptremE nastavte propoku #+) M;lut= na snmkuH 7o poice programovacho re;imu Muav4en=H a aplikovat napen o0vo7u *aCtek o7e>? 0linkrN.

  • 8/18/2019 Esp8466 Rusky Navod

    6/16

      edState + 3 - edState5   gpio.w'ite(edPin& edState)   end)

    #oku7 e vDe v po47kuE e mo;n p4ipoit naDe a4en 7o elektrick suvky a ;rovky. "pakute testovn kU7u na vrcholuE a mN;ete vi7tE ;e svtlo e 4ena tak mo7ulem. :H #ou;ite vho7n= chla7iC pro trtov= v=kon v triak.

  • 8/18/2019 Esp8466 Rusky Navod

    7/16

  • 8/18/2019 Esp8466 Rusky Navod

    8/16

    &U7 ulo;it 7o %P# ako LOe0ov sOitch.luaLE novu %P# a vy7at p4ka:

    +wifi.sta.getip() -- find te IP Add'ess we'e 1ou' new #e6 Se'e' wi 6e   dofie("we6switc.ua") -- Sta't te #e6 Se'e'

    7entiikace )#" piny:

      outpin+3 -- Seect T'iac command PIN - 4PIO2   gpio.mode(outpin&gpio.O!TP!T)

      gpio.w'ite(outpin&gpio.7O#)

    send(?/%OCTPE =TD7?)   conn>send(?tm?)   conn>send(?eadmeta content+"teFt@tm5 ca'set+utf-G"st1einputHwidt> 3,,pF5 eigt> 3,,pF5@st1e?)

      conn>send(?titeESPG900 - Powe' Switc Cont'oe'@tite@ead?)

  • 8/18/2019 Esp8466 Rusky Navod

    9/16

      conn>send(?6od13Powe' Switc Cont'oe'@3?)   conn>send(?Status> 6?)   if (status ++ "ON") ten conn>send(?font coo'+'edON@font@?)   eseif (status ++ "O$$") ten conn>send(?font coo'+g'eenO$$@font@?)   ese

    conn>send(status)   conn>send(?J?)   end   conn>send(?@66' @6' @?)

      conn>send(?fo'm action+"@" metod+"POST"?)

      if (status ++ "ON") ten conn>send(?input t1pe+"su6mit" st1e+"6ac*g'ound-coo'>'ed" name+"cmd3" aue+"O$$"@6' @6' @?)

    eseif (status ++ "O$$") ten conn>send(?input st1e+"6ac*g'ound-coo'>g'een" t1pe+"su6mit" name+"cmd3" aue+"ON"@?)

      end

      conn>send(?@fo'm?)   conn>send(?@6od1@tm?) end

    Ve0 Perver: s'+net.c'eateSe'e'(net.TCP) s'>isten(G,&function(conn)   conn>on("'eceie"& function(conn&pa1oad)   --neFt 'ow is fo' de6ugging output on1   --p'int(pa1oad)   if (st'ing.find(pa1oad& "4ET @ =TTP@3.3") K+ ni) ten   p'int("4ET 'eceied")

      sendPage(conn)   ese

  • 8/18/2019 Esp8466 Rusky Navod

    10/16

      swstat+Hst'ing.find(pa1oad&"cmd3+")   --If POST aue eFist& set 7E% powe'   if swstat89:K+ni ten   p'int("Command 'eceied> " .. pa1oad)   Pw'S#(swstat&pa1oad)   sendPage(conn)   end   end   end)   conn>on("sent"& function(conn)   conn>cose()   p'int("Connection cosed")

      end) end)

    "tev4ete svN o0l0en= Oe0ov= prohl;eC a a7ete # a7resu novho Oe0ovho serveru. #oku7 vDe pN7e 7o04eE ml 0y vypa7at ak e uve7eno n;e:

    Slavn vypnaC ?ontroller

    Ptatus: O$$ L*7e e Le'enM taLt*o ne0o eenM v vislosti na stavu spnaCeL

    ?hcete-li hlavn vypnaC na automatick spuDtnE k7y; e o0vo7 apnut= ne0o restartovn napsnm pr 47kN 7o sou0oru Linit.uaL:

    tm'.now() -- fo' de6ug on1& 1ou can s*ip it wifi.sta.getmac() -- fo' de6ug on1& 1ou can s*ip it wifi.sta.getip() -- fo' de6ug on1& 1ou can s*ip itnode.eap() dofie("we6switc.ua") -- needed to sta't #e6 Se'e' fo' command input

  • 8/18/2019 Esp8466 Rusky Navod

    11/16

    &U7 ulo;it 7o %P# ako Linit.luaLE restartute %P#. #o restartovn  nD 7evaysa automaticky restartue program a sou0or Linit.luaL PpuDtn master sou0oru LOe0WsOitch.luaL:

    PotOare a har7Oare 7esign e

    7istri0uovn v na7iE ;e 0u7e u;iteCn=E ale I%* XA&Y&"'<

    *Z+&[ 7okonce i 0e p4e7pokl7an ruky #+"(%X"P! ne0o

  • 8/18/2019 Esp8466 Rusky Navod

    12/16

    1. Defie !"e# $P%& 'i(

      outpin=3 -- Select IO - GPIO0 gpio.mode(outpin,gpio.OUTPUT)

      gpio.write(outpin,gpio.LOW)

    2. Power Switch function, acting based on received command:

      unction PwrSW(!w!t"t,p"#lo"d)   gpio.mode(outpin,gpio.OUTPUT)   new!t"t=!tring.!u$(p"#lo"d,!w!t"t%&',*p"#lo"d)   !t"tu! = new!t"t    i new!t"t==+O+ ten gpio.write(outpin,gpio.IG) return end    i new!t"t==+O//+ ten gpio.write(outpin,gpio.LOW) return end    end

    3. Send Page function based on request:

    unction !endP"ge(conn)  conn!end(1TTP2. &00 O34n4n1)   conn!end(+567T8 TTP-79UI:=4+;7/;7S4+ +)   conn!end(15?@O1)   conn!end(15tml>1)   conn!end(15e"d>5met" content=+teBt2tmlC c"r!et=ut-D+>5!t#le>inputEwidt 00pBC eigt 00pBCF52!t#le>1)   conn!end(15title>7SPD& - Power Switc 52e"d>1)   conn!end(15$od#>5>Power Switc 1)   conn!end(1St"tu! 5$>1)   i (!t"tu! == +O+) ten conn!end(15H>5ont color=red>O52ont>52H>1)   el!ei (!t"tu! == +O//+) ten conn!end(15H>5ont color=green>O//52ont>52H>1)   el!e

    conn!end(!t"tu!)   conn!end(11)   end    conn!end(152$>5$r 2>5$r 2>1)   conn!end(15orm "ction=+2+ metod=+POST+>1)

      conn!end(15input t#pe=+!u$mit+ n"me=+cmd+ J"lue=+O//+2>1)   conn!end(15input t#pe=+!u$mit+ n"me=+cmd+ J"lue=+O+2>5$r 2>5$r 2>52orm>1)   conn!end(152$od#>52tml>1)

  • 8/18/2019 Esp8466 Rusky Navod

    13/16

    end 

    4. Web Server:

    !rJ=net.cre"teSerJer(net.T

  • 8/18/2019 Esp8466 Rusky Navod

    14/16

    also )one time only* +

      wii.!etmode(wii.ST8TIO)   wii.!t".conig(+5YOUR WIFI Network SSID>+,+5 password >+) 

    ,pen your favorite $eb browser and type your new $eb "erver

    I# address. If all o&' s

Click here to load reader

Embed Size (px)
Recommended