Need guidance with pir sensor project

Hello to all,

This is my first time on this forum.

I am learning Arduino at the moment and started a project.

I have a keypad from aliexpress that when enters the right pincode or use rfid the relay sends 5v. and i read pir sensor.
So far i can get the keypad and pirsensor working and read there value's

Now the hard part.

The keypad sends 5v for 5 seconds and then 0V.

How would i approach the following:

  • Voltage on system / turn on
  • Keypad is active and pir sensor values are coming in. / alarm on
  • Enter pincode or use Rfid.
  • System goes to inactief.
  • do nothing with pir sensor values / alarm off

When i want to activate the alarm again, by entering pin or use rifd again how to know that state is alarm off or on and reactivate alarm again?

I hope you can guide me in the good direction.

Kalis

What does that mean?

I'd use an led (or maybe more than one) but one would work:

  • led off= no power
  • led solid on= power on, system disarmed
  • led blinking= power on, system armed

... or something along those lines anyway. Perhaps a beeper (like my next door neighbour's annoying house alarm) that beeps once when they arm, and twice when they disarm.

Good that you used the word "state" though- this project is perfect for a state machine approach.

When you enter the right Pincode there is a relay in the keypad unit. I input 5v in COM and NO sends out to arduino.

Its not that i do not know when alarm is off or on. When 1st time i insert Pincode and 5v gets to arduino. How to store this in the arduino that alarm is off? so the next time i enter a Pincode the arduino see that alarm is already off so it will set it to On!

Kindly share the link the keypad and RFID reader that you're using.

Wait a minute... are you saying that with the Arduino turned off, the keypad is used to enter a pin that then activates a relay to turn the Arduino on? If that's the case, how do you read the keypad? Maybe I misunderstood?

This needs a schematic to show the system wiring and components, and perhaps a flow chart or state diagram to explain the states and actions.

here is the link to the product! scroll down to see backside and what i mean with COM and NO or NC

https://nl.aliexpress.com/item/1005004101903249.html?spm=a2g0o.productlist.0.0.656e6bf74W6sny&algo_pvid=63369aae-dcd8-4ef9-aea7-727fe15d4ae0&algo_exp_id=63369aae-dcd8-4ef9-aea7-727fe15d4ae0-19&pdp_ext_f={"sku_id"%3A"12000028036539442"}&pdp_npi=2%40dis!EUR!!29.54!!!!!%402100bddb16532990885861437ee96e!12000028036539442!sea

I tried with a boolean Alarmstate.

Alarmstate = true

void ReadLockIN() {
if (Alarmstate=true) {
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
if (voltage == 5.00)
{
Alarmstate = true;
PirsensorOff();
}
}
else {
Alarmstate = false
PirsensorOn();
}
}

You haven't answered my question in #5. Maybe you think #6 is an answer?

Let me ask explicitly again: Does the successful reading of the keypad / rfid tag happen with no reference to the Arduino, so that the relay which seems to be part of the reader powers the Arduino? But then you say it's only on for 5 seconds, presumably to unlatch a lock, so how does that provide power to the Arduino? Or is the Arduino actually powered up all the time, and you want this 5s signal to tell it the keypad / tag was read?

Diagram and flowchart please or I'm out.

5V signal from keypad is the only thing i want to read with arduino. As i said i recieve the 5v and i can do something with it.

Only thing i dont know is how to let arduino know if 5v signal is send before. So i can make a alarm of or on statement!

And Diagram and Flowchart...how do i create that??

OK eventually it's beginning to get clearer in my mind. Have a look at statechangedetect in File / Examples in the IDE, which will allow you to see the change on a pin. Your reader is very much like a button which is active high; does the reader output explicitly remain low if not high though? If not you may need a pull down resistor on the pin to make sure it's kept low until it's meant to be high.

Well there are numerous tools available for that stuff, but pen and paper's the easiest!

Thank you for your help, i will take a look at the statechangedetect.
Will let you know the outcome :slight_smile:

Have a nice day!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.