Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Multiple ultrasonic sensor doesn't work while connecting with NODEMCU and Blynk App

Status
Not open for further replies.

ZJ0518

Newbie
Joined
Jun 24, 2019
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
28
Hey, I faced this issue where when I only connect one ultrasonic sensor to the NodeMCU and Blynk App, the Blynk app did notify me when someone is passing by the sensor. When I added on another ultrasonic sensor to the NodeMCU, the blynk app didn't notify me when I interrupted both sensors.
Attached below is my code to interface the ultrasonic sensors with the NodeMCU and blynk app. Please help me out guys... Thank you!

Code:
Code:
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#define echoPin1 D1

#define trigPin1 D2

#define echoPin2 D3

#define trigPin2 D4





char auth[] = "***";

char ssid[] = "***";

char pass[] = "***";



long duration1;

float distance1;

long duration2;

float distance2;



void setup() {

  // put your setup code here, to run once:

  Serial.begin(9600);

  Blynk.begin(auth,ssid,pass);

  pinMode(trigPin1,OUTPUT);

  pinMode(echoPin1,INPUT);

  pinMode(trigPin2,OUTPUT);

  pinMode(echoPin2,INPUT);

}



void loop() {

  // put your main code here, to run repeatedly:

  digitalWrite(trigPin1,LOW);

  delayMicroseconds(2);

  digitalWrite(trigPin1,HIGH);

  delayMicroseconds(10);

  digitalWrite(trigPin1,LOW);

  duration1 = pulseIn(echoPin1,HIGH);

  distance1 = duration1 *0.34/2;

 

  digitalWrite(trigPin2,LOW);

  delayMicroseconds(2);

  digitalWrite(trigPin2,HIGH);

  delayMicroseconds(10);

  digitalWrite(trigPin2,LOW);

  duration2 = pulseIn(echoPin2,HIGH);

  distance2 = duration2 *0.34/2;





  if (distance1 <= 1000){

    Blynk.virtualWrite(V1,255);

    Blynk.notify("Intruder passing by sensor1 !");

  }

  else{

    Blynk.virtualWrite(V1,0);

  }

 if (distance2 <= 1000){

    Blynk.virtualWrite(V2,255);

    Blynk.notify("Intruder passing by sensor2 !");

  }

  else{

    Blynk.virtualWrite(V2,0);

  }

  Blynk.run();
  }
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top