Go Down

Topic: Security System Time Logging. (Read 250 times) previous topic - next topic

Hi, i've recently built a security system for my grandfather, and everything works as is, however, I want to add a feature that creates a log file of all the times that the security system is triggered.

The system will be standalone from a computer and will have an external power supply.

here is my code. what should i do from here?
Code: [Select]

int time = 30;

void setup(){
  //start serial connection
  Serial.begin(9600);
  //configure pin2 as an input and enable the internal pull-up resistor
  pinMode(7, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);
  pinMode(8, OUTPUT);

}

void loop(){
  //read the pushbutton value into a variable
  int switchVal = digitalRead(7);
  int sensorVal = digitalRead(2);
  //print out the value of the pushbutton
  Serial.println("Sensor" + sensorVal);
  Serial.println("Switch" + switchVal);
 
  // Keep in mind the pullup means the pushbutton's
  // logic is inverted. It goes HIGH when it's open,
  // and LOW when it's pressed. Turn on pin 13 when the
  // button's pressed, and off when it's not:
  if (sensorVal == HIGH && switchVal == LOW) {
   tone(8, 3000, time*4);
delay(time*4);
tone(8, 2800, time*4);
delay(time*4);
  }
 
}





Peter_n

Logging to a file on a (micro)SD card ?
You need a shield with a SD socket.
http://www.adafruit.com/products/1141
There are other shields (ethernet, audio) that have a SD socket included.

You also need a chip that is a clock. The DS1307 is the most common.
http://www.adafruit.com/products/264

PaulRB

#2
Jul 19, 2014, 07:24 pm Last Edit: Jul 19, 2014, 07:52 pm by PaulRB Reason: 1
Hi,

How exactly do you want to log the events? For how long? How often are they likely to occurr?

How do you want to review the events and once you have reviewed them, do you need to keep the data long term?

I agree with Peter thay you need an rtc. However, an sd card may be overkill. Arduinos usually have 1K of eeprom memory, and if that is not enough, many rtc come with a larger amount on the same module. Its just that this memory is not removeable for archiving, but do you need that?



For reviewing the data, I would suggest a 16×2 lcd. One with an i2c interface would make it easier to use for a beginner.

http://www.ebay.co.uk/itm/DS3231-AT24C32-IIC-Precision-RTC-Real-Time-Clock-Memory-Module-For-Arduino-/400624291795?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item5d47118fd3

http://www.ebay.co.uk/itm/Blue-Display-IIC-I2C-TWI-SP-I-Serial-Interface-1602-16X2-Character-LCD-Module-/161096292800?pt=LH_DefaultDomain_0&hash=item25821659c0


Are you a fan of the Uno/shield format, or are you prepared to do some soldering?

Paul

raschemmel

I'm not following any of this. I looked at that code and didn't see anything that said anything about "triggering the system"
I have no idea what that sketch is supposed to do or what it has to do with any security system. Can someone enlighten me as to how that sketch is related to the OP's desire to log when the security system is triggered ?
(show me where the code mentions "SYSTEM TRIGGERED !"

I just don't see it.

Yeah I'm not a professional programmer but do I need to be ? Shouldn't it say something about TRIGGERING if that is in fact what it is logging or am I asking too much ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter


Hi,

How exactly do you want to log the events? For how long? How often are they likely to occurr?

How do you want to review the events and once you have reviewed them, do you need to keep the data long term?

I agree with Peter thay you need an rtc. However, an sd card may be overkill. Arduinos usually have 1K of eeprom memory, and if that is not enough, many rtc come with a larger amount on the same module. Its just that this memory is not removeable for archiving, but do you need that?



For reviewing the data, I would suggest a 16×2 lcd. One with an i2c interface would make it easier to use for a beginner.

http://www.ebay.co.uk/itm/DS3231-AT24C32-IIC-Precision-RTC-Real-Time-Clock-Memory-Module-For-Arduino-/400624291795?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item5d47118fd3

http://www.ebay.co.uk/itm/Blue-Display-IIC-I2C-TWI-SP-I-Serial-Interface-1602-16X2-Character-LCD-Module-/161096292800?pt=LH_DefaultDomain_0&hash=item25821659c0


Are you a fan of the Uno/shield format, or are you prepared to do some soldering?

Paul


hi, sorry for the late reply, i've liked your method the best. thanks. I'm wanting it to trigger every moment the security system goes off. its for my grandfather, he will not need to know any more than turning the system on and off. (i added a switch for that).

I'd like to be able to have the system run 24/7 and log every trigger. i'd also like to be able to delete all data except the recent weeks data every month to save memory. how would i go about doing that?

also, I already have about 4 wires in the digital pins of the uno r3. thats how my system is running. would i be able to add the clock right on top of that?

thanks a ton! (sorry for late reply)


I'm not following any of this. I looked at that code and didn't see anything that said anything about "triggering the system"
I have no idea what that sketch is supposed to do or what it has to do with any security system. Can someone enlighten me as to how that sketch is related to the OP's desire to log when the security system is triggered ?
(show me where the code mentions "SYSTEM TRIGGERED !"

I just don't see it.

Yeah I'm not a professional programmer but do I need to be ? Shouldn't it say something about TRIGGERING if that is in fact what it is logging or am I asking too much ?


I hardly have any text output at all. The code i put only make a buzzer ring when triggered. Don't worry, i'm not a pro programmer either, i just graduated high school lol. let me guide you through the part of my code that matters.

Code: [Select]

//previous code irrelevant

//triggers are inverted, HIGH means off and LOW means on.

  if (sensorVal == HIGH /* door is open*/ && switchVal == LOW /*Switch is turned on*/)
{

//make a ringing noise as tone(pin#,frequency,previously_initialized_time);
tone(8, 3000, time*4);
delay(time*4);
tone(8, 2800, time*4);
delay(time*4);

  }
 


raschemmel

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

PaulRB

#7
Jul 20, 2014, 08:21 am Last Edit: Jul 20, 2014, 09:08 am by PaulRB Reason: 1
To add the rtc and the lcd (if you get one with i2c interface as I suggested), you must use the Arduino outputs marked SDA and SCL on some diagrams. I do not think they are marked as such on the uno itself. I think they are the A4 and A5 outputs

As for deleting old event data, the simplest way is probably to let the memory fill up, and when it does, overwrite the oldest event with the new one when the alarm is trigerred. Apart from the date and time, what needs to be recorded? A code to indicate which trigger activated the alarm? If so, each event will take up around 10 bytes of memory. If using the Arduino's internal eeprom memory, this will allow 100 events to be recorded. Will that be enough? The rtc I linked to has 32K bits = 4K bytes of eeprom memory which could hold 400 events.

So, my other question: pre-made shields only, or soldering?

PeterH

You say it's a standalone unit, but will there be a PC anywhere near it? If so, adding a network interface or radio connection to the PC would enable you to do the logging on the PC where you would be in a position to do much more - for example sending email or SMS notifications, or uploading the log to off-site storage - as well as making it trivial to timestamp the notifications.
I only provide help via the forum - please do not contact me for private consultancy.

Go Up