0

I started a new project with an ESP8266-01 module. I want to use it as stand-alone circuit to send an Email at the press of a button.

The wiring is:

  • VCC - 3.3v VCC
  • CH_PD - 3.3v VCC
  • GND - GND
  • GPIO_2 - Push down button (internal pullup)

I've the sketch (Arduino IDE), I've upload it and it essentially works. However:

  • If I call the sendEmail(); method inside the void setup(){}, it works like a charm.
  • If I add an push down button on Pin #2 (GPIO_2) it only works if I previously have removed VCC from the CH_PD pin and reattached it again shortly after.

Now, I would bet I read something regarding (or similar) this situation a couple of days back, but I am unable to find it again, now that I need it.

Is there a solution for this or am I missing something?

Any help will be greatly appreciate it!

Thanks in advance!

3
  • The GPIO0 and GPIO2 determine what mode the module starts up. GPIO0 and GPIO2 need to have pull-up resistors connected to ensure the module starts up correctly. You can also use RX pin for the button.
    – AltAir
    Commented Dec 1, 2017 at 22:28
  • Thanks @AltAir for your response. I've followed step #4 of this instructable instructables.com/id/How-to-use-the-ESP8266-01-pins but still doesn't work as I needed it to... Commented Dec 2, 2017 at 10:08
  • You can try a bulk capacitor between VCC and GND close to the module.
    – AltAir
    Commented Dec 2, 2017 at 14:38

1 Answer 1

0

Well, after literally spending hours trying to figure out what the heck is going on, I decided to test the setup with a ESP8266-12 NodeMcu, which is essentially the same but more resembling to an Arduino in that it has more in/out pins and it's better for testing.

On this platform I got a different behavior. I was able to send an Email by the push of the button but... only once. So apparently, contrary to what I believed, something was wrong with the code.

In the code there is this method, which essentially initiates the WiFi connection:

void initializeWifi(){

  WiFi.begin(WIFI, PASSWORD);

  // allow time to make connection
 while (WiFi.status() != WL_CONNECTED)  delay(5000);

  }

Somehow the delay(5000); didn't seem right as delay usually freezes the whole thing. When I commented out the line, everything worked as expected. With the NodeMcu as well as with the ESP8266-01.

However, I still have to figure out how to give time to the WiFi to connect without freezing out all together. Probably it's the time for millis();

I hope this becomes useful to somebody else in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.