user2488238
Published

Automatic Pet Water Bowl Sensor Package (Team 31)

This project is the construction and programing of sensors that detect water levels and temperature of a pet bowl, for automated service.

BeginnerShowcase (no instructions)116
Automatic Pet Water Bowl Sensor Package (Team 31)

Things used in this project

Hardware components

Photon 2
Particle Photon 2
×2
Adafruit Water Level Depth Sensor
×1
Digital Temperature Thermistor
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Story

Read more

Custom parts and enclosures

Water Level Sensor

Schematics

Thermistor wiring to photon 2

Thermistor wiring

Water Level Sensor

Photon 2 Pinout

Code

Water Level Sensor

C/C++
Code for photon 2 Water Level Sensor
#include <Particle.h>

int sensorPin = A0; // Analog pin where the sensor is connected
int waterLevel = 0; // Variable to store water level data

void setup() {
    Particle.variable("waterLevel", waterLevel);
}

void loop() {
    // Read water level from the analog sensor
    int sensorValue = analogRead(sensorPin);

    // Convert the analog value to a meaningful water level value
    waterLevel = map(sensorValue, 0, 4095, 0, 100); // Adjust the mapping as needed

    // Publish the water level to Particle Cloud
    Particle.publish("water_level", String(waterLevel));

    delay(1000); // Delay for 10 seconds (adjust as needed)
}

Temperature Sensor

C/C++
Code for photon 2 temperature sensor.
#include <Particle.h>

int led = D7; // Define the LED pin
int digitalPin = D2; // KY-028 digital interface
int analogPin = A0; // KY-028 analog interface
int digitalVal; // Digital readings
int analogVal; // Analog readings

void setup() {
    pinMode(led, OUTPUT);
    pinMode(digitalPin, INPUT);
    Serial.begin(9600);
}

void loop() {
    // Read the digital interface
    digitalVal = digitalRead(digitalPin);
    if (digitalVal == LOW) { // If temperature threshold reached
        digitalWrite(led, HIGH); // Turn ON the LED
    } else {
        digitalWrite(led, LOW); // Turn OFF the LED
    }

    // Read the analog interface
    analogVal = analogRead(analogPin);
    Serial.println(analogVal); // Print analog value to serial
    delay(100);
}

Credits

user2488238
1 project • 0 followers
Thanks to Ryan Jacques and Henry Hohl.

Comments