Security alarm system

Hi blynk, I want to make motion sensor, I want to set the alarm whenever I want, when I want to disable, you can share sample code?

Security alarm on!
securtiy alarm off button
The constant notification in normal conditions is coming, but when I have activated I want the notification to come to me, the notification comes in every movement at home.

Hi. here use my code:
using the V0 to disable and enable the alarm

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

char auth[] = "xxxxxxxxxxxxx";
char ssid[] = "xxxxxxxxxxxxxx";
char pass[] = "xxxxxxxxxxxxx";
char server[] = "";

#define ledPin 12 
#define pirPin 14

int pirState;
int val;
int x;

SimpleTimer timer;


 x = param.asInt();

void PIRval(){
val = digitalRead(pirPin);
    if (val == HIGH) {
      digitalWrite(ledPin, HIGH);  
      else {
        digitalWrite(ledPin, LOW); 

  void pir(){
  if (x == 1){
    if (digitalRead(pirPin) == HIGH){

void setup(){
  Blynk.begin (auth, ssid, pass, server, 8080);//local server
   // You can change server:
  //Blynk.begin(auth, ssid, pass, "", 80);

  pinMode(ledPin, OUTPUT);
  pinMode(pirPin, INPUT);

  timer.setInterval(1000L, PIRval);
 timer.setInterval(1000L, pir);

void loop(){;;
1 Like

thanks, char server write my local ip?

i use this code, but not connect blynlik app, my device is everytime offline

If you are using a Local Server, then yes… use the IP for that, otherwise edit the code to use the normal Cloud server connection.

1 Like


Make sure you are doing as just below.

  1. You are connected in the same network your ESP connected.
  2. Your Auth key must be the same as in your Blynk project. you can verify in your project

if after this you are facing the problem, try to replace Blynk.begin(auth, wifi, ssid, pass); to Blynk.begin(auth, wifi, ssid, pass, “”, 8080); or Blynk.begin(auth, wifi, ssid, pass, “”, 80);

It will work


Ravindra Prajapati


FYI, So as not to confuse new users… when using the Blynk.begin(auth, wifi, ssid, pass); command the correct Cloud URL and port are automatically assumed by the library.

Yes it takes default but sometimes it’s not taking the default value that time we need to define it.

This is was experience by me.

1 Like

ok thanks, :slight_smile:

This code sensor pin 14, i use esp8266 generic and one motion sensor, pin settings?

Sounds like the Geo DNS problem that was solved last year… if you are still running into issues please open up a new topic with details.

1 Like

Can you clarify your question… do you understand enough programming to edit the example provided (for your use)… Or how the Blynk App works with virtual pins for App control, thus it shouldn’t matter what board setting you use.

1 Like

i want use asp8266 standolen only pin gpo0 and gp02

#define ledPin 12
#define pirPin 14

i change

#define ledPin 12
#define pirPin 0
this ture?

I don’t know… depends if that is the pin you are plugging your PIR input into? What about your LED?

However, It is NOT one of the recommended pins (using GPIO numeration NOT the Dpin ones) to use when others are available

Or are you referring to using an ESP-01 device? (otherwise, ALL other ESP8266 devices are considered “standalone”) If so, then yes, since you only have a few pins available, try them and test for yourself.

1 Like

Hi this code works fine. I want to add 1 smoke detector and 1 water dominant detector in this code. The v0 pin will only turn the motion detector on and off. Other detectors will be active for 24 hours. When the water detector detects a problem, I want to switch off the solenoid valve with a relay.

hi i am waiting a help :slight_smile:

You’ve been gifted some excellent code, and you’ve then proceeded to change the GPIO pins. You received some feedback about this, but you insist that what you’re doing is okay.

You’ve then said that you have some further requirements, then 80 minutes later say that you’re still waiting for help with these requirements.

Personally, I think that you’re very lucky to be given the working code from @ErfanDL, and the advice regarding GPIO usage from @Gunner. It’s now time to roll your sleeves up and do the rest yourself, and if you request advice about a specific issue along the way then take heed of any advice you receive.



@ykilicaslan Please don’t post PM to me begging for help in the title and a link here (I moved it back here)… not that begging in your existing topic will help much either :stuck_out_tongue: Please learn with what we have already supplied.

1 Like

ok thanks.