Home Security Using Doppler Radar( New version HB100X adjustable)

Hello Everyone,
I am kind of new to Arduino coding in this detailed, but have done a gaming platform involving serial communication, but I am far from the experts here in this forum and appreciate any help or guidance as to why some problems are occurring. I have a couple of questions concerning the coding of multiple identical sensors (New circle version HB100X adjustable) and the way to get them to work independently no matter which one is triggering the 4 Bank relays.

Coding maybe be messy or not correct but like I mentioned any help or guidance will be greatly appreciated, just getting tired of people stealing my hard earned stuff from my property.

Q1. example problem- if relay1 has been triggered... R2,R3,R4 will not trigger until R1 has triggered off, but if R2,R3,R4 has been triggered R1 will trigger fine?

Q2. Can I create 4 separate folders for each of the Doppler Radar units or is there a better way of isolating them with coding?

Q3. Does anyone know if I will have to add Frequency code with the New 3pin version of the HB100X if I am not worried about speed or frequency, I'm only worried about the detection with in distance of my property?

Hardware as follows,
Gen Arduino Mega 2560

4 New circle version HB100X adjustable 3pin V+, G-, Out (from ebay)https://sparkfruit.ph/product/mh-et-live-hb100-x-10-525ghz-microwave-sensor/

5v 4 channel relay
2 Sound modules
4 HD camera - Will work independently and may not be directly connected to the mega2560 Not sure yet
1 alarm buzzer (for all relays) 3-24v
4 10mm LED pre-wired

/*Doppler Radar Test Arduino Mega 2560*/

// Analog Pins used 
   int dopplerA4 = A4;
   int dopplerA6 = A6;
   int dopplerA8 = A8;
   int dopplerA10 = A10;
   int soundsensA12 = A12;
   
// Digital Pins used   
   int relay2 = 2;
   int relay3 = 3;
   int relay4 = 4;
   int relay5 = 5;
   int alarm6 = 6;
   
// Read the sensors
   int analogValue = 0;
   int sensorRead = 0;
   int sensorValue = 0;
   int sensValue = 0;
   int sensRead =0;
   
// threshold value setting to decide when motion is detected.
    int threshold = 400;      

    void setup() {
// Setup serial monitor                    
    Serial.begin(9600);
             
// Initialize input pins
    pinMode (dopplerA4, INPUT);
    pinMode (dopplerA6, INPUT);
    pinMode (dopplerA8, INPUT);
    pinMode (dopplerA10, INPUT);
    pinMode (soundsensA12, INPUT);
   
// Initialize output/ high or low
    pinMode (relay2,OUTPUT);
    digitalWrite(relay2,HIGH);
    pinMode (relay3,OUTPUT);
    digitalWrite(relay3,HIGH);
    pinMode (relay4,OUTPUT);
    digitalWrite(relay4,HIGH);
    pinMode (relay5,OUTPUT);
    digitalWrite(relay5,HIGH);
    pinMode (alarm6,OUTPUT);
    digitalWrite(alarm6,HIGH);
}                               
// Main loop
    void loop() {
    analogValue = analogRead (dopplerA4);
    sensorRead = analogRead (dopplerA6);
    sensorValue = analogRead (dopplerA8);
    sensValue = analogRead (dopplerA10);
    sensRead = analogRead (soundsensA12);
    
// if the sensor reading is greater than the threshold.
   if (analogValue >= threshold) {
    // toggle the status of the relayPin (LOW is On) (HIGH is OFF).
    digitalWrite(alarm6, LOW);
    digitalWrite(relay2, LOW);
    Serial.println("Alarm Triggered!");     // send the string "Alarm On!" back to the computer.
    Serial.println("Relay2 On!");
   
    
    }else{
    digitalWrite(alarm6, HIGH);
    digitalWrite(relay2, HIGH);
    Serial.println("Alarm OFF!");          // send the string "Alarm On!" back to the computer.
    Serial.println("Relay2 OFF!");
    delay (500);
       
    if (sensorRead >= threshold) {
    digitalWrite(alarm6, LOW);
    digitalWrite(relay3, LOW);
    Serial.println("Alarm Triggered!");   // send the string "Alarm On!" back to the computer.
    Serial.println("Relay3 On!");
   

    }else{ 
    digitalWrite(alarm6, HIGH);
    digitalWrite(relay3, HIGH);
    Serial.println("Alarm OFF!");         // send the string "Alarm OFF!" back to the computer. 
    Serial.println("Relay3 OFF!");
   delay (500);

   if (sensorValue >= threshold) {
 // toggle the status of the relayPin (LOW is On) (HIGH is OFF).
    digitalWrite(alarm6, LOW);
    digitalWrite(relay4, LOW);
    Serial.println("Alarm Triggered!");     // send the string "Alarm On!" back to the computer.
    Serial.println("Relay4 On!");
   
    }else{
    digitalWrite(alarm6, HIGH);
    digitalWrite(relay4, HIGH);
    Serial.println("Alarm OFF!");          // send the string "Alarm On!" back to the computer.
    Serial.println("Relay4 OFF!");
    delay (500);
   }
}
}
}

