Inspiration

Nowadays, more and more people get used to using smart phones frequently, even after they going to bed, which affects people’s sleeping to a large extent. In this regard, we decide to build a smart bedroom system which aims to improve people’s sleeping quality.

What it does

The system tries to help people go to bed and get up regularly. It has several functions, such as drawing the curtains and turning off the lights before people go to bed.

In addition, we have successfully added other functions. For example. We used a force resistor to monitor the time the person goes to bed and the time he or she gets up. If the person doesn’t go to bed or get up on time, we change the alarming time accordingly. We also used it to calculate how many times the person gets up at night and how much time the person uses the cell phone after lying on the bed, since we believe this data is important to reflect whether the person has a good sleep or not.

How we built it

To solve the sleeping problem, we use MCUs to control things like curtains and lights in the bedroom and monitor the time the person actually gets up or goes to bed. The system can control the parts in the bedroom, such as lights, curtains. Specifically, the system will draw the curtains, turn off the lights automatically when it’s time to sleep. The system can also detect whether the person goes to sleep or not by using a force sensitive resistor below the mattress. After the person going to bed, the system can detect whether the person still uses the cell phone by using a photoresistor. Moreover, it can sound the buzzer to alarm the person if the person still uses the cell phone lying on the bed. It can also record how much time the person uses the cell phone on the bed. In the morning, the system opens the curtains and turns on the light to help the person getting up easier. If the person doesn’t get up on time, we may sound a buzzer to help the person get up. We used two MCUs in the system. One is linked with a Real time clock, an LCD, a photoresistor and a force sensitive resistor. The other one is linked with a motor, a buzzer and a led.

Challenges we ran into

In practice, we have encountered many obstacles we didn’t anticipate. For example, we initially connected all the things to one MCU. Although all the device could work, it would cause a delay when we tried to get the real time, such as the actual get-up time. Therefore, we tried to use 2 MCUs and found it better. Because SDA and SCL are already used for real time part, so we tried to use interrupt to communicate between those 2 MCUs. In addition, when we tried to combine 2 MCUs using the wire, the input we got from another MCU wasn’t what we expected. Finally, when we tried to use a pull down resistor, it worked!

At first, we decided to turn on or turn off the led gradually, but in practice we found the change of the luminance of the LED is not obvious. Therefore, we changed our approach and just simply turned on and off the led.

What’s more, we got stuck when we tried to calculate the next day’s get-up time and go-to-bed time, since the library we used set the time in BCD format. For example, 0x12 means 12, 0x40 means 35. If we simply do the subtraction, we will get 0x2e result, which is different from the result we anticipate, which is 0x28. Thus, we wrote a function to calculate the difference. In the function, we first convert the hexadecimal number to the real decimal number digit by digit and do the subtraction. Finally, we convert the decimal result into hexadecimal number. This function we wrote is actually what we have been proud of, since it is our own algorithm to calculate the difference of the BCD format numbers.

Accomplishments that we're proud of

We are proud of we have achieved most of the functions we anticipated. Also, the function we wrote is actually what we have been proud of, since it is our own algorithm to calculate the difference of the BCD format numbers.

What we learned

Actually, we have learned a lot from this project. We have learned how to use the stepper motor, the real time clock and the force sensitive resistor. We also have learned how to communicate between 2 MCUs using the wire.

What's next for A model of smart bedroom system

For the next step, we plan to use wireless communication between the two MCUs. We also plan to buy a suitable timing pulley so that we can hang on the curtain on the timing belt.

Built With

Share this project:

Updates