Build an Arduino Intruder Alert using a Micro SD module and an IR Sensor
In this tutorial we’re gonna use the IR Obstacle Avoidance sensor to detect movement, and then write the time and date of the event to a MicroSD card with the help of the RTC1307 real time clock module we saw in the previous tutorial.
The IR sensor, like many others (the sound detection module for example), require only 1 pin that will go either HIGH or LOW when it is triggered.
The Arduino MicroSD module uses the SPI Bus.
The Arduino IDE already comes with a library to make writing to the card very simple.
So when the pin on the IR sensor goes LOW, we will get the time and date from the RTC1307 real time clock, and write the information on the MicroSD card.
The MicroSD module uses the SPI Bus and is connected to the SPI pins on the UNO:
SPI: 10 (CS), 11 (MOSI), 12 (MISO), 13 (SCK).
The DS1307 real time clock uses the I2C Bus and is connected to the I2C pins of the UNO:
I2C: A4 (SDA) and A5 (SCL).
The IR Obstacle Avoidance sensor can be connected to any digital pin.
It’s connected to pin 2 in our tutorial.
We use a breadboard to connect the VCC and Ground to both modules from our UNO.
We are using a couple of libraries in this tutorial:
The DSRTC1307 Arduino Library for the DS1307 real time clock.
We also include the Wire.h and Time.h library for the I2C Bus and Time manipulation.
The Wire.h and the SD.h library for the MicroSD Module are included with the Arduino IDE software.
First thing we need to do is initialize our DS1307 module with the current date and time.
We do this by running the “SetTime” sketch that comes with the DSRTC1307 library.
After this, we will upload the main code that will write the Time and Date when motion is detected.
As always please watch our Tutorial video for more information.