Pin problem with nodemcu 1.0

Hello! I’m trying to get a LED widget on the app light up when i press a hardware button connecting a pin and 5v trough a resistor.It worked perfectly without blynk on an arduino Uno where a real LED lights up.But trying to blend blynk and the other code together makes the board keep restarting.Here’s the code:
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "code code code";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "SSID SSID  SSID";
char pass[] = "pass pass pass";

// Select your pin with physical button
const int  buttonPin = 8;

WidgetLED led3(V3);

SimpleTimer timer;

// V3 LED Widget represents the physical button state
void buttonLedWidget()
{
  // Read button
  if (digitalRead(buttonPin) == 1) led3.on();
  else led3.off();
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

  // Setup physical button pin (active low)
  pinMode(buttonPin, INPUT);

  timer.setInterval(500L, buttonLedWidget);
}

void loop()
{
  Blynk.run();
  timer.run();
}

And this is the serial monitor output:

 ~?–$“Т¶Јя_CAZюы[243] Connecting to Xiaomi_EFB5
[3744] Connected to WiFi
[3744] IP: 192.168.31.138
[3744] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.3 on NodeMCU

[5001] Connecting to blynk-cloud.com:8442
[5087] Ready (ping: 0ms).
ь!m!„яж¦цю[60] Connecting to Xiaomi_EFB5
[3561] Connected to WiFi
[3561] IP: 192.168.31.138
[3561] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.3 on NodeMCU

[5001] Connecting to blynk-cloud.com:8442
[5096] Ready (ping: 0ms).
ьГЋ¦И1¤
сю[60] Connecting to Xiaomi_EFB5
[3061] Connected to WiFi
[3061] IP: 192.168.31.138
[3061] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.3 on NodeMCU

[5001] Connecting to blynk-cloud.com:8442
[5094] Ready (ping: 1ms).
ь
1И ЧЖэ1¦эя[60] Connecting to Xiaomi_EFB5
[3561] Connected to WiFi
[3561] IP: 192.168.31.138
[3561] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.3 on NodeMCU

[5001] Connecting to blynk-cloud.com:8442
[5086] Ready (ping: 1ms).
ьБ‡M¤„яжКUцю[60] Connecting to Xiaomi_EFB5
[3561] Connected to WiFi
[3561] IP: 192.168.31.138
[3561] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.3 on NodeMCU

[5001] Connecting to blynk-cloud.com:8442
[5089] Ready (ping: 1ms).
т!†M¤„я‹жхцю[60] Connecting to Xiaomi_EFB5
[3061] Connected to WiFi
[3061] IP: 192.168.31.138
[3061] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.3 on NodeMCU

[5001] Connecting to blynk-cloud.com:8442
[5098] Ready (ping: 1ms).
ь!m!dя‹Охя[60] Connecting to Xiaomi_EFB5
[3561] Connected to WiFi
[3561] IP: 192.168.31.138
[3562] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.3 on NodeMCU

Thank you in advance :slight_smile:

I think this is your bug.
You don’t have a pin 1 on an ESP like you do an Arduino.
Well you do but it’s either the RX / TX pin that you don’t want to mess with.

I also like to see pinMode() before Blynk connections but maybe that’s just me.

1 Like

1 is not the pin it’s if i press the button digitalRead(buttonPin) is 1 and if its not pressed its 0. that like high and low or true and false

How stupid am I, long night.

1 Like

and if you comment out
timer.setInterval(500L, buttonLedWidget);
and
timer.run();

it has stable connection?
did you try to add another function instead buttonLedWidget in simple timer? maybe its the function…

also, it is not clear to me what board are you using? what is the value of the resistor?
are you using any physical pull up / pull down? in your sketch you just have: pinMode(buttonPin, INPUT); , not INPUT_PULLUP…

2 Likes

If i comment them out it still resets constantly which is strange since the “default” program works just fine. idk what you mean by stable connection if you mean connection to router then yes.About the other function i am no expert so idk what youre talking about and im using nodemcu 1.0 value of resistor 10Kohms resister is connecting GND to the pin and i touch the leg of the resistor which is connected to the pin with a cable which is connected to 5V. It works on the arduino Uno without blynk.i have no idea what physical pull up and pull down is but changing it to INPUT_PULLUP did not fix the issue.

it resets every time when you “press the button”, or it resets anyway?

1 Like

Maybe I’m not so stupid.

Your button pin is 8, now this doesn’t appear anywhere on a nodemcu 1.0.
There is a D8 which is tied to GPIO 15. GPIO 15 should be avoided as it’s “special”.

My personal favourites are GPIO 4 and 5 which are D1 and D2.
You can either prefix the pin number with the D, so D1 or our preference stick to GPIO’s and use 4 (or 5).

Many Arduino users mix up the pins.

1 Like

yeah, this is exactly what i’m thinking about :wink:
regarding this image: http://blog.filipeflop.com/wp-content/uploads/2016/02/Node-MCU-ESP-12E-Pin-Out-Diagram2.jpg

try to choose another pin, which is not so special :slight_smile:

1 Like

It resets anyways and ill check out the pins as yall told me. 5 mins :smiley: so i right D1 for D1 or 5 for D1?

try to use D1

and you should consider changing the title and category for this topic, as it is highly probable has nothing to do with simple timer nor blynk, and it is not an issue / error!

better “need help with my project” or something similar category…

1 Like

YEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE it worked thank you so much.You’re all amazing and intelligent creatures

1 Like

how do i change category?

and name

Edit: nevermind is that better?

ok, then please read my edit on last post.
and if you are curious bout the pullup / pulldown stuff, you can read here:


https://www.arduino.cc/en/Tutorial/DigitalPins

but i do not know what pins (if any) has built in pullup / down resistor on nodemcu board. you should figure this out… or maybe @Costas know this?

edit: i do not know how to change post title / category…

1 Like

I don’t use nodemcu’s but the following table indicates ESP’s have pullup resistors on all pins except GPIO 16 which has a pulldown resistor. GPIO 16 is “special” too.

https://blog.falafel.com/programming-gpio-on-the-esp8266-with-nodemcu/

2 Likes