• I developed a simple push button project
  • I used a wemos D1 mini
  • I connected D3 pin to a pull down 1K resistor.
  • I used a multimeter to measure D3 pin voltage.

When I push the button, D3 pin voltage changes from 0.x volt to 4.x volt. But digital read on D3 always return HIGH.

Please help me find the problem.

This in my sketch :

    int ledPin = D2; // choose the pin for the LED
    int inPin = D3;   // choose the input pin (for a pushbutton)
    int val = 0;     // variable for reading the pin status
    void setup() {
      pinMode(ledPin, OUTPUT);  // declare LED as output
      pinMode(inPin, INPUT);    // declare pushbutton as input
    void loop(){

      val = digitalRead(inPin);  // read input value
      if (val == HIGH) {    
        digitalWrite(ledPin, LOW);  
      } else {
        digitalWrite(ledPin, HIGH);  
  • 1
    How can it be that you measure > 4V at D3 if you're just pulling down the pin. Either you provide us with schematics on what's at D3 or we won't be able to do anything else than speculate, let alone help you. Feb 19, 2017 at 0:07
  • you should use the INPUT_PULLUP mode if you want to activate by connecting the GPIO to GND; otherwise your input state will be inverted.
    – dandavis
    Feb 19, 2017 at 8:48

2 Answers 2


The problem is that when the button isn't pressed, the voltage at pin D3 is just floating. Since there is nothing attached, the voltage at the pin can be anything. To prevent this, you use a pull-down resistor, so that when the button isn't pressed, the voltage at D3 is pulled to ground, and you will get a LOW using digitalRead.


simulate this circuit – Schematic created using CircuitLab


First of all - read your post before you actually post it. This code is no readable. And if you have problems with electronics add picture of schematics how you connected your board. There can be problem too.

D3 IO, 10k Pull-up GPIO0

Source: https://www.wemos.cc/product/d1-mini-pro.html

Your D3 pin have internally pull-up so no doubt that it reads HIGH all the time. Connect your board like on picture below or change your reading pin to D0 for example (It has no other function than simple IO).


simulate this circuit – Schematic created using CircuitLab

For this case you can trust internal pull-up but in more complicated projects you should add your own one.

For more information about pull-ups and pull-downs check this article: http://www.electronics-tutorials.ws/logic/pull-up-resistor.html

  • Thanks for your advice Adam Rosiek, i choose D3 for some packaging space issue. Yes i move to D8 it solve the problem. And i.m sorry for inconvenient code and no picture Feb 19, 2017 at 4:12

Your Answer

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

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