user48454: I couldn't find a proper answer on the net so I came here as a last resort.
So I want to use the FLASH button as an input in the loop() method.
Is there a way the check if it's pressed or not?


user47766: I often use it as an input if I need a button input on my boards. After the initial boot sequence it is just another I/O pin. 

user77847: The top answer only works for me when the Nodemcu is connected via a serial port and the "Serial Monitor" is turned on.  (It was frustrating because it would always work whenever I connect up the serial monitor for debugging and then stop working when I disconnect it to run standalone).   I think this is because the Nodemcu connects GPIO0 and GPIO16 to the UART's RTS and DTR signals.   The buttons only work when those control lines are in the right states and that might not always be the case.   See the third page in the schematic at https://github.com/nodemcu/nodemcu-devkit-v1.0/blob/master/NODEMCU_DEVKIT_V1.0.PDF

user37940: Just to complete the other answers, here is sample Lua code to help you get started
inpin=3 -- Select input pin - GPIO0 

function pressed()
    print("PRG Pressed")
end

gpio.mode(inpin,gpio.INT,gpio.PULLUP)
gpio.trig(inpin,"down",pressed)

When you press the "Flash" or "PRG" button "PRG Pressed" is printed. You can perform additional magic in the function. 
Above sample code adapted from this blog post
I am using this board from MakerFocus

user55251: I recommend you EasyButton library, you can use pin 0 (D3) in NodeMCU, if you want use a external button module, you can wire your button between D3 pin and GND.
https://github.com/evert-arias/EasyButton
#include <EasyButton.h>

// Arduino pin where the button is connected to.
#define BUTTON_PIN 0

// Instance of the button.
EasyButton button(BUTTON_PIN);

// Callback function to be called when the button is pressed.
void onPressed() {
    Serial.println("Button has been pressed!");
}

void setup() {
    // Initialize Serial for debuging purposes.
    Serial.begin(115200);
    // Initialize the button.
    button.begin();
    // Add the callback function to be called when the button is pressed.
    button.onPressed(onPressed);
}

void loop() {
    // Continuously read the status of the button. 
    button.read();
}



user37622: The Flash button on NodeMCU is connected between io 0 and ground.  You can use it as a button.  Set pinMode(0, INPUT_PULLUP) and you will read io 0 LOW if the button is pressed.
NodeMCU schema
To put the module in flashing mode, first the Flash button must be held and the Reset button pushed, only then should the Flash button be released. Normally, the reset to flashing mode is done automatically by esptool before uploading over USB. This uses the circuit connected to serial RST and DTS lines.

48454: <p>I couldn't find a proper answer on the net so I came here as a last resort.
So I want to use the FLASH button as an input in the <code>loop()</code> method.</p>

<p>Is there a way the check if it's pressed or not?</p>

<p><a href="https://i.stack.imgur.com/FMur3.png" rel="noreferrer" title="ESP module with the flash button"><img src="https://i.stack.imgur.com/FMur3.png" alt="ESP module with the flash button" title="ESP module with the flash button"></a></p>
 47766: <p>I often use it as an input if I need a button input on my boards. After the initial boot sequence it is just another I/O pin. </p>
 77847: <p>The top answer only works for me when the Nodemcu is connected via a serial port and the &quot;Serial Monitor&quot; is turned on.  (It was frustrating because it would always work whenever I connect up the serial monitor for debugging and then stop working when I disconnect it to run standalone).   I think this is because the Nodemcu connects GPIO0 and GPIO16 to the UART's RTS and DTR signals.   The buttons only work when those control lines are in the right states and that might not always be the case.   See the third page in the schematic at <a href="https://github.com/nodemcu/nodemcu-devkit-v1.0/blob/master/NODEMCU_DEVKIT_V1.0.PDF" rel="nofollow noreferrer">https://github.com/nodemcu/nodemcu-devkit-v1.0/blob/master/NODEMCU_DEVKIT_V1.0.PDF</a></p>
 37940: <p>Just to complete the other answers, here is sample Lua code to help you get started</p>

<pre><code>inpin=3 -- Select input pin - GPIO0 

function pressed()
    print("PRG Pressed")
end

gpio.mode(inpin,gpio.INT,gpio.PULLUP)
gpio.trig(inpin,"down",pressed)
</code></pre>

<p>When you press the "Flash" or "PRG" button "PRG Pressed" is printed. You can perform additional magic in the function. </p>

<p>Above sample code adapted from <a href="https://esp8266-projects.org/2015/03/buttons-pushbuttons-and-debouncing-story-html/" rel="nofollow noreferrer">this</a> blog post</p>

<p>I am using <a href="https://rads.stackoverflow.com/amzn/click/com/B076JDVRLP" rel="nofollow noreferrer" rel="nofollow noreferrer">this</a> board from MakerFocus</p>
 55251: <p>I recommend you EasyButton library, you can use pin 0 (D3) in NodeMCU, if you want use a external button module, you can wire your button between D3 pin and GND.</p>

<p><a href="https://github.com/evert-arias/EasyButton" rel="noreferrer">https://github.com/evert-arias/EasyButton</a></p>

<pre class="lang-js prettyprint-override"><code>#include &lt;EasyButton.h&gt;

// Arduino pin where the button is connected to.
#define BUTTON_PIN 0

// Instance of the button.
EasyButton button(BUTTON_PIN);

// Callback function to be called when the button is pressed.
void onPressed() {
    Serial.println("Button has been pressed!");
}

void setup() {
    // Initialize Serial for debuging purposes.
    Serial.begin(115200);
    // Initialize the button.
    button.begin();
    // Add the callback function to be called when the button is pressed.
    button.onPressed(onPressed);
}

void loop() {
    // Continuously read the status of the button. 
    button.read();
}

</code></pre>
 37622: <p>The Flash button on NodeMCU is connected between io <code>0</code> and ground.  You can use it as a button.  Set <code>pinMode(0, INPUT_PULLUP)</code> and you will read io <code>0</code> LOW if the button is pressed.</p>

<p><a href="https://github.com/nodemcu/nodemcu-devkit-v1.0/blob/master/NODEMCU_DEVKIT_V1.0.PDF" rel="noreferrer">NodeMCU schema</a></p>

<p>To put the module in flashing mode, first the Flash button must be held and the Reset button pushed, only then should the Flash button be released. Normally, the reset to flashing mode is done automatically by esptool before uploading over USB. This uses the circuit connected to serial RST and DTS lines.</p>