Doppler_Radar_Test_Mega_10.12.2019.ino (3.06 KB)

Read "How To Use This Forum"

in particular, 7. If you are posting code or error messages, use "code" tags

This is what happens when you do not

add a link to the radar that includes a link to the datasheet. help us help you.

people here respect those who come prepared, and disrespect those who do not

Geek Emeritus,
I'm Very sorry for the not following the forums guideline's and it will not happen again.

Not getting any errors just this problem...
example problem- if relay1 has been triggered... R2,R3,R4 will not trigger until R1 has triggered off, but if R2,R3,R4 has been triggered R1 will trigger fine

I am not someone you need to apologize to.

// Analog Pins used
   int dopplerA4 = A4;
   int dopplerA6 = A6;
   int dopplerA8 = A8;
   int dopplerA10 = A10;
   int soundsensA12 = A12;

are these the outputs of the sensors? assuming that is true:

you read them all in at once

// Main loop
    void loop() {
    analogValue = analogRead (dopplerA4);
    sensorRead = analogRead (dopplerA6);
    sensorValue = analogRead (dopplerA8);
    sensValue = analogRead (dopplerA10);
    sensRead = analogRead (soundsensA12);

and act on only three of them:

// if the sensor reading is greater than the threshold.
   if (analogValue >= threshold) {
    // toggle the status of the relayPin (LOW is On) (HIGH is OFF).
    digitalWrite(alarm6, LOW);
    digitalWrite(relay2, LOW);
    Serial.println("Alarm Triggered!");     // send the string "Alarm On!" back to the computer.
    Serial.println("Relay2 On!");
  
    
    }else{
    digitalWrite(alarm6, HIGH);
    digitalWrite(relay2, HIGH);
    Serial.println("Alarm OFF!");          // send the string "Alarm On!" back to the computer.
    Serial.println("Relay2 OFF!");
    delay (500);
      
    if (sensorRead >= threshold) {
    digitalWrite(alarm6, LOW);
    digitalWrite(relay3, LOW);
    Serial.println("Alarm Triggered!");   // send the string "Alarm On!" back to the computer.
    Serial.println("Relay3 On!");
  

    }else{
    digitalWrite(alarm6, HIGH);
    digitalWrite(relay3, HIGH);
    Serial.println("Alarm OFF!");         // send the string "Alarm OFF!" back to the computer.
    Serial.println("Relay3 OFF!");
   delay (500);

   if (sensorValue >= threshold) {
 // toggle the status of the relayPin (LOW is On) (HIGH is OFF).
    digitalWrite(alarm6, LOW);
    digitalWrite(relay4, LOW);
    Serial.println("Alarm Triggered!");     // send the string "Alarm On!" back to the computer.
    Serial.println("Relay4 On!");
  
    }else{
    digitalWrite(alarm6, HIGH);
    digitalWrite(relay4, HIGH);
    Serial.println("Alarm OFF!");          // send the string "Alarm On!" back to the computer.
    Serial.println("Relay4 OFF!");
    delay (500);
   }
}
}
}

by repeating the same code three times.

it's a whole lot easier for me to say this than it will be for you to do it, but here we go:

write a block of code that does what you need done with the sensor output. give it a name, like sensorHandler ( you can't use spaces or dashes, so we capitalize mid-word ) and make that into a function:

void sensorHandler()

your code here

this is a function.

you call functions from inside void loop().

find projects in the project hub that poll multiple sensors to see where to go from there

search terms: arduino function, arduino for loop, and arduino arrays

the first code block is the sensor

// Analog / Digital Pins used 
   int dopplerA4 = A4;
   int dopplerA6 = A6;
   int dopplerA8 = A8;
   int dopplerA10 = A10;
   int soundsensA12 = A12;   
   int relay2 = 2;
   int relay3 = 3;
   int relay4 = 4;
   int relay5 = 5;
   int alarm6 = 6;

inputs

// Read the sensors
   int analogValue = 0;
   int sensorRead = 0;
   int sensorValue = 0;
   int sensValue = 0;
   int sensRead =0;
// Initialize input pins
    pinMode (dopplerA4, INPUT);
    pinMode (dopplerA6, INPUT);
    pinMode (dopplerA8, INPUT);
    pinMode (dopplerA10, INPUT);
    pinMode (soundsensA12, INPUT);

Yes I have only 3 of the sensors setup, was going to continue when discovered the problem concerning the relays.

// Initialize output and high or low
    pinMode (relay2,OUTPUT);
    digitalWrite(relay2,HIGH);
    pinMode (relay3,OUTPUT);
    digitalWrite(relay3,HIGH);
    pinMode (relay4,OUTPUT);
    digitalWrite(relay4,HIGH);
    pinMode (relay5,OUTPUT);
    digitalWrite(relay5,HIGH);
    pinMode (alarm6,OUTPUT);
    digitalWrite(alarm6,HIGH);

So I think I know what your saying and I will look in the project hub,