Toby HaleShane ReedNate WeltonSierra Clark
Created April 14, 2015 © Beerware

coo

'Coo' is the first smart baby monitoring device on the market, eliminating constant monitoring, by sending a text when the infant is crying

IntermediateWork in progress191
coo

Things used in this project

Story

Read more

Code

Intel Edison board

Plain text
just paste it into your Edison board
// Demo of Grove - Starter Kit V2.0

#define ON 1
#define OFF 0


// Reads the value of the Grove - Temperature Sensor, converts it to a Celsius temperature,
// and prints it to the serial console.
// Connect the Grove - Temperature Sensor to the socket marked A0
// Open the Serial Monitor in the Arduino IDE after uploading

// Define the pin to which the temperature sensor is connected.
const int pinTemp = A0;
const int pinLight = A1;
const int pinSound = A2;
const int relayPin = 7;


long timeOn=0, totalTime=225000;
int motor = OFF;

// Define the B-value of the thermistor.
// This value is a property of the thermistor used in the Grove - Temperature Sensor,
// and used to convert from the analog value it measures and a temperature value.
const int B = 3975;

int pos;

void setup()
{
    // Configure the serial communication line at 9600 baud (bits per second.)
    Serial.begin(115200);
    
    pinMode(relayPin, OUTPUT);
}

void loop()
{
    int spin = 0;
  
    // Get the (raw) value of the temperature sensor.
    int tempval = analogRead(pinTemp);
    int lightval = analogRead(pinLight);
    int soundval = analogRead(pinSound);
    
    // Determine the current resistance of the thermistor based on the sensor value.
    float resistance = (float)(1023-tempval)*10000/tempval;

    // Calculate the temperature based on the resistance value.
    float temperature = 1/(log(resistance/10000)/B+1/298.15)-273.15;


    // Print the temperature to the serial console.
    Serial.print("Temp: ");
    Serial.print(temperature);
    
    if (temperature > 27) {
      Serial.print(" TOO HIGH ");
       system("node /opt/sms/hot.js");
      sleep(30);
      
    }
    if (temperature < 15) {
      Serial.print(" TOO LOW ");
    }
    
    Serial.print(" Motion: ");
    Serial.print(lightval);
  
    if (lightval < 200) {
      Serial.print(" Moved ");
      spin=2;
    }
    if (lightval > 780) {
      Serial.print(" Moved ");
                                                                                                                                                                                                                                                                                                                                                                                               
      spin=2;
    }

 // Print the sound to the serial console.
    Serial.print(" Sound: ");
    Serial.print(soundval);
    
    if (soundval > 300.0) {
      Serial.print(" Crying? ");
      system("node /opt/sms/cry.js");
      sleep(30);
    }

    if (spin>0 && motor==OFF) {
      digitalWrite(relayPin, HIGH);
      motor=ON;
      timeOn=clock();
      
      Serial.print(" Motor On ");
      Serial.print(" TimeOn: ");
      Serial.print(timeOn);
    }
    
    if(timeOn > 0){
      Serial.print(" Clock: ");
      Serial.print(clock());
      if ((clock() - timeOn) > totalTime ) {
        digitalWrite(relayPin, LOW);
        motor=OFF;
        timeOn=0;
        Serial.print(" Motor Off ");

      }
      
    }
 Serial.println("");   
 delay(250);                       // waits 15ms for the servo to reach the position

Credits

Toby Hale
1 project • 2 followers
My name Is Toby Hale an Mfa student just about to graduate from CCAD having studied industrial deisgn. looking to work for any companies striving in inovation
Shane Reed
1 project • 2 followers
Nate Welton
1 project • 1 follower
A long time ago, in a galaxy far, far... never mind.
Sierra Clark
1 project • 1 follower
Graphic Design Student at CCAD.
Thanks to Intel and Twilo App.

Comments