My Update Blog
Wiring Closet
Main Controller
RS485 Network
Plantation Shutters
Lighting & Devices
Audio System
Climate Control
iPhone Detection
Contact Me
Custom Nodes
Multi-Purpose Node
Servo Controller Node
IR Occupancy Counting
Bed Occupancy Node
Old Townhouse
Old Macros and Events
Old Wiring and Design
Old Lighting and Devices
Old Audio Componets
Old Security System
Old iPhone Web Interface

Washington, NC Real Estate - A cool site with real estate information in Washington, Bath, and Belhaven, North Carolina.

Greenville, NC Real Estate - Another real estate site with information for Greenville and Winterville, NC.

Morehead City, NC Real Estate - Another real estate site with information for Atlantic Beach and Emerald Isle, NC.

Jacksonville, NC Real Estate - A real estate site with information for Jacksonville, NC and Richlands, NC and homes for sale.

Bed Occupancy Detector Node

One of the variables needed for my home automation setup to work correctly is for it to know when I am sleeping. This allows the main controller to turn off all the lights in the house, turn off the music, arm the security system in stay mode, turn on the beside fan, and make sure all the exterior deadbolts are locked. The simplest way to do this is just to have a flag variable called isSleepingFlag and toggle it to on or off using my iPhone interface. However, this method requires for me to have to think about turning on the sleep mode every time I go to bed – and that's not exactly what I call a “smart home”. So I did the next best thing which was to set the sleep flag based off the status of the security system. This way when the security system is armed in stay mode the house would be set to sleeping. This presented a few problems that made me search for a better solution. First, I would have to set the security system by manually using the keypad or my iPhone interface before I went to bed, again causing me to do an extra unneeded step. Second, I was not able to arm the security system in stay mode unless I was going to bed.

After searching for some time, I finally came up with a viable solution. The answer to my problem involves mounting a flex sensor to the bottom of the joists on my bed. The flex sensor changes its resistance value when it flexes or bends slightly. When weight is applied to the top of the bed (for example when I lay on the bed) the downward pressure causes the joists to bend very slightly and as a result the flex sensor bends and changes its resistance value.

This method gives the main controller the ability to detect when I lay on the bed and when I get off the bed without me having to do anything. Not only that, but by measuring the resistance value I can also detect when multiple people are laying on the bed. This comes in very handy as I have routines setup to control lights when only one person is in the bed even though two are home. When I walk into the master bathroom and someone is sleeping on the master bedroom bed, the lights dim on to 20% so that I don't disturb them. Then, if all people are in bed the lights are shutoff instantly without waiting for occupancy timers to expire in rooms. For example, if I am the only one home and I walk into the master bathroom the lights stay on for five minutes after I leave the room. If I lay down on the master bed then the main controller recognizes that I'm the only one home and I'm in the bed, so unset the timer and turn the lights off right away.


Building the Sensor

I opted to use a flex sensor called the Pulsor by Sure Action. This sensor was made to be placed under floor joists to detect the movement of people in security system applications. Sure Action actually makes a controller board that monitors the resistance value of the Pulsor and trips a NO/NC contact when a pre-set amount of pressure is detected. This board would be easy to hook up to a security system or other input to monitor the occupancy status of the bed. The only negative about this board is that you can't get the actual resistance value back to MisterHouse so that you can detect not only when someone lays on the bed, but how many people are on the bed. In other words you will be able to see if the bed is occupied or not, but you won't be able to know if it's occupied by more than one person using this controller.

Because of these limitations I opted to design my own controller to monitor the Pulsor and power it with the PIC16 series microcontroller (PIC16F886 to be exact) that I call the master bed node. The node connects to the main controller via my RS485 network that I ran throughout my house.

I have the Pulsor sensor epoxied to the underside of one of the joists that my mattress lays on with with a two conductor cable that I soldered to the leads coming from the sensor. At the end of the cable I soldered on a 3.5mm stereo plug so that I could easily connect and disconnect the sensor to the node when I needed.

Since having an AC to DC power adapter behind the bed just for this node is really a waste since it so small anyway, I opted to use the power from my RS485 network cable that I distribute for small nodes. I added a voltage regulator to the node as well so that I could get a steady 5 volts for the PIC to operate.

As you can see from the picture to the right the board is quite small and fits into a little project box. You can see the 3.5mm stereo female jack on the side that the Pulsor sensor from under my bead plugs into. My RS484 network runs over ethernet so that I can easily plug RJ45 connectors into it for each of the nodes. Because of this you can also see the blue ethernet cable that comes out of the node and terminated with a RJ45 connector.

I have the sensor set to measure the resistance of the Pulsor once per second. This measurement is then added to the sum of the last 9 measurements and then divided by 10. This gives me the average resistance over the past 10 seconds. If this value goes up or down by 2 or more units then the new average is reported back to the main controller and a new threshold is set. This virtually eliminates the false reporting of someone in the bed when I toss something heavy onto the bed (causing a large flex for a split second). It also stops me from falsely triggering a sensor update if I roll over to the side of the bed, or sit on the edge due to the threshold.

The main controller can also query the sensor at anytime if it needs to get the current value due to a reset or bug.


Project box and stripboard with 3.5mm female jack installed

Node finished with cover attached




Jon Scott 2012 -- All Rights Reserved.