Wake Up Bed for Bad and Deep Sleepers

by VdsMaximilian in Circuits > Microcontrollers

111 Views, 0 Favorites, 0 Comments

Wake Up Bed for Bad and Deep Sleepers

eindresultaat.jpg

I always have been someone who likes to sleep through the noise of my alarms to later find my phone having several notifications of missed alarms. Therefor for my first school project I decided to make a smart bed. This bed has not only a alarm based of sound but movement aswell. The assure that you sleep in a good enviorment this bed will also messure temperature, humidity & lumosity. This project is a prototype of a bed which i would appreciate to have for my own.


In this instructable I will be:

- explaining the different components that work via external libraries or been made by specific companies

- the hardward installation

- the structure of the database

- the code

The code for this project can be found here: https://github.com/howest-mct/2021-2022-projectone-VanderschuerenMaximilian.git

Load Cell & Hx711

load cell wire connection.jpg

The Hx711 is a chip designed for incredebly presicion scaling with a data accuarcy of 24bit. It can be configured to messure values such a load or pressure. It is the power supply regulator for the load-cell and ADC analog power supply. The operation voltage range is 4,8V-5,5V with a current of 1,6mA. The module can be used to regulate up to two load cells.

Wire connection

load cell -> hx711 ( NOT CORRECT YEETTTTTTT)

Excitation+ (E+) or VCC is red

Excitation- (E-) or ground is black

Output+ (O+), Signal+ (S+)+ or Amplifier+ (A+) is white

Output- (O-), Signal- (S-)+ or Amplifier- (A-) is green

hx711 -> pi

On a module which the possebility to regulate two load cells the wiring is as follows:

from left to right:

5V Vcc, data pin (A), SCLK (A), GND, data pin (B), SCLK (B)

HX711 library

The library i used comes with 2 classes and an example code. The comments in that file should succesfully help you to get the correct value out of the load cell. Don't forget to set your callibration factor correct when using your load cell.

This step only shows you on how to program the interface of the hx711. To get a little more insight and a video example of this go to Tutorial Hx711.

Seeed Studio Grove Recorder

grove recorder.PNG

The speaker used in this project is a combination of a speaker and recording component which can record sounds up to 83 seconds. The oporational voltage of this component is 3,3V-5V.

To record a sound you can simply keep pressing on the build in button. You have also the option to program these function. On the offical site, SeeedWiki-Grove-Recorder V3, you can find example code of how to start, stop your recording and also play it.

DHT11 Sample Source Code

DHT11.PNG

The DHT11 is a component which measures both temperature as humidity. The operational voltage is 5V. The DHT11 can be purchased in two styles: with 3 or 4 connections. If you have a choice I would recommend to purchase one with 3 connections because these are most likely to be sold on a little board which means you dont have to build the circuit yourself. If you do have a 4 connections one, the image above shows you the circuit you need to build. The needed library to use the DHT11 is brovided by adafruit (DHT11-Sample-Code).

Hardware Installation

hardware.jpg

I would recommend to test of all your components espacially the load cell with the Hx711.

Database

Database.PNG

The database I made has two big parts.

The history where is shown what the components measure and when.

The made alarms that are made. The alarms are track by columns for each day of the week or a different date. The alarms will also have a snooze option and can be manually be put on (non-)active.

Code (back-end)

This part of the code mostly tracks the data in the database, updates it, sends values to the front-end code (will be seen next) based of the measured values or activates outputs. The file app.py is the main code of the back-end. Here the components actions are put into threads so they can work at the same time without interacting with eachother. The thread 'update_database' handels components like the DHT11 and LDR while the thread 'wekker_planning' handles the alarms.

Code (front-end)

front-end.PNG
create.PNG
change.PNG
ldr.PNG

The front-end code exists out off html&css and javascript. In the app.js all values that will be shown are all found in the function 'listenToSocket'. The other functions are actions you can do with the alarms on the website; create, change, delete.

The DHT11 values are shown at the top of the home-page and provide info about the state of the room with an added state text which shows if the current state of the room is in good conditions.

Via the LDR will be shown if the room if too bright to sleep in.

The alarms are shown on the home-page in order of time.