# How would you go about building this?

Joined Jun 4, 2009
7
Hello everyone,

I hope I came to the right place for this type of question. Please assume that I am completely ignorant with regards to circuits/electronics (although if you can go into further detail, that would be very helpful in the long run).

I am looking to build a simple miniaturized door detection system with the following properties:

- System can detect when door is open and when door is closed.
- System stores this information in its memory along with the time when the door was open and when it was closed.
- One can extract this information and easily read it on a computer.

It is critical to keep it as small as possible (roughly the size of a bottlecap). If that is not possible, at what size would it be possible? Also, it can not be connected directly to a computer. What is the best form of energy source? More than one way of accomplishing this would be encouraged.

Thanks a lot guys. Looking forward to hearing from you.

#### bertus

Joined Apr 5, 2008
19,947
Hello,

You will need some microcontroller with a lot of memory.
(depending on how many events you want to record).
A real time clock IC.
A doorswitch.
When the door opens or closes you can read the "timestamp" from the RTC and store it in the memory of the microcontroller.

Greetings,
Bertus

Joined Jun 4, 2009
7

Follow up questions if you don't mind.

How much memory do you think it would require if it is only to be used for a duration of not more than 3 months, with it being triggered at an average rate of 3 times a day?

Given that required memory capacity, what will be the size and price of the microcontroller?

What is the size of a real-time clock? what is the size of a doorswitch? what is the type and size of the energy source it requires?

How will the transfer of information from the device to a pc for the information to be read take place?

Appreciate it very much, bertus. I am not expecting you to answer all of this. I realize it may be too much for one person to tackle. Just throwing it out there for anyone that may help.

#### bertus

Joined Apr 5, 2008
19,947
Hello,

To be honest, I am not a programmer.
I have found an application note on a microcontroller and a RTC chip.
See attached PDF.
The amount of memory will be dependent on what data you want to store.

Greetings,
Bertus

#### Attachments

• 61.6 KB Views: 30

#### PRS

Joined Aug 24, 2008
989
There's always more than one way to skin a cat. But some are more complicated and expensive than others. Let's see...

You want the condition of door open/closed to be detected and its time recorded.
But not directly connected to a computer. (This sounds like intrigue! Are you a spy? LOL)
And you want a complete recording over 3 months time?

Bertus chose the easy way. A microcontroller. But what if there is a simpler, cheaper way? Hm.

You need a clock.
You need a sensor for the door.
You need memory.

I think a dedicated sequential logic circuit would be a bit more complicated than using a microcontroller (I could be wrong, sounds like a good project), and therefore I agree with Bertus.

Joined Jun 4, 2009
7
Hello PRS,

Thank you for your input and for a different perspective on how to tackle this issue. I am interested in learning of as many ways as possible of achieving this, and then selecting using the following criteria:
Primary importance:
- Size
- Price

Secondary importance:
- Longevity

Simplicity/Complexity is not an issue for the moment although it would be welcomed as long as it is not at the expense of the other more important properties.

Would a dedicated sequential logic circuit be smaller? cheaper? longer-lasting (consumes less energy?).

Also, what type of sensor would be appropriate? Is it equivalent to the door-switch bertus mentioned earlier?

Thanks again fellas.

PS - I am not a spy, but I might be working for one

#### bertus

Joined Apr 5, 2008
19,947
Hello,

The doorswitch can be simple.
Mount a magnet on the door.
Mount a reed-contact on the doorpost.
Connect the reed-contact to the controller.
When the magnet moves away from the reed-contact its status will change.

Greetings,
Bertus

#### KL7AJ

Joined Nov 4, 2008
2,208
This can be done with a simple datalogger. It will record a time stamp every second (or any interval you choose) and report a data condition for each entry...which can be a simple contact closure...a 0 or a 1. You can then load the data in to a spreadsheet, and even do a plot.

Eric

#### mango matto

Joined Jun 2, 2009
13
What type of budget are you working with. You can get a burglar alarm most of the big name alarms have event logging for a reasonable price.

#### Propaganda

Joined Jun 3, 2009
22
Hi

My quick thoughts...

PICmicro MCU, RTC, EEPROM, switch, battery, and supporting components.

A PIC 16F688 should work fine... it is only 14 pins!... you can connect the PIC to the RTC and EEPROM via software SPI. You can retrieve the data VIA USART.

The RTC can be any really... most are 8pins... with that you will need a supporting crystal.

The smallest EEPROM are 8 pins and run a 50 cents for 2-32k...

The battery is easy.

Data size my thoughts are a you want to log when the door changes state... open to close or close to open.. that will allow to also determine if the door was held open. So the needed data are DATE, TIME, DOOR STATE... 7 bytes. 7 bytes * 2 (open then close) * 3 times a day * 90 days = 3780... so you data space is really not a concern considering you can get a 32k EEPROM for 44 cents! (small package too!)

So how to retrieve the data? Just hook up the project to a serial port (RS232) and send it a pretermined code such as '123' on the USART port... then the PIC can transmit the data in one long burst... from there the PC reads and writes the data to a TXT file... so now you can import it to EXCEL.

Project cost?

#### Zenock

Joined Jun 1, 2009
36
8pin SMD PIC, 12F629 (or 675)
8pin SMD 24LC256 eeprom
IR TX/RX pair
3v cell

Not many other parts needed, maybe 1 button to start the IR data output.
That would fit easy in the bottle cap size and cost about \$3 in parts without battery.
If the IR receiver is watching for door open or door close anyway. No reason not to have it also watch for patter to start data output, I'd leave the button off and be creative in my programming.

Z