Project showcase

BarkBox! Simple Noise & Intrusion Detection Device © LGPL

This is a device that simply listens for loud sounds, like barking, and looks for motion present and records the events.

  • 2,525 views
  • 0 comments
  • 3 respects

Components and supplies

Apps and online services

About this project

About This Project

BarkBox! This is a device that simply listens for loud sounds, like barking, and looks for motion present and records the events. I created this project because one day I came home to my dog barking and thought how long had he been barking. I could hear him down the hall when I walked into the building. I live in condos btw so I don't need him barking all day long and making my neighbors upset. Or more to the point why is he barking??? So I thought, "Hey, I got these mic boards laying around from a sensor kit; lets see if I can catch if he is doing it a lot! Oh and I got this PIR motion detector, lets slap that on also!"

When i created the first iteration it only had one mic board for sound detection but I was having problems with it either being way too sensitive or not sensitive enough. I couldn't find the 'sweet spot'. So my solution was to not only add another mic, but to add adjustable thresholds for when they consider the reading to in fact be barking. I have one mic board turn pretty sensitive but with a higher threshold and the other with low gain and a lower threshold. It works pretty good together. Also on the first iteration I had a lot of problems with the mics picking up the radio rx/tx because it was so close to the esp8266 module. It also created voltage fluctuations slightly which wasn't helping. I added 2 capacitors & lowered the esp8266 tx power and it almost got rid of it all. Just recently when I was testing a couple new ESP8266-01S chips, i noticed that the "S" chips completely eliminated the noise from the tx signal & voltage fluctuations. Yay

The settings/how to run it are as follows:

Buttons

  • Arm - resets all counts & starts recording event counts for motion & sound. Both mics must detect the sound at once for it to register as a bark.
  • Notify - turns on text messaging & will send a text when motion is detected.
  • Raw Values? - This live updates the raw values to the dashboard - This WILL slow down polling interval of the mics/motion substantially possibly missing barks or motion events. Just to test & see your average levels

After some playing around with the threshold settings I got it pretty tuned in to identifying when he is barking or not. Turns out overall he is a good dog.

What's Connected

This project currently used: Arduino Uno R3 ESP8266-01S 2x Analog sound microphones Motion Detector HC-SR501 plus some small parts- AMS1117, capacitors, etc...

Triggers & Alerts

I didn't use too much for alerts or triggers with this project. Just one trigger that is used for notifying me, if intrusion/motion is detected & I have the "notify me" button enabled. I may add a LED on the board to indicate when motion is detected or bark detected. Maybe a Neopixel strip that also counts the events?

Scheduling

I have the device arm itself everyday at 9am and disarm at 4pm otherwise I always forget to turn it on and then it won't keep count.

Dashboard Screenshots

Photos of the Project

Video

no video yet...

Code

#include <CayenneESP8266Shield.h>

char token[] = "your token here";
char ssid[] = "your wifi";
char password[] = "your wifi password here";

#define EspSerial Serial
#define ESP8266_BAUD 115200
ESP8266 wifi(EspSerial);


const int barkPin1 = A1;
const int barkPin2 = A0;
const int motionPin = 3;

int barkLevel1;
int barkLevel2;
int threshold1;
int threshold2;
int armed;
int barking1 = 0;
int barking2 = 0;
int trueBark = 0;
int showRaw;
int motion = 0;
int notify;
int prevMotion = 0;
int motionDetects = 0;


void setup()
{
	EspSerial.begin(ESP8266_BAUD);
	delay(10);

//	Serial1.begin(9600);

	Cayenne.begin(token, wifi, ssid, password);

	Cayenne.virtualWrite(V13, 0);
	Cayenne.virtualWrite(V11, 0);

	pinMode(barkPin1, INPUT);
	pinMode(barkPin2, INPUT);
	pinMode(motionPin, INPUT);
}


void loop()
{
	Cayenne.run();

	prevMotion = motion;
	barkLevel1 = 530 - analogRead(barkPin1); //set your mics values here
	barkLevel2 = 1023 - analogRead(barkPin2); //set your mics values here
	motion = digitalRead(motionPin);

	if (motion != prevMotion)
		{
			Cayenne.virtualWrite(V10, motion);

			if (armed == 1)
				{
					if (prevMotion == 0)
						{
							motionDetects++;
							Cayenne.virtualWrite(V11, motionDetects);
						}
					if (notify == 1)
						{
							Cayenne.virtualWrite(V13, 1);
						}
					else
						{
							Cayenne.virtualWrite(V13, 0);
						}
				}
		}


	if (showRaw == 1)
		{
			Cayenne.virtualWrite(V8, barkLevel1);
			Cayenne.virtualWrite(V9, barkLevel2);
		}

	if (armed == 1)
		{
			if (barkLevel1 > threshold1)
				{
					barking1++;
					Cayenne.virtualWrite(V2, barking1);
				}

			if (barkLevel2 > threshold2)
				{
					barking2++;
					Cayenne.virtualWrite(V5, barking2);
				}

			if (barkLevel1 > threshold1 && barkLevel2 > threshold2)
				{
					trueBark++;
					Cayenne.virtualWrite(V6, trueBark);
				}

			//		Serial1.print(barkLevel1);
			//		Serial1.print("  ");
			//    Serial1.println(threshold2);
		}
}




CAYENNE_IN(V1)
{
	armed = getValue.asInt();
	if (armed == 1)
		{
			barking1 = 0;
			barking2 = 0;
			trueBark = 0;
			motionDetects = 0;
			Cayenne.virtualWrite(V2, 0);
			Cayenne.virtualWrite(V5, 0);
			Cayenne.virtualWrite(V6, 0);
			Cayenne.virtualWrite(V11, 0);
		}
}

CAYENNE_IN(V3)
{
	threshold1 = (getValue.asLong() / 1023);
}

CAYENNE_IN(V4)
{
	threshold2 = (getValue.asLong() / 1023);
}

CAYENNE_IN(V7)
{
	showRaw = getValue.asInt();
}
CAYENNE_IN(V12)
{
	notify = getValue.asInt();
}

Comments

Similar projects you might like

Arduino Inputs Outputs on PC

Project tutorial by moty

  • 181 views
  • 0 comments
  • 4 respects

Scavenger Hunt Clues w/ Telephone Keypad

Project tutorial by Sam Horne

  • 598 views
  • 0 comments
  • 3 respects

Arduino Mini Shields Construction

Project tutorial by Patel Darshil

  • 260 views
  • 0 comments
  • 5 respects
Add projectSign up / Login