Instructables
Ok, so for my first instructable I thought to share something I've just made today.
It's a logger for anything really that consist's of something being on or off ( in the door case, open / closed ).
For this to be applied to a door, the push-button has to be replaced to something like an hall effect sensor ( which I don't have thus the button).

All'right, what i've used:
- Arduino UNO
- DS1307 Real Time Clock
- SD shield ( from this instructable: http://www.instructables.com/id/Arduino-DIY-SD-Card-Logging-Shield )
- 1 led
- 1 push-button
- 220 ohm resistor , 10k resistor and hook-up wire



 
Remove these adsRemove these ads by Signing Up

Step 1: Connecting the parts

Picture of Connecting the parts
P4050007.JPG
SD card pins:
** MOSI  - pin D11 
** MISO  - pin D12
** SCK   - pin D13
** CS    - pin D4 
+ GND, 5v, 3.3v

RTC pins:
** SDA  - A4
** SCL  - A5
** GND - GND
** VCC  - 5V

Button + led pins:
** Led's - to 220ohm resistor to GND
** Led's + to D3
** Connect the button to 5V and D2  
** Connect 10k resistor from D2 to GND

Step 2: The code

As for the sketch, download it below.
External library used: adafruit's ds1307 lib ( https://github.com/adafruit/RTClib )

Now, to explain a few things:

variables:
* ok - it stop's the loop if the sd card was not initialized correctly
* first - it log's the first state, and then wait for the state to change before logging it again

functions:
* time() - get the time from RTC and convert it to a string
* SDwrite(int state) - write's on the SD card the time and a message depending on the state it receive's (1 or 0)
* call(int buttonState) - it's used to turn off/on the led and trigger the SDwrite() function

Feel free to contact me for any additional information.

That's it for my first instructable, I'm waiting for feedback.

backinthelab2 months ago

I'm a complete noob when it comes to arduino, so this really helped me out. Thanks! I made some modifications based on my particular use, such as omitting the LED, and changing some of the output text, but it works beautifully with the code provided. Essentially, I'm prototyping a data logger for use in my weld shop. When a weld fixture is loaded, it will actuate a spring pin that will hold down a button. When unloaded, the button will be released. This will give me the exact time that it takes for an assembly to be completed. The only other thing I'd like to do is have it log duration instead of a timestamp, but it's usable as-is so I'll igure out how to do it at some point. Once I get this off of the breadboard and solder up a working model, it should work great! Probably will make 10-15 more to cover the whole shop! Thanks again!