Cole Poswiatowski
Published © GPL3+

Fish Bowl Monitoring System

A new all in one system to help keep a healthy lifestyle for your aquatic friend.

IntermediateFull instructions providedOver 1 day84
Fish Bowl Monitoring System

Things used in this project

Hardware components

Argon
Particle Argon
×2
Breadboard (generic)
Breadboard (generic)
×2
Ultrasonic Sensor - HC-SR04
SparkFun Ultrasonic Sensor - HC-SR04
×1
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
ThingSpeak API
ThingSpeak API

Story

Read more

Schematics

Ultra Sonic Schematic

This is the wiring diagram for the ultrasonic sensor

Switch Schematic

This is the wiring diagram for the switch and LED light

Flowchart

A flowchart of how the system communicates

Code

Ultrasonic Coding

C/C++
int trigPin = D4;   
int echoPin = D5;    
int boardLed = D7;
long duration, cm;
 
void setup() {

  Serial.begin (9600);

  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  Particle.subscribe("Switch Pressed!", Pressed, MY_DEVICES)
}
 
void loop() {

  digitalWrite(trigPin, LOW);
  delayMicroseconds(5);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
 

  duration = pulseIn(echoPin, HIGH);
 
  
  cm = (duration/2) / 29.1;     
  
  
   
  String data = String(cm);
  
  Particle.publish("Distance", data, PRIVATE);
  
  delay(60000);
}
void Pressed(const char *event, const char *data) {
    
  if (strcmp(data,"Switch Pressed!")==1 {

    digitalWrite(boardLed,HIGH);
    delay(3000)
    digitalWrite(boardLed,LOW);
  }
  else if (strcmp(data,"Switch Pressed!")==0 {
   
    digitalWrite(boardLed,LOW);
  }
  else {
  }
}

Switch Code

C/C++
#define LEVER_SWITCH_PIN 4
int pressSwitch = 0;
int led1 = D6;
void setup()
{
Serial.begin(9600);
pinMode(led1, OUTPUT);
Particle.subscribe("Distance", led, MY_DEVICES);
}
 
void loop()
{
pinMode(LEVER_SWITCH_PIN,INPUT);
pressSwitch = digitalRead(LEVER_SWITCH_PIN);
if(pressSwitch == LOW)
{
// Get some data
  String data = String(1);
  // Trigger the integration
  Particle.publish("Switch Pressed!", data, PRIVATE);
  // Wait 60 seconds
  delay(60000);
}
}

void led(const char *event, const char *data) {

if (strcmp(data,"Distance")>=17) {
    
    digitalWrite(led1,HIGH);
  }
  else if (strcmp(data,"Distance")<17) {
    
    digitalWrite(led1,LOW);
  }
  else {
    
  }
}

Credits

Cole Poswiatowski

Cole Poswiatowski

1 project • 0 followers
Thanks to Stephen Poswiatowski.

Comments

Add projectSign up / Login