+ All Categories
Home > Documents > Esp8466 Rusky Navod

Esp8466 Rusky Navod

Date post: 07-Jul-2018
Category:
Upload: buchar
View: 228 times
Download: 0 times
Share this document with a friend

of 16

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 a4en e vho7n poue pro o - spnn o7porov t;e

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

  • 8/18/2019 Esp8466 Rusky Navod

    2/16

    "?3@B ako 4i7iC aspot4e0a prou7u triak sluDn= uDet4it msto na 7esce."0vykle 25A vho7n= pro vDechny 7omc pot4e0yE neapomeFtesi vy0rat ten sprvn= chla7iC.

    #ro 0;nho 7omcho osvtlenE p4i prou7 8A a 99G 7o0yprovou a 7enE co; e vce ne; 7ost. e7en kanl. #oku7 e vD7omov - mek s o0rovsk=mi lustryE tento re;im prav7po7o0nne0u7e it. :H!riaky ne0;ni pou;van polovo7iCov=ch souCstek pro 4env=konu a p4epnn potore0iteley. !ato regulace v=konu systmymohou 0=t pou;ity pro 7lkov napen elektrick=ch a4enne0o pro automatick spnaCe energieE k7y; se parametryE ako

     e teplota ne0o intenity svtla a p4e7em stanovenou roveF.!riaky I!1BB t47a o7 B# nik7y neklamou. en to en pou;it=v osv7Cenm istiCem triak s iolac na optosimistore >"?3@BEkontrolovan= 7igitln signl @/1:

    elpe po47it I!1BB o7 B# a po47it ho se spolehlivho

    7roe.

    TRIAC

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

    #oku7 e pot4e0a spnat in7ukCn t;E tak n;e uve7enapoen s 1@@J o7porem a kon7entorem 1@@nK/@@

  • 8/18/2019 Esp8466 Rusky Navod

    3/16

    0y 0yla vevypnutmstavuE a0yspot4e0itel 0yl

     en neutrlnvo7iCH.

    !ento typschmatu Mviv=DeH e 7ost

    7o0r en proo7porovt;e. k7y;

     e p4stroovl7in7ukCnt;e napt

    a prou7t;e nesouve i."meit sklonnapt novu aaistit 47n!+A? oEo0vyklepou;vny vparalelnm

    apoen s kapacitn t;. !ento systm mN;e 0=t tak pou;itpro lepDen o7olnosti proti triakov rychle p4echo7ov napt.#4kla7y apoen 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 p4eprogramovn irmOare na >#P> o7e>?: ># P>?onnect 7esky na PI a7aptremE nastavte propoku #+) M;lut=na snmkuH 7o poice programovacho re;imu Muav4en=H aaplikovat napen o0vo7u *aCtek o7e>? 0linkrN.

  • 8/18/2019 Esp8466 Rusky Navod

    6/16

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

    #oku7 e vDe v po47kuE e mo;n p4ipoit naDe a4en 7oelektrick suvky a ;rovky. "pakute testovn kU7u navrcholuE a mN;ete vi7tE ;e svtlo e 4ena tak mo7ulem. :H#ou;ite vho7n= chla7iC pro trtov= 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 vy7atp4ka:

    +wifi.sta.getip() -- find te IP Add'ess we'e 1ou'new #e6 Se'e' wi 6e  dofie("we6switc.ua") -- Sta't te #e6 Se'e'

    7entiikace )#" piny:

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

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

    send(?/%OCTPE =TD7?)  conn>send(?tm?)  conn>send(?eadmeta content+"teFt@tm5ca'set+utf-G"st1einputHwidt> 3,,pF5 eigt>3,,pF5@st1e?)

      conn>send(?titeESPG900 - Powe' SwitcCont'oe'@tite@ead?)

  • 8/18/2019 Esp8466 Rusky Navod

    9/16

      conn>send(?6od13Powe' SwitcCont'oe'@3?)  conn>send(?Status> 6?)  if (status ++ "ON") ten conn>send(?fontcoo'+'edON@font@?)  eseif (status ++ "O$$") ten conn>send(?fontcoo'+g'eenO$$@font@?)  ese

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

      conn>send(?fo'm action+"@" metod+"POST"?)

      if (status ++ "ON") ten conn>send(?inputt1pe+"su6mit" st1e+"6ac*g'ound-coo'>'ed"name+"cmd3" aue+"O$$"@6' @6' @?)

    eseif (status ++ "O$$") ten conn>send(?inputst1e+"6ac*g'ound-coo'>g'een" t1pe+"su6mit"name+"cmd3" aue+"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("'eceie"& function(conn&pa1oad)  --neFt 'ow is fo' de6ugging output on1  --p'int(pa1oad)  if (st'ing.find(pa1oad& "4ET @ [email protected]") K+ ni)ten  p'int("4ET 'eceied")

      sendPage(conn)  ese

  • 8/18/2019 Esp8466 Rusky Navod

    10/16

      swstat+Hst'ing.find(pa1oad&"cmd3+")  --If POST aue eFist& set 7E% powe'  if swstat89:K+ni ten  p'int("Command 'eceied> " .. pa1oad)  Pw'S#(swstat&pa1oad)  sendPage(conn)  end  end  end)  conn>on("sent"& function(conn)  conn>cose()  p'int("Connection cosed")

      end)end)

    "tev4ete svN o0l0en= Oe0ov= prohl;eC a a7ete # a7resunovho Oe0ovho serveru. #oku7 vDe pN7e 7o04eE ml 0yvypa7at ak e uve7eno n;e:

    Slavn vypnaC ?ontroller

    Ptatus: O$$L*7e e Le'enM taLt*o ne0o eenM v vislosti nastavu spnaCeL

    ?hcete-li hlavn vypnaC na automatickspuDtnE k7y; e o0vo7 apnut= ne0o restartovn napsnm pr47kN 7o sou0oru Linit.uaL:

    tm'.now() -- fo' de6ug on1& 1ou can s*ip itwifi.sta.getmac() -- fo' de6ug on1& 1ou can s*ipitwifi.sta.getip() -- fo' de6ug on1& 1ou can s*ipitnode.eap()dofie("we6switc.ua") -- needed to sta't #e6Se'e' fo' command input

  • 8/18/2019 Esp8466 Rusky Navod

    11/16

    &U7 ulo;it 7o %P# ako Linit.luaLE restartute %P#. #o restartovn nD 7evaysa automaticky restartue program a sou0or Linit.luaLPpuDtn master sou0oru LOe0WsOitch.luaL:

    PotOare ahar7Oare 7esign e

    7istri0uovn v na7iE ;e 0u7e u;iteCn=E ale I%* XA&Y&"'<

    *Z+&[ 7okonce i 0e p4e7pokl7an ruky #+"(%X"P!ne0o

  • 8/18/2019 Esp8466 Rusky Navod

    12/16

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

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

      gpio.write(outpin,gpio.LOW)

    2. Power Switch function, actingbased 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+ ten gpio.write(outpin,gpio.IG) return end   i new!t"t==+O//+ ten gpio.write(outpin,gpio.LOW) return end   end

    3. Send Page function based onrequest:

    unction !endP"ge(conn)  conn!end(1TTP2. &00 O34n4n1)  conn!end(+567T8 TTP-79UI:=4+;7/;7S4+ +)  conn!end(15?@O1)  conn!end(15tml>1)  conn!end(15e"d>5met" content=+teBt2tmlC c"r!et=ut-D+>5!t#le>inputEwidt00pBC eigt 00pBCF52!t#le>1)  conn!end(15title>7SPD& - Power Switc 52e"d>1)  conn!end(15$od#>5>Power Switc 1)  conn!end(1St"tu! 5$>1)  i (!t"tu! == +O+) ten conn!end(15H>5ont color=red>O52ont>52H>1)  el!ei (!t"tu! == +O//+) ten conn!end(15H>5ontcolor=green>O//52ont>52H>1)  el!e

    conn!end(!t"tu!)  conn!end(11)  end   conn!end(152$>5$r 2>5$r 2>1)  conn!end(15orm "ction=+2+ metod=+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>52orm>1)  conn!end(152$od#>52tml>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* +

      wii.!etmode(wii.ST8TIO)  wii.!t".conig(+5YOUR WIFI Network SSID>+,+5 password >+) 

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

    I# address. If all o&' should loo& something li&e below +

    If you want the $eb #ower "witch software to start automatically

    when your CBDB module starts or reboots' then you neet to

    create and add some lines in your (init.lua( le+

  • 8/18/2019 Esp8466 Rusky Navod

    15/16

    tmr.now() -- for debug only, you can skip it 

    wi.sta.getmac() -- for debug only, you can skip it

    wi.sta.getip() -- for debug only, you can skip

    itnode.heap()dole("web_switch.lua") -- needed to start Web er!er for

    command input 

    "ave the code on !"# as 'init.lua(' restart !"#. It should reboot

    and restart the program and reinitiali-e the $eb "erver+

    s I said from the beginning' this is a e/perimental $01#"

    module e/ample for a $eb Controlled #ower ,%2,FF switch only.

    Dimming is another story' but if you are interrested about we

    can tal& about it.

    s usual' waiting your comments and suggestions. If is anybody

    interested I have available few of them from previous proects

    and can easily respin more as the parts are already available.

  • 8/18/2019 Esp8466 Rusky Navod

    16/16


Recommended