Weston BartlettGunner MolekO'Hodge Garvin
Published

Pet Monitoring System

Temperature, food, and water bowl level sensors to make sure your pets are taken care of when you are away.

BeginnerFull instructions provided20 hours78
Pet Monitoring System

Things used in this project

Hardware components

Arduino Ky-028 Digital Temperature Sensor
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Adafruit Water Level Sensor
×1
Jumper wires (generic)
Jumper wires (generic)
×12
Argon
Particle Argon
×3
Resistor 100 ohm
Resistor 100 ohm
×1

Story

Read more

Schematics

Food Level Sensor

Detects the level of food in a bowl

Temperature Sensor

Detects the Temperature of the room

Water Level Sensor Diagram

Detects when water level is low

Code

Temperature Sensor

C/C++
#include <math.h>
// Declaration and initialization of the input pins
int Analog_Input = A0; // Analog output of the sensor
int Digital_Input = 3; // Digital output of the sensor
float TempreadKelvin;
float TempreadCelcius;
float TempreadF;
float TemperatureHigh;


void setup ()
{
  pinMode (Analog_Input, INPUT);
  pinMode (Digital_Input, INPUT);
       
  Serial.begin (9600); // Serial output with 9600 bps
}
  
// The program reads the current values of the input pins
// and converts them to voltage and then to temperature
void loop ()
{
  float Analog;
  int Digital;
    
  //Actual values are read, converted to the voltage value....
  Analog = analogRead (Analog_Input) * (3.3 / 4095.0); 
  Digital = digitalRead (Digital_Input);
  
  //Assuming constant current (I = 1A to make calcualtions easier) this means that outputvoltage = resistance for a given temp measurement
  //A = 0.005997 B = -0.005210 C = 0.003081; 
  TempreadKelvin = 1.0/(0.0059973329-0.0052101143*log(Analog)+0.0030811518*pow(log(Analog), 3));
  TempreadCelcius = TempreadKelvin-273.15;
  TempreadF = (TempreadCelcius*1.8)+32;
  
  //Insert the temperature in which you want to be notified. Use > or < to determine if notification will be for values greater than or less than the specified value
  if(TempreadF<65)
  {
      Serial.println (" reached");
      Particle.publish("TemperatureThreshold", String(TemperatureHigh));
     delay(30000);
  }
  else
  {
      
      Serial.println (" not yet reached");
      Particle.publish("Temperature", String(TempreadF));
      delay(2300);
  }

 Particle.subscribe("CommsCheck", "GotIt", ALL_DEVICES); 
  
}

Food Level Sensor

C/C++
//Defining variables
float duration, cm, setdistance, setdistanceinch, diff, FoodLow;
int trigPin = 2;
int echoPin = 6;


void setup()
{
  
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT);
   // Particle.subscribe("ClayPetersonLED",LEDOn,"4b0023000351353530373132");

    Serial.begin(9600);
}

void loop()
{
     //lines 23 - 30 output and collect the soundwave, get a duration in
    //terms of microseconds, convert that time to distance since we know how fast sound travels
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(100);
    digitalWrite(trigPin, LOW); 
    duration = pulseIn(echoPin, HIGH);
    cm = (duration/2) / 29.1; //divides time in half because the wave goes to target and back. 29.1cm/millisecond converts the time to distance in centimeters.
    
    if(cm > 8)
    {
        Particle.publish("FoodLow", String(FoodLow));
        delay(30000);
    }
    else
    {
       Particle.publish("Distance", String(cm));
       delay(5000);
    }
    Particle.subscribe("GotIt", ALL_DEVICES);
}

Water Level Sensor

C/C++
int analogPin = A1;
int level = 0;
int TempInt =0; //global int var
int Dist =0;//float receivedfloat = 0; //global float variable
int FoodLow =0;


void setup()
{
    Particle.variable("Water Level", level);
    pinMode(analogPin, INPUT);
}


void loop()
{

    level = analogRead(analogPin);
    delay(200);

    if (level>8)
    {
        
        Particle.publish("Water Level", String(level));
       
    }
    else 
    {
    
    Particle.publish("Water Level", String(level));
    }
    delay(500);
    
   Particle.publish("CommsCheck","GotIt", PRIVATE);
  
    delay(500);
}

Credits

Weston Bartlett

Weston Bartlett

1 project • 3 followers
Gunner Molek

Gunner Molek

1 project • 3 followers
O'Hodge Garvin

O'Hodge Garvin

1 project • 1 follower

Comments

Add projectSign up / Login