The aim of the project is to have a Flexible studio of the future. Why flexible???In what way??? Every educational institute has students of varied learning and working styles and it is very important to be able to provide them with spaces which boosts their interest and potential of work. This thought formed the base of the concept leading us to monitor noise and number of people in each space and providing this information to students so that they are able to find the spot that will help them be most productive.

Created: March 4th, 2015

0

About my spot

Myspot is system which monitors noise level and number of people in a space in live time to give the student the freedom to make a more informed decision on when and where they want to work. 


0

Persona

0

Scenario

0

Basic Idea

0

How it works

The device has two boxes that house infra red sensors which send out infra red light. If the light bounces off anything that is in front of it the sensors pick up the reflection. This reflection is then translated into a response saying that there is an object in front of the device. If the second sensor picks up the same object, it counts it as a person entering the room. If one device picks up a reflection but the other doesn't, then it is not counted as a person. The device then sends this information to the cloud so that users can see how many people are in a room before they go to the room.

The audio portion is set up with a microphone sensor that picks up sound. There are certain threshold limits for the sound volume to tell if a room has the quietness of a library, the sound level of a casual conversation, or the level of sound expected at a party. The sensor then picks up the amount of sound that is in the room and lights up an indicator that corresponds with the room's sound level. The device then sends this information to the cloud so that any user is able to see what the sound level is in a room before traveling to the room.

0

Process 

0

Noise level detection code

0
#define micPin A0
#define micCancelPin A4

const int sampleWindow = 10; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;
unsigned int sample2;

double volts=0;
double volts2=0;

//average ON sample
const int numOnSamples=2;
int sampleOnCount=0;
double alpha=0.5; //pick a val between 0 and 1
double averageVal=0;
double averageValPub=0;
double avgLongTime=0;

//average OFF sample
const int numOffSamples=250;
int sampleOffCount=0;
double currentAvg=0;
double currentAvgPub=0;

//publish events to cloud
const double ambientNoiseLevel=0.6;

unsigned long lastTimeStamp=0;

void setup()
{
 //Serial.begin(9600);
 Spark.variable("volts",&volts,DOUBLE);
 Spark.variable("currentAvgPub",&currentAvgPub,DOUBLE);
 pinMode(D0, OUTPUT);
 pinMode(D1, OUTPUT);
 pinMode(D2, OUTPUT);
}


void loop()
{
 unsigned long startMillis= millis();  // Start of sample window
 unsigned int peakToPeak = 0;   // peak-to-peak level
  unsigned int peakToPeak2 = 0;

 unsigned int signalMax = 0;
 unsigned int signalMin = 4095; //1024

  unsigned int signalMax2 = 0;
 unsigned int signalMin2 = 4095; //1024

 // collect data for 50 mS
 while (millis() - startMillis < sampleWindow)
 {
    sample = analogRead(micPin);
    sample = analogRead(micCancelPin);
    if (sample < 4095)  // toss out spurious readings
    {
       if (sample > signalMax)
       {
          signalMax = sample;  // save just the max levels
          signalMax2= sample2;
       }
       else if (sample < signalMin)
       {
          signalMin = sample;  // save just the min levels
          signalMin2 = sample2;
       }

    }
 }
 peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
 volts = (peakToPeak * 3.3) / 4095;  // convert to volts

 peakToPeak2 = signalMax2 - signalMin2;  // max - min = peak-peak amplitude
 volts2 = (peakToPeak2 * 3.3) / 4095;  // convert to volts

 volts=volts-volts2;
Click to Expand
0

Head count code

0
const int doorSensorA = A7;
const int doorSensorB = A0;
const int checkingLength = 500; //ms
const int delayAfterCount = 300; //ms
const int recheckTimes = 50;
const int checkingInterval = checkingLength/recheckTimes; //ms

int valveA = 0;
int valveB = 0;
int peopleCounts = 0; 
int sensorAValue = 0; //Analog measure of sensor1
int sensorBValue = 0; //Analog meausre of sensor2
int recheckCounter = 0;

void setup() {
    
    pinMode( doorSensorA, INPUT );
    pinMode( doorSensorB, INPUT );
    
    
    //To auto-calibrate the sensors. Averages 100 samples. Adds an extra 40 to weed out the peaks
    for(int i=0; i<100; i++){
        valveA += analogRead( doorSensorA );
        valveB += analogRead( doorSensorB );
    }
    
    
    valveA = valveA / 100 + 40;
    valveB = valveB / 100 + 40;
    
    //Variable to monitor performance
    Spark.variable( "peopleCounts", &peopleCounts, INT );
    Spark.variable( "sensorAValue", &sensorAValue, INT );
    Spark.variable( "sensorBValue", &sensorBValue, INT );
    Spark.variable( "valveA", &valveA, INT );
    Spark.variable( "valveB", &valveB, INT );
    Spark.function( "resetPeopleCounts", resetPeopleCounts );
    
}

void loop() {
    
    recheckCounter = 50;

    sensorAValue = analogRead( doorSensorA );
    sensorBValue = analogRead( doorSensorB );
    
    //if A is blocked and B is not
    if( analogRead( doorSensorA ) >= valveA && analogRead( doorSensorB ) < valveB ){
        
        while( recheckCounter >= 0 ){
            sensorAValue = analogRead( doorSensorA );
            sensorBValue = analogRead( doorSensorB );
            
            //if B is blocked
            if( analogRead( doorSensorB ) >= valveB ){
                
                peopleCounts++; //add people count
                delay( delayAfterCount );
                recheckCounter = 0; //break the while loop
            }
            
            delay( checkingInterval );
            recheckCounter--;
        }
        
    //if B is blocked and A is not
    }else if( analogRead( doorSensorA ) < valveA && analogRead( doorSensorB ) >= valveB ){
        
        while( recheckCounter >= 0 ){
            
            sensorAValue = analogRead( doorSensorA );
            sensorBValue = analogRead( doorSensorB );
            
            //if A is blocked
            if( analogRead( doorSensorA ) >= valveA ){
                if (peopleCounts<=0) //i added
                peopleCounts++; //i added
                else
                peopleCounts--; //minus people count
                delay( delayAfterCount );
                recheckCounter = 0; //break the while loop
            } 
            
            delay( checkingInterval );
            recheckCounter--;
        }
        
    }
}

int resetPeopleCounts(String whatever){
    peopleCounts = 0;
    return 1;
}
Click to Expand
0

Headcount circuit components

1 - Spark core

2 - 1okohm resistor

2 - 5kohm resistor

2 - I R sensor

Connecting wires


Noise detector components

1 - Spark core

3 - red LED

1 - RGB LED

2 - 10kohm resistor

1 - Microphone module

Connecting wires 



x
Share this Project


About

The aim of the project is to have a Flexible studio of the future. Why flexible???In what way??? Every educational institute has students of varied learning and working styles and it is very important to be able to provide them with spaces which boosts their interest and potential of work. This thought formed the base of the concept leading us to monitor noise and number of people in each space and providing this information to students so that they are able to find the spot that will help them be most productive.