Jump to content

Door open/close detection


Recommended Posts

Hey,

 

I'm, just trying to find a simple way to relay the information about a door at home, if it's opened or closed. I tried to understand if the bricklet would help me but I'm not sure what it is actually.

 

Is it autonomus as in could I just check via a Javascript / PHP page that the door is open or closed with the sensor?

 

Thanks!

Link zu diesem Kommentar
Share on other sites

Hi,

 

Bricklets have to be connected to a Brick (e.g. a Master Brick). This Brick can be connected to a (Embedded-) PC (e.g. Raspberry Pi) where a small software called Brickd is running. This software handles the USB connection and provides an TCP/IP port. Our bindings, e.g. the PHP bindings, will connect to this TCP/IP port and deliver the information over it. Therefore you can connect the Bricks/Bricklets to one PC and control them over others (e.g. your Smartphone).

 

One way to leave out the PC in between is the usage of a Master Extension. You can use a WIFI Extension or a Ethernet Extension (will be available soon) to connect to the Brick/Bricklets directly.

Then there is no need for a PC and you can control them directly with your PHP script.

Link zu diesem Kommentar
Share on other sites

That sounds very interesting!

 

Let me know if I understand correctly: when the Wifi Extension will be out, I'll just need the bricklet (door sensor) and the Wifi extension plugged to it and it'll send a notice via the Wifi network and it'll get to my PHP script?

 

When is it supposed to be out? Any timeframe?

 

Also, can this solution be powered only by battery? If so, how long should I expect the battery to last?

 

Thanks a lot!

Link zu diesem Kommentar
Share on other sites

Let me know if I understand correctly: when the Wifi Extension will be out, I'll just need the bricklet (door sensor) and the Wifi extension plugged to it and it'll send a notice via the Wifi network and it'll get to my PHP script?

 

First of all, you'll need a Brick to make that setup work, because Bricklets on their own are basically just sensors or actors. The need to be connected to a Brick (that's where the logic is) to get a working system. But then it basically works as you describe it. Let me give you some details:

 

There are different approaches to detect a door opening/closing.

 

a) You could use a Master Brick with an IO-4 Bricklet and a microswitch (or any other kind of push button). The microswitch gets connected to the IO-4 Bricklet. This allows the Master Brick to readout the microswitch status: open or closed. To detect the door status the microswitch is mounted to the door frame in a way that the closed door closes the switch and opening the door also opens it. Now your website can periodically query the status of the microswitch to get the door status.

 

You can also configure the IO-4 Bricklet to send you a callback if the status of the microswitch changes and the you can react on this event. The problem with this is that it requires a continuously running program, but a website doesn't meet this criteria.

 

b) Another approach would be to use a Master Brick with a Distance IR Bricklet and mount the Bricklet to the door frame in a way that it measures different distances depending on the door being opened or closed. Again your website could query for the distance or you could configure a callback for a continuously running program to be informed about changes in the distance.

 

c) There are probably some more ways to do this than just the two :)

 

There are also different approaches for connection the Master Brick to your PC hosting your website.

 

a) The simplest way is to connect it directly via USB, then the Master Brick and the connected Bricklet is also powered via USB.

 

b) You could also connect a WIFI Extension (that is already available) to the Master Brick. Then your PC can connect to the stack directly via WIFI. Now you need to power the stack. This can be done via an USB power supply connected to the USB port of the Master Brick. Another option is a Step-Down Power Supply that is connected to the bottom of the stack and can handle DC input voltage of 6-27V. You can also supply the power from a battery to USB (5V) or the Step-Down Power Supply (6-27V). How long the battery will last depends on your particular battery, the actual Bricklet used to detect the door status and your WIFI configuration. The power consumption of the different devices can be found in the documentation. A rough guess for the power consumption of this setup is probably about 100-250mA I think, but don't quote me on that :)

 

c) You could also connect an Ethernet Extension (this one is coming soon) to the Master Brick. Then your PC can connect to the stack directly via Ethernet. The power supply options are the same as with WIFI, but in addition the Ethernet Extension supports Power-over-Ethernet. This allows the stack to be powered directly via the Ethernet cable if you have a PoE injector at hand.

 

Phew, quite long explanation. I hope I didn't overwhelm you with this :)

Link zu diesem Kommentar
Share on other sites

You, sir, won the most exhaustive answer I've gotten from a stranger. Thanks a lot for taking the time to write it all down!

 

It was yes overwhelming as I'm not into electronics at all. I'm a web programmer so...! ;)

 

So I would need a Master Brick (https://www.tinkerforge.com/en/shop/bricks/master-brick.html) and a Wifi Master extension (https://www.tinkerforge.com/en/shop/master-extensions/wifi-master-extension.html), IO-4 Bricklet (https://www.tinkerforge.com/en/shop/bricklets/io4-bricklet.html) and a Distance IR Bricklet (https://www.tinkerforge.com/en/shop/bricklets/distance-ir-bricklet.html). Do I need both Bricklets or does the Distance IR Bricklet connect directly to the Master Brick?

 

I'll add a Step-Down Power Supply (https://www.tinkerforge.com/en/shop/power-supplies/step-down-power-supply.html) to power it all. I just thought about the time it'll last though...

 

If you say this setup would consume around 100 mAh, if I use a Energizer Rechargeable 9V battery (http://www.energizer.com/batteries/rechargeable-batteries/Pages/9v.aspx) that has 175 mAh, the setup would last not even 2 hours on a single battery? I have a hard time believing this setup would use 100 mAh when my iPhone in standby mode consume about 5 mAh...!

 

Could I just use a 7000 mAh battery (like this one http://www.androidpolice.com/2013/04/12/deal-alert-this-7000mah-galaxy-s-iii-battery-will-power-your-phone-till-the-cows-come-home-and-its-only-34/) and think a 100 mAh setup would last 70 hours (or around 3 days).

 

I know I'm sidetracking the question but... anyway...

 

Finally, about the communication part, when you say the website can periodically query the status of the microswitch, do you mean I could do something like "masterbrick.getStatus();" in PHP and it'll return the switch status? How would I connect to the Brick via PHP?

 

Again, thanks for your time, I really appreciate it!

Link zu diesem Kommentar
Share on other sites

If you really want to use this 9V battery, take the more powerful, (and expensive) lithium version. Energizer declare its capacity around 750mAh:

http://www.energizer.com/batteries/performance-lithium/advanced-lithium/Pages/9v.aspx

 

At the beginning in your case it could be enough to take a Master-Brick and connect it with a IO4 (1) or Distance IR Bricklet (2).

This stack can be powered directly by the USB-Cable connected to Host-PC. Data comm. between software and the stack is provided by this cable too.

 

In case of (1) you need an additional mechanical microswitch e.g.:

https://www.tinkerforge.com/en/shop/accessories/micro-switch.html

So there is no need to take both bricklets. It depends how do you want to determine door status mechanically or contact-free.

 

A step-down-power supply is optional, but a must if you provide external servo- or stepper motors (via corresponding bricks) with higher voltage and current than the ordinary (USB-) 5V.

But on the other hand a step-down supply offers more opportunities to power the stack with an external accu or battery pack that delivers a higher capacity e.g. for long term operations.

 

A step-down power supply regulates the origin voltage (6-27V) down to 5V used by brick/bricklet-stack and loops through the full voltage to other bricks e.g. motors etc.

 

A callback is often used to recognize state changes at pins or channels:

http://www.tinkerforge.com/en/doc/Software/Bricklets/IO4_Bricklet_PHP.html#io4-bricklet-php

Link zu diesem Kommentar
Share on other sites

It really has to be battery connected and can't be tethered to the computer, it's too far away. So, can I expect the battery to last a month with this kind of setup?

 

If I'm correct, If I go for a different battery (i.e.. smartphone battery), I'll need the step-down power supply, right?

 

Is it possible to put the Brick in idle mode when nothing is happening to save power? It would wake up then send the notice and then go back to idling... if that's possible...?

 

Thanks!

Link zu diesem Kommentar
Share on other sites

For example if a battery pack like this one: http://www.amazon.com/dp/B00A7PF3KA

has a capacity of 10000 mAh and the whole brick stack would consume approx. 300mA (in average), the battery could deliver the necessary power not more than 33 hours (theoretically ;)

For a month you should take a https://www.tinkerforge.com/en/shop/power-supplies/usb-power-supply.html.

 

If the stack is too far away from Host-PC, the WIFI Extension (wireless) or the coming soon Ethernet-Ext.(wired connection) could be used.

A brick stack has no idle (or low power) feature except the WIFi-Extension.

A step down supply is needed if a power source delivers more than 6V.

Link zu diesem Kommentar
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Clear editor

×   Du kannst Bilder nicht direkt einfügen. Lade Bilder hoch oder lade sie von einer URL.

×
×
  • Neu erstellen...