Roomie the room status monitor

Made by Robert Zacharias

Roomie is a sensor network that helps you find good rooms to study or socialize in on campus.

Created: September 29th, 2015

0

Intro

When it's time to study or socialize in a public space, there are many options that a college campus affords. But what if you know that you need a good spot specifically distraction-free studying, or want to find a place where people are already hanging out?

Roomie is a sensor network that monitors the status of rooms on campus and sends this data to a publicly available map so that you can check in on where to go to do what you want to do.

0

Idea

I thought it would be interesting to solve this problem with a wireless sensor network because each node can be made to be fairly low-cost, low-resolution, and high efficacy. Having a simple light and sound sensor that's network-enabled allows for a fair bit of useful data collection.

The light and sound data is interpreted as follows:

Lights on, loud room: social

Lights on, quiet room: study

Lights off, quiet room: empty

Lights off, loud room: creepy.

The collated data is displayed with text and color clues to increase speed of reading. Below are some screenshots of one sample room's status as displayed based on the sensor data.

0

Next steps

A full realization of this network would use wifi-enabled sensor devices, running on low power (ideally solar power, if possible), distributed all over indoors public spaces on campus. The data from these would feed into a central server, which would then publicize the data to a dedicated website and also publish it via an API, so that app developers could integrate it as they wish.


Processing and Arduino code below:

0
// Processing code

/*
 * Room Status Display
 *
 * A remote Arduino sends serial data relaying the status of a room
 * on campus.
 *
 * If lights are on and it's loud, room is social.
 * If lights are on and it's quiet, room is study.
 * If lights are off and it's quiet, room is empty.
 * If lights are off and it's loud, room is creepy.
 *
 * 9/29/15, Robert Zacharias, rz@rzach.me
 * released to public domain
 * incorporates code from Processing simpleRead serial example.
 */


import processing.serial.*;

Serial myPort;  
int val;    

PImage hunt;    // library floor plan image
color textFill;
String status;

void setup() 
{
  String portName = Serial.list()[3]; // 4 for Uno on my laptop, 3 for Bluetooth on laptop
  myPort = new Serial(this, portName, 9600);
  hunt = loadImage("huntmap.png");
  rectMode(CORNERS);
  textAlign(CENTER);
  size(800, 609);
}

void draw()
{

  image(hunt, 0, 0);

  if ( myPort.available() > 0) {
    val = int(myPort.read());
//    String inString = myPort.readStringUntil('\n');
//    if (inString != null) {
//      inString = trim(inString);
//      val = int(inString);
//    }
    print(val);
  }

  if (val == 4) {          // lights and sound = social = blue       
    fill(0, 0, 255);
    textFill = #FFFF00;
    status = "social";
  } else if (val == 1) {    // sound but no lights = creepy = red
    fill(255, 0, 0);
    textFill = #00FFFF;
    status = "creepy";
  } else if (val == 2) {    // lights but no sound = study = green
    fill(0, 255, 0);
    textFill = #FF00FF;
    status = "study";
  } else if (val == 3) {    // no lights or sound = empty = black
    fill(0);
    textFill = 255;
    status = "empty";
  } else {
    status = "";
  }


  // status rectangle painted over room on map
  rect(416, 50, 488, 122);

  // room number, larger and stable color
  fill(255, 255, 0);
  textSize(20);
  text("A15", (488+416)/2, (122+53)/2);

  // status, smaller and contrasting color
  textSize(15);
  fill(textFill);
  text(status, (488+416)/2, 15+(122+53)/2);

}
Click to Expand
0
// Arduino code

/*
 * Room status reader.
 *
 * If lights are on and it's loud, room is social.
 * If lights are on and it's quiet, room is study.
 * If lights are off and it's quiet, room is empty.
 * If lights are off and it's loud, room is creepy.
 *
 * Prints 0, 1, 2, 3 for room status for easy reading in Processing sketch.
 *
 * 9/29/15, Robert Zacharias, rz@rzach.me
 * released to the public domain
 */


int soundPin = A5;
int lightPin = A4;
int x= 0;
int runningSoundAvg, runningLightAvg;

int soundThreshold = 250;
int lightThreshold = 200;

float weightOfNewData = 0.99; // closer to 1 biases towards old data, closer to 0 biases towards new data

unsigned long countdown;

void setup() {
  pinMode(soundPin, INPUT);
  pinMode(lightPin, INPUT);
  Serial.begin(9600);
}

void loop() {
  runningSoundAvg = (analogRead(soundPin) * (1.0 - weightOfNewData)) + (runningSoundAvg * weightOfNewData);
  runningLightAvg = (analogRead(lightPin) * (1.0 - weightOfNewData)) + (runningLightAvg * weightOfNewData);

  if (runningSoundAvg > soundThreshold && runningLightAvg > lightThreshold) x = 4; // social
  else if (runningSoundAvg > soundThreshold && runningLightAvg <= lightThreshold) x = 1; // creepy
  else if (runningSoundAvg <= soundThreshold && runningLightAvg > lightThreshold) x = 2; // study
  else if (runningSoundAvg <= soundThreshold && runningLightAvg <= lightThreshold) x = 3; // empty

  // send data every half second
  if (millis() - countdown > 500) {
    Serial.write(x); // to talk to Processing
    countdown = millis();
  }
  
  delay(10);

}
Click to Expand
0

Difficulties

I had quite a few unexpected stupid technical challenges, including more than an hour and a half of inability to get an Arduino to talk to Processing—still somewhat unresolved. It appears that for some reason wireless serial communication interferes with an amplified electret's output.

x
Share this Project


About

Roomie is a sensor network that helps you find good rooms to study or socialize in on campus.