First off, I love Blynk and this Forum! It has helped a newbie like me start my first project! I’ve searched for a solution in Google and the Forums However I Can’t seem to find the answer. I’m having issues with a particular piece of the project. I’m working with a NodeMCU connected to a linear actuator. The actuator is switched forward/reverse by a relay (ICND1/2). I have a Reed Sensor attached that will cause the LCD to diplay “Door Open” or “Door Closed” depending on the sensor.
However, the Display is displaying the P 1 0 value found in my code before my text on the LCD screen in the App even though it’s not in the quotations. It’s doing this for both Closed and Open states.
Other than that, the code is working exactly as I’d want.
Code is below. Does anything stick out???
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "";
char ssid[] = "";
char pass[] = "";
#define D0 16
#define D1 5
#define D2 4
#define D3 0
#define D4 2
#define D5 14
#define D6 12
#define D7 13
WidgetLCD lcd(V10);
int inPinVal ; //Virtual Pin Input
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(D7, OUTPUT); //IND2
digitalWrite(D7, HIGH);
pinMode(D2, INPUT_PULLUP); //magnetic sensor
pinMode(D6, OUTPUT); //IND1
//Widget Button using virtual pin 7
}
BLYNK_WRITE(V7)
{
if (param.asInt() == 0)
{
digitalWrite(D6, HIGH); //Forward or Close
digitalWrite(D7, LOW);
}
else
{
digitalWrite(D6, LOW); //Reverse or Open
digitalWrite(D7, HIGH);
}
}
// Door Magnetic Monitoring
bool current = 0;
bool previous = 1;
void doorOpen() {
lcd.print(1, 0,"Door OPEN"); // LCD print, column 1, row 1
}
void doorClose() {
lcd.print(1, 0,"Door Closed");
}
void doorMagSensor()
{
current = digitalRead(D2); // Door Magnetic Switch
if (current != previous)
{
previous = current; //reinitialize
if (current == LOW)
{
doorClose();
}
else
{
doorOpen();
}
}
}
void loop()
{
doorMagSensor();
Blynk.run();
}