-->
Page 1 of 1

ESP configuration mode on startup button click

PostPosted: Wed Dec 30, 2015 5:15 pm
by Boyan Djumakov
Hi everybody,
I, as all other here, play with ESP8266 for the Home Automation. I need to have a 'configuration' mode on the different nodes activated somehow. It will be used for general configs like WiFi settings, MQTT setup and etc.
One of the options, I have seen and used in LUA script is to wait for a button click within 5 sec from the powering of the esp in which case an AP and Web Server would be fired, otherwise, a normal execution is started.
In LUA I used a timer of 5 secs that at the end checked if the button has been pushed at least once within that period and if so, I run the 'config.lua' script, otherwise I run the 'main.lua' .

I want to implement similar behavior but in ESP-Arduino C code, as I don't want to run a whole AP and a Web Server all the time when it's needed once a year.
Anyone that could help with at least a working idea is welcome.
BTW if anyone has an alternative idea, it's welcome as well :)

Thanks,
Boyan.

Re: ESP configuration mode on startup button click

PostPosted: Fri Jan 01, 2016 5:24 am
by schufti
why have a "timeout" for button press?
In setup() just check if button is pressed at startup, then branch to first init ...

Re: ESP configuration mode on startup button click

PostPosted: Sat Jan 02, 2016 3:55 am
by Boyan Djumakov
10x I'll try it out... I thought that it would interfere with the initial push for programming mode, if I put that button on GPIO0.
For this "In setup() just check if button is pressed at startup, then branch to first init ..." can you give me a quick example?
Do you mean to set a flag in setup() based on that button state and in main to execute a setup function instead of calling a proper main loop? Or is there a better way to do it?

10x,
Boyan.

Re: ESP configuration mode on startup button click

PostPosted: Sat Jan 02, 2016 2:38 pm
by schufti
Hi,
with the button on GPIO0 it won't work.
And yes, the easiest way would be to setup common parts, then depending on button state the specific parts and a variable for the main loop ...