If you sleep like a princess, and wonder what keeps you tossing and turning at night, perhaps there's a gadget that can find the pea under your mattress.

Companies have begun selling electronics directly to consumers that can help anyone monitor their sleep and adjust their bedtime routine, and some people have invented their own tracking systems. Slip on a wireless wristband or headband and focus your camcorder before you hit the sack, and the next morning you'll wake up to a mound of data.

At a Quantified Self meetup at Wired's San Francisco offices Dec. 7, around 100 people gathered to share their data-driven sleep habits. The founders of the Wakemate startup were on hand to talk about their wristband that keeps track of your sleep patterns. It's equipped with an accelerometer and a Bluetooth transmitter that connects with a free smartphone app. The accelerometer is the same one that's in the highly popular (and backordered) Fitbit exercise tracking device. The Wakemate will be very hackable and cost just $50, but won't ship until January.

So, if it's a Christmas gift for a sleepy friend you're after, you might want to check out the Zeo Personal Sleep Coach, an alarm clock that records electrical signals from your brain with a headband. In the morning, it returns a chart of how much time you spent in light, deep and REM sleep, as well as a personal sleep score (which they call your ZQ). It can also make waking up easier to wake you if you ask it to, by choosing a lighter sleep moment to rouse you.

Techology investor Esther Dyson gave the Zeo a mixed review at the meetup. For example, the headband has little pads that wear out quickly, and must be replaced. But the biggest problems are on the software side: Zeo does not allow more than one user to share the device, and makes it hard to extract the raw data. Despite those flaws, Dyson said she plans to experiment with it some more.

If you want an even better picture of your sleep, you can follow the example of San Francisco resident, Matt Bell. After years of feeling drowsy all day and not knowing why, he set up a bedside camcorder with an infrared illuminator in search of an answer.

The footage was revealing. "The biggest thing that surprised me was seeing how much I moved around while sleeping," Bell said at the meetup. "It was fascinating to glimpse at the workings of this hidden unconscious world that occupies close to a third of our lives."

In his quest for a perfect night of rest, Bell experimented with the lighting in his bedroom, his diet, his sleeping positions and lots of drugs. He even kept a daily log of how well he slept, his mood during the following day, and how much excitement he experienced during the prior day.

Photos: Wakemate, Zeo

Video: Matt Bell/YouTube

See Also: