Hacker News new | ask | show | jobs
Arduino Sensor Network – Bathroom occupancy detector (robots.thoughtbot.com)
61 points by tonyd256 4486 days ago
9 comments

My company made a very similar tool (using photoresistors instead of reed switches to determine whether that bathroom was occupied) a couple of years ago, it was a major lifesaver with single occupancy bathrooms: http://www.sanbornmediafactory.com/portfolio_pieces/bum/
Why would you abuse the WDT to periodically wake the AVR? You could connect one of the reed switches to a true external interrupt and use that as your wakeup call. Saves battery and you don't run the chance of missing anything in between the second long checks.
I used the WDT to make a platform for sensing any sensor in second intervals. Using the reed switches as external interrupts would have been specific to this application. Also, the ATMega328P doesn't allow you to set the interrupt to fire on CHANGE when using the lowest power mode.

For a door opening and closing a 1 second delay is fine. If it misses an event with that delay then it was probably a fluke. Think of it as a buffer to prevent false readings.

This isn't to suggest that using the WDT in interval mode is the wrong approach, and I know there's a certain amount of elegance to doing everything with one chip, but you could still use the level interrupt by adding a 7486 (standard quad XOR gate). For the gate's inputs, you would use the reed switch and a output pin from the AVR, and the gate's output would go to the external interrupt line. If the ISR toggles the state of the output pin each time it runs, the gate's output is only in the IRQ-asserted state for as long as it takes the ISR to fire up--so you don't get constant interrupts while the switch is closed, only a single one on the opening and closing transitions.

The 74LVC86 variant only draws a dozen, or so, microamps, which is dwarfed by the current in the 10k pull-down resistor when the reed is closed, and comparable to the standby current of the radio in the new radio.

I totally agree. There are definitely some more things like this that I could have done to reduce power further and use normal external interrupts. I was going for more of a general purpose sensor board though and wanted to keep it minimal. I could also have used the HIGH and LOW level interrupts on those pins and just change which it triggers on every time it triggered. But I decided to go with the WDT.
Interesting! I guess that I'm not using the lowest power mode[1], but for months now I have had a ATMega328P (running on 3-AA batteries) monitoring doors w/reed switches. I haven't had any trouble w/interrupts not firing on change.

1: I'm using Rocket Scream's LowPower.PowerDown for what it's worth.

Cool, there probably isn't a huge difference between idle and deep sleep modes so I'm sure it could still last a long time. In deep sleep you can still use the HIGH & LOW level interrupts but just not the CHANGE one.
I did this a few years ago, but I simply bought a motion detector and hooked it up to a light in the other room. Cost me like $25 and worked like a charm. Buuuut one of the girls at the office complained because she thought it was creepy, so we had to take it down. Somehow, someone standing around outside the door waiting for their turn is less creepy...
Boundless (http://www.boundless.com/) did this first, and I think we did it better IMHO.

https://github.com/jelder/doors http://doors.boundless.com/

Great to see others are doing this too! I like your solution, very cool. I have some of those digispark boards but decided to go in a different direction making a standalone sensor board that transmits its sensor data to a hub for pushing to the cloud. There are tons of ways this could be done. The way I describe here worked best for us and achieved my goals for it.
How are you supplying power to the digispark?
Love it. A company I used to work with had something like this and hooked it up to a dashboard widget - knowing "occupancy status" was just an F12 away! The bathroom was on the far end of the floor and it was such a waste of time to walk all the way over there to find it occupied. Such a great fix.
Pretty cool, but why reed switches on the door instead of a passive IR detector with a timeout? Neither is perfect, but the PIR doesn't rely on people to remember not to close the door when leaving (which I assume is how they determine actual occupancy?).

You could wire the same PIR to also control the light on/off state, so if someone is having an epic poop but not moving too much you can be pretty sure they'll move to make the light go on if they hit the timeout.

I did exactly this for my home light, I connected the Arduino as a USB peripheral to my home server and use a PIR sensor and a photoresistor to turn lights on/off when it's bright/dark/I'm home/I'm away. It works very well.

Partial writeup: http://www.stavros.io/posts/control-rf-devices-with-arduino/

I considered this but we already have fancy light switches with motion detectors in our bathrooms and our company is strict about leaving the doors open when you leave so that hasn't been a problem. An added bonus of this is that if the last person is leaving and about to lock up they can see if a bathroom door is closed and check to make sure no one is still in there, where as the light could still be on.
Would it be possible to use something like an attiny2313 or even an attiny45, do the job of handling the reed switch data and then delegating the rest of the logic to a central server? I would think you'd get the most power savings that way.
The ATMega328P is pretty low power. I could probably save a bit more with a smaller more targeted MCU, but I wanted this board to be as close to the Arduino Uno as possible. I'm not sure what you mean by a central server. It's possible to use an ATTiny series chip to sense the reed switches and transmit to the nRF24 board.
Many families of uCs (e.g. MSP430) are extremely power-efficient. Power consumption is dominated by the radio; the fewer packets the better.
Someone shares something they made - with quite a bit of programming details - and your reaction is "how original"? I've got news for you: most things aren't fundamentally new. That doesn't mean they're uncool or people hacking hardware for the fun of it deserve your ridicule.

Now go, make something, and come back.

You're great at reading usernames.
I got the name, but I still wanted to invite you to do something more rewarding with your time.
This is HN. The usernames are grey, and no one reads them.
This isn't reddit. Please avoid using novelty accounts.

Sincerely,

Everyone trying to have a conversation.

And 10 years before that... http://bathroom.mit.edu/
"* Clam K has been occupied for 4 days"
How is this helpful?
It helps people know when the bathroom is vacant or occupied.
I meant the snarky comment.
Downvotes for Arduino -- didn't you know the maker community has moved on to Raspberry Pi? Nothing in the Arduino community has been updated in the last 2 years.

Edit: Jeez, sarcasm folks...

Arduino and Pi really serve different purposes to an extent. They are different platforms and each does some things better than other. There are certain things you can't achieve with a Pi that you can with an Arduino. Just look around at the projects joining the two devices together for proof of this.

Edit - just found this Kickstarter - https://www.kickstarter.com/projects/john-cole/arduberry-uni...

I dunno, the Pi has a GPIO bus that replaces 99% of what people do with Arduinos.
THe GPIO is not going to help you build a custom H-bridge to drive motors forward and backward with variable speed. You can use the 2 relay switches to make one of those, but it will be noisy and you only get 1 H-bridge out of all that wiring. You can get an add-on board for the Pi but most designs (I have seen) seem to hijack all the GPIO pins, so any sensors you want to add onto your robot will likely have to use USB (which rules out a lot of the cool low power stuff).

There is a place for both systems, they do different things (even though there is some overlap) so for any moderate project (say a little hexapod robot) you are likely to use both. The Pi as a general purpose computer that can do all your nav/ANN/signalling stuff and an Arduino board to receive the signals and actually run your motors/servos (assuming you need more than 1 or 2).

They overlap, but are quite different. Arduino is a high end microcontroller, Pi is low end computer. If you want real time and low power, you want to be on the microcontroller side of that divide.
The Flora platform is 2 years old but the wearables community around it is still quite active. In fact they just started another podcast just to showcase wearables projects.
No, I mean nothing in the Arduino area has been updated in 2 years. Software, hardware, anything. It really feels like the entire community just up and left and moved to Raspberry Pi.
you're the wirst Kind oft person