Read a pin and drive another pin with App Blynk for NodeMCU ESP8266

Hello everyone!

I need help with blynk. I’m a newbie.:slightly_smiling_face:

In my project, I need to trigger a MOSFET that is connected (terminal gate) to pin D1 (GP05) of ESP8266 (NodeMCU V3). Using the blynk (application for smartphone) is very easy to trigger any pin. And I did it.:+1:t4:

The problem I have not resolved so far is: An external 12V signal needs to trigger MOSFET, which is connected to pin D1 (GP05). So I do not know how to set up a pin as input and also do not know how to read that input to make a decision on pin D1. I do not know how to do this in the Blynk smartphone application.:disappointed:

Could a good soul help me?:pray:t4::pray:t4::pray:t4:

If you’re using a MOSFET with a gate trigger voltage of 12v then you’re making life very difficult for yourself.

Your post seems slightly contradictory as you talk about needing to trigger the MOSFET from a GPIO pin, but then talk about this being an input pin rather than an output pin.

Take a read of this thread where I discuss the type of MOSFETs I’m using in an LED lighting controller that can be triggered directly from an ESP GPIO pin at 3.3v.
If this doesn’t answer your questions then maybe you could share more details about exactly what you’re trying to achieve.


Dear Pete,

I do not think I was clear.

The MOSFET I use is connected to the nodeMCU, so it can only be powered with 3.3V! The problem is not the MOSFET.

But I have an external 12V signal that I need to apply it to a pin of the nodeMCU (of course, it will also be necessary to limit the voltage that will reach the nodeMCU by 3.3 V. This will be done later with a resistive divider or a diode zener).

The problem is this: According to the value that will arrive at the pin of the nodeMCU, this value coming from the external signal of 12v, I need to make a decision to activate or deactivate the pin D1 (GP05) that this will activate or deactivate the MOSFET.

But friend, I do not know how to do this using the blynk smartphone app.

Need help! A lot of peace!

Well, it’s not really done with the Blynk app, it’s done with code running on the NodeMCU.
You have two choices, use the single analogue pin on the NodeMCU (A0) and poll the pin on a regular basis to determine the value of the signal. Or, use a digital pin to check whether the input is HIGH or LOW.

If you want a simple binary test (on/off) of the input then a digital pin makes sense.
In this situation you could either sample the pin on a regular basis (using a timer so as not to upset Blynk) or you could use an interrupt which will automatically monitor the pin ion the background and run some cod if the power comes on (a rising interrupt) or goes off (a falling interrupt).

You could use a voltage divider circuit to reduce the 12v supply to a suitable level, or even a 12 to 3.3v buck converter that shares a common ground with the NodeMCU.

Ultimately, this isn’t a Blynk issue so much as a C++ coding issue, but you need to ensure that your code is Blynk friendly and doesn’t have anything other than and in your void loop.


Thank you friend.

As I said, I’m new to ESP8266. I need to learn how to program an interrupt by a rising or falling edge for the project to work.