Hello Community of Blynkers I am really new to Blynk community and to node mcu I have 3 Query
-
I want to create program where PIR motion sensor state is taken and delay is set via slider in blynk app to turn relay on according to slider time.
I have tried to incorporate the same and working but Blynk app gets offline every time sensor detect presence. -
I want to use Blynk button to turn relay on/off but when sensor is connected its not working.so is there any way to use sensor and button in same relay module.
3)Unable to write long 10 digit number in eeprom
here is my code
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <EEPROM.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = " xxxxxxxxxxxxxxxxxxxxx";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Pxxxxxxxx";
char pass[] = "2345665";
int Status = 12;
int sensor = 16;
int relay = 5;
float r ;
float eeprom ;
BLYNK_WRITE(V0) { // timer switch
r = param.asInt()*60000;
EEPROM.write(eeprom,r);
}
void setup() {
EEPROM.begin(512);
EEPROM.commit();
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
pinMode(sensor, INPUT); // declare sensor as input
pinMode(Status, OUTPUT); // declare LED as output
pinMode(relay, OUTPUT); // declare LED as output
}
void relays_onoff()
{
long state = digitalRead(sensor);
if(state == HIGH){
digitalWrite (Status, HIGH);
digitalWrite (relay, LOW);
Serial.println("Motion detected!");
Serial.println(EEPROM.read(eeprom));
delay(EEPROM.read(eeprom));
}
else {
digitalWrite (Status, LOW);
digitalWrite (relay, HIGH);
Serial.println("Motion absent!");
}
}
void loop(){
Blynk.run();
relays_onoff();
}