Project in progress
Pre-Bedtime Environment Analysis

Pre-Bedtime Environment Analysis © MIT

Define the optimum environment for sleep by applying ML to sensor data.

  • 2,405 views
  • 2 comments
  • 6 respects

Components and supplies

About this project

Introduction

This project revolves around using the Cypress Analog Coprocessor Pioneer Kit as a sensor hub. Using an Arduino Uno as an I2C-to-UART USB serial bridge, a computer records sensor values taken once every second and saves the useful ones to file for annotation and feature extraction. This annotated data is then given to an off-the-shelf SVM classifier to to train a model that will then be used to to determine if the sensor recordings at a given moment fall are ideal.

Setup

  • Flash the EnvironmentSensing firmware onto the Cypress Analog Coprocessor Pioneer Kit board using the PSoC Creator software package. (A bunch of thanks to Michiyuki Yoneda over at Cypress for sending that my way!)
  • Connect the Cypress and Arduino boards:
"""
Arduino A5 ----> 4.0 Pioneer
Arduino A4 ----> 4.1 Pioneer
Arduino 5V ----> VIN Pioneer
Arduino GND ----> GND Pioneer
"""
  • Connect the computer to the Arduino Uno via USB.
  • Start the Python companion script, passing in the port of the Arduino as an input parameter. For Windows machines, this will look something like:
python serial_read.py COM3

Timeline

  • 12/13/16 - Received PSoC Creator project files from Michiyuki @ Cypress, who offered his help in transforming the Cypress Analog Pioneer Kit into a Sensor Hub.
  • 12/22/16 - Finally managed to run the Cypress Bridge Control Panel app to read the I2C sensor readings coming off of the Kit board. (More thanks to Michiyuki!)
  • 2/4/17 - Was able to pull bytes off of the Pioneer Kit's via I2C onto an Arduino Uno. Unfortunately the data was incomprehensible unicode jibberish.
  • 2/13/17 - Recognized a bug in my Arduino code transforming the values into characters instead of floats. Began project documentation and started to write Python data collector.
  • 2/15/17 - Started to decipher the data stream from Cypress board. Wrote a Python script to read values.
  • 2/20/17 - Fixed issue preventing NodeMCU from supplying adequate power to Cypress board.
  • 2/21/17 - Wrote Python Flask web server to serve as collection hub for data.
  • 2/26/17 - Updated Arduino program to collect data once per second. Added code to companion Python app to write data to CSV file.

Notes

While pin-compatible with an Arduino Uno, my Uno resets itself incessantly when the Pioneer Kit is plugged directly into it. Instead we have to make the connections via jumper cables.

It also appears as though most of the sensor data is relative and not absolute. That means calibration will be necessary to use the sensor data from the thermistor, ambient light sensor, etc. The sensor values also appear to be base 255-encoded, further throwing off attempts at deciphering which belong to which sensor.

Results

Unfortunately the sensor data being transmitted via I2C from the Cypress board isn't absolute and is thus ill-suited for our purposes. Every power cycle of the board results in a recalibration of the sensor values, rendering the recording sessions impossible to compare directly. The project continued forward regardless, with the goal of instead incorporating a NodeMCU in order to create a sensor hub that can post environment readings to the internet.

However without absolute certainty that the values are correctly assigned to their respective sensors, utilizing a NodeMCU was never fully investigated. Case in point: two I2C values appeared linked to the ambient light sensor, despite those values not being identical.

It also turns out that the SVM implementation chosen would only be capable of assigning an ideal/not-ideal label to a set of measurements correlating to one point in time, and not capable of identifying multiple measurements over a period of time. That would requite more advanced automatic analytics.

The end result is a system that is capable of recording sensor values, which can then be later analyzed such as in the screenshot taken above.

For The Future

I was only able to reasonably discern the values corresponding to three of the five sensors on the Cypress board. Moving forward I would like to include the remaining two in my environment recordings. Additionally I would prefer to not rely upon a computer and instead incorporate a NodeMCU and cloud-based app to manage the data generated.

Code

Code Repository
Contains PSoC Firmware, Arduino I2C-to-Serial Firmware, and Python scripts to work with the data.

Comments

Similar projects you might like

Factory/Warehouse/Control Shed/ Environment Monitoring

Project tutorial by Muhammad Afzal

  • 1,674 views
  • 0 comments
  • 7 respects

Dynamic Environment

Project showcase by Mostafa Alani, Ph.D

  • 1,767 views
  • 2 comments
  • 17 respects

Where's my stuff?? - Find your misplaced things with Alexa!

Project in progress by Team Crakers

  • 1,630 views
  • 0 comments
  • 6 respects

SMART SCHOOL SYSTEM. IoE unit REMIC, intellectual-control.

Project in progress by Team iTea.School

  • 1,237 views
  • 0 comments
  • 2 respects

Precision Agriculture – A Prototype Solution

Project in progress by Eric Hall

  • 18,869 views
  • 2 comments
  • 65 respects

The Environment Cube! Know the Land Beneath You!

Project in progress by Dhairya Parikh

  • 6,016 views
  • 6 comments
  • 19 respects
Add projectSign up / Login