This is Plan-A.

Plan-B is taken!

Final Project Plan-B

Scratching Post Camera
Cat sharpens own claws instinctively. Cat owner can see this aciton every day on scratching post if prepared. We could see how cats sharpen from far distance. As soon as people come close to there, cats stop and go way easily. We, cats owner want to see their expression when scratching.


What to do
Cats start scratching from lower position of the post, then go up gradually to the top. When a cat come closely to the top, sensor detects where s/he is, and take a photo and send it to network storage.

Detect cat approaching

To detect cat approaching camera, Ultrasonic Distance Sensor is used. When cat comes to appropriate distance where is close enouth to the top, photo will be taken.

int Trig = 8;
int Echo = 9;
int Duration;
float Distance;

int PhotoTakeDistance = 10; //[cm]

void setup() {
  Serial.begin(9600);
  pinMode(Trig,OUTPUT);
  pinMode(Echo,INPUT);
}

void loop() {
  digitalWrite(Trig,LOW);
  delayMicroseconds(1);
  digitalWrite(Trig,HIGH);
  delayMicroseconds(11);
  digitalWrite(Trig,LOW);
  Duration = pulseIn(Echo,HIGH);
  if (Duration>0) {
    Distance = Duration/2;
    Distance = Distance*340*100/1000000; // ultrasonic speed is 340m/s = 34000cm/s = 0.034cm/us 
    Serial.print(Distance);
    Serial.println(" cm");
//
//photo will be taken
//
    if(Distance < PhotoTakeDistance){
      Serial.println("Photo Taken");
      delay(1000);
    }
  
  }
  delay(500);
}
    
download .ino

Camera

Grove - Serial Camera Kit is used.
Specifications
Input Voltage: 5V
Pixel: 300,000
Resolution: 640*480, 320*240, 160*120
Uart Baud Rate: 9600~115200
Communication: RS485 and RS232
Photo JPEG compression, high, medium and low grades Optional
AGC
Auto Exposure Event Control
Automatic White Balance Control
Focus adjustable
seeed wiki
Demo Github

Network board

ESP8266 ESP-WROOM-02 board is used.


TEST: Pre-saved Picture see in phone

Referenced this site how to see picture in ESP8266 conected SD card from Smart phone.
I used micro-SD card socket and connected to ESP8266 module like below.

Install SD_EasyWebSocket Beta ver 1.45 library to Arduino IDE.

Make "picture" folder in microSD card and save .jpg or .bmp file in to "picture" folder.
Download https://github.com/mgo-tec/ESP8266_picture_send_HTML_devide_files and open .zip file. Copy "EWS" folder to microSD card like above.
Open "ews_hesd.txt" under "EWS" folder and change ESP8266's IP address where is line10 and line189. Then save this file as "UTF-8". Conpile and send sketch to ESP8266 board

download ino

"CAT.JPG" is show in serial moniter


Open browser in iPhone and access ESP8266's IP address.