Super new and trying to get up and running with a ESP8266 D1 Mini and Blynk.
I have two sketches, one where the D3 pin works and and another, with Blynk, in which it does not.
Setup, I have a D1 Mini with an LED in D3 and ground pins.
// This sketch works fine.
// The LED connected to Pin D3 on the D1 Mini blinks as it should.
void setup() {
Serial.begin(115200);
pinMode(D3, OUTPUT);
}
void loop() {
digitalWrite(D3, HIGH);
Serial.println("LED On");
delay(1000);
digitalWrite(D3, LOW);
Serial.println("LED Off");
delay(1000);
}
Now, If I swap out the following code and upload it to the D1 Mini, and I use my simple Bylnk app with a single virtual pin (V0) to attempt to turn the LED on and off I get the following results.
- It Successfully connects and talks to the Blynk app
- When I press the button on the Blynk app
a. the Built in LED (LED_BUILTIN) turns on and off correctly when my Blynk app button is pressed.
b. The D3 pin is always HIGH and the LED does not change it stays lit.
// This sketch is based on the example Sketch: Blynk -> Blynk.Edgent -> Edgent_ESP8266
#define BLYNK_TEMPLATE_ID "XXXXXXX"
#define BLYNK_DEVICE_NAME "Starter"
#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
#define APP_DEBUG
#include "BlynkEdgent.h"
void setup()
{
Serial.begin(115200);
pinMode(D3, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
delay(100);
BlynkEdgent.begin();
}
void loop() {
BlynkEdgent.run();
}
BLYNK_WRITE(V0) {
int pinValue = param.asInt();
Serial.print("Blynk Write V0: ");
Serial.println(pinValue);
if (pinValue == 1) {
digitalWrite(D3, HIGH); // Turn LED on.
digitalWrite(LED_BUILTIN, LOW);
Serial.println("-- HIGH");
} else {
digitalWrite(D3, LOW); // Turn LED off.
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("-- LOW");
}
}
I get the following output in the Serial Monitor when the button is pressed 3 times:
[8071] CONNECTING_CLOUD => RUNNING
Blynk Write V0: 1
-- HIGH
Blynk Write V0: 0
-- LOW
Blynk Write V0: 1
-- HIGH