hello I am having some trouble, I am trying to control my relays from my IOS device, everything is working fine. The only problem is that in my country the electricity go some times so when the nodemcu restart the relays turn on. My question is how can I do it so when the board restart the relays stays off.
-arduino nodemcu esp8266
-blynk server
this is my code
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "...";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "...";
char pass[] = "...";
void setup()
{
// Debug console
{ Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
}
void loop()
{
{
Blynk.run();
}
}
then I tried using this code
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define relay_pin 2
#define relay_pin2 8
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "...";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "...";
char pass[] = "...";
void setup()
{
pinMode(relay_pin, OUTPUT);
pinMode(relay_pin2, OUTPUT);
digitalWrite(relay_pin, LOW);
digitalWrite(relay_pin2, LOW);
}
// Debug console
{ Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
{
Blynk.run();
}
}
If you’re referring to the characters highlighted in yellow then this is because the NodeMCU is outputting some boot-up information at its native baud rate, usually 74880, and you have your serial monitor running at 9600, so the NodeMCU output is corrupted.
If you set your serial monitor to 74880 and reboot the board then the NodeMCU messages will make sense, but your serial output from your sketch will be garbled.
The solution is to change this line:
to this:
Serial.begin(74880);
and your serial monitor to 74880 as well, then both the NodeMCU and the debug output from your sketch will make sense.
Do your relays go out when you boot your board now?