building a poop box for my cat with automatic door.
im using an HC-SR04 ultrasonic sensor with Arduino mega.
i have a sensor inside of an enclosed box(to sense if my cat is stuck inside, or stay open while cat is inside)
the inside sensor will fluctuate 67-68cm most of the time, however randomly it will throw in a value significantly less like 50cm, which in my program is designed to open up because it passed a threashold for 'nothing to be inside' and because of this my door keeps opening. how do i get around this.
my only solutions in my head is:
- adding approx 5-10 sets of value in an array and take the average(since its scanning fast enough)
any other solutions? thanks :)
These random values could be nothing but noise as your receiver may be sensing other source of ultra sound.
Here is an example, where I take multiple readings (
poop_measurementsmeasurements) and then take the average over it: