Chat freely about anything...

User avatar
By juanmol
#3965 Hi all,
i think i can use esp8266 esp-01 to control a light without a mcu. I need:
1- a gpio to control a relay (gpio13)
2- a gpio to read from the switch (gpio2)
3- send the swith state on each swith change (get http://server.ip:8080/light1/on), and change the relay state.
4- receive new orders, to control the relay

It's possible all that only with the esp-01? I have read the webserver tutorial, i think this is very simmilar. What i have on my mind:

## mental code start
on start{
set gpio13=LOW
set STATUS=LOW}

on loop{
if gpio2 state = HIGH and STATUS=LOW (
set gpio13=HIGH
set STATUS=HIGH
get http://server.ip:8080/light1/on
)
if gpio2 state = HIGH and STATUS=HIGH (
set gpio13=LOW
set STATUS=LOW
get http://server.ip:8080/light1/off
)
if [[wifi received]] = ligh1/on (
set gpio13=HIGH
set STATUS=HIGH
get http://server.ip:8080/light1/on
)
if [[wifi received]] = ligh1/off (
set gpio13=LOW
set STATUS=LOW
get http://server.ip:8080/light1/off
)

}
## mental code end

it's possible? can anyone guide me?