This is a project for a class at the University of Applied Sciences Potsdam. The goal was to create an IoT-Device, preferably with NodeJS and Johnny Five. The two-week long class was supervised by Fabian Morón Zirfas.
Interval is a sleep tracker that grabs values from an accelerometer (in this case the MPU6050) and visualizes movement throughout the night. Tracking can be started and ended via a website that runs on NodeJS, which is also the place where the visualization happens.
I attached the accelerometer to a wooden board for more accurate tracking and placed it next to my pillow. See the prototype below:
The final product would be invisible and hidden underneath the sheets/bed.
I set up forever on my Raspberry Pi so that my server is always up and running. Otherwise just use
npm start to start. Make sure that the database is running (
sudo mongod start or
sudo /etc/init.d/mongod start).
Communication between frontend and backend happens either via AJAX (for data) or socket.io (for starting/ending tracking).
If you want to change the styling of the page please use Compass via the
comapass watch command in the root of the project. The stylesheets can be found in the
/sass directory. Output is in
For templating Jade is used, the views are located in
bower install to get all frontend components (located in
As stated before, tracking can be started and ended on the website. The visualization also happens there. The higher the values, the lighter is the sleep at that time. Low values indicate a deep sleep phase.
Concerns and Outlook
Unfortunately the visualization and tracking of the accelerometer data is not as accuate and unambiguous as I’ve hoped, so there is definitely some work to do.
I could imagine interesting addtions to the hardware, such as sensors for air quality, temperature, brightness, or even more accelerometers that are attached to the body. Autonomous starting and ending of the tracking could be a cool feature on the software side.
- Install NodeJS on Raspberry Pi
- Installing mongodb on Raspberry Pi (using pre-compiled binaries)
- Raspberry Pi MongoDB Installation – The working guide!
- Interfacing Raspberry Pi and MPU-6050
- Reading data from the MPU-6050 on the Raspberry Pi
- General Information on Accelerometers
- MPU6050 module for node-i2c (fixed version)
- MPU6050 calculations from johnny-five
- How do I backup my Raspberry Pi?
The MIT License (MIT)
Copyright (c) 2015 Fabian Schultz
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.