Security alarm system


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.

you can not using two analog sensors with the ESP8266 boards. the ESP8266 only supported one analog pin. I thing your smoke and water dominant sensor is analog ! so you must using an Arduino board to supporting more analog pins.

i use now esp8266 nodemcu

He could use an analogue multiplexer, but a better option would probably be to use multiple ESP devices.
In reality, these sensors aren’t likely to be in the same physical place within the house, so multiple devices, with each located next to the area where the sensor is needed, is probably a better solution.

However, it seems that @ykilicaslan needs to invest some time in learning how to code, and how best to use Blynk, so I doubt that his alarm system will actually materialise.

On the subject of alarms, I came across this YouTube video the other day:

It seems like a really neat solution to adding IoT notifications to a standard battery powered alarm. If I was doing this then I’d probably go with the MQTT notification as described in the video, but it would be just as easy to add a Blynk notification, or use a Blynk API call.



hi this code is for 1 sensor. I have added it to the water and gas sensor, when the sensor detects the ALARM MESSAGE, when it detects the gas sensor, I want to write GAS ALARM. Could you help
my board : esp8266 nodemcu

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

char auth[] = "7b2f0486955b41b2aecfb2551f5f2975";
char ssid[] = "okhan";
char pass[] = "atakan2009";

#define ledPin 14 
#define pirPin 12
#define gazPin 13
#define suPin 15

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);
  pinMode(gazPin, INPUT);
  pinMode(suPin, INPUT);
Serial.println("WiFi connected");  
  Serial.println("IP address: ");
  timer.setInterval(1000L, PIRval);
 timer.setInterval(1000L, pir);

void loop(){;;

Hello… We try to teach about Blynk, we do not write your code for you, that is up to you to learn.

You are trying to run both of these function at the exact same time every second… if you need then to run together, then combine them into ONE function, otherwise stagger the timers so they runs separately without convergence… e.g. 1000 = every second for one and 1300 = every 1.3 seconds for the other.

1 Like