Security Cam (Part 1)

makermattfeatured, Projects1 Comment

One of the first things I wanted to get when we got our hose was a home security system. Getting locked into a commitment though is not something I wanted to do. Some of those companies are like 30 bucks a month?!? I mean, I'm sure they provide a good service but do I really need them? Well I hope not because I took the first step in building my own home security system.

What better way than to start with a security camera, of course with a few maker twists.

So I think I'm going to start breaking up these posts into 3 parts... and they are.. wait.. no... 4 parts... yea, 4 is better right? 

  • Parameters
  • Design/Components
  • Coding
  • Final Product

So without further ado. Wait, what the hell is ado anyway? Well let's just throw in a little ado. Ado.

Parameters

Well one of the first things this device needs to have a camera.. I mean, it's in the title of the blog man! 

Now the question was what kind of camera should I go with. I really don't want to go with a proprietary camera, too hard to interface it into things. Plus, you have to end up using some 3rd party app that may or may not be sending your waist size and list of fears to China. Originally I went with the Yi Home Camera since there was a really simple hack that opened up the entire system. Unfortunately they recently changed the firmware and bye-bye hack. Would have been nice to know before I ordered one but oh well, live and learn.

So I need the following

  • Camera
  • PIR sensor (for motion)
  • Temperature sensor

So here are the ones I went with.

  • Digmoo DG-M1Q Camera

    Digoo DG-M1Q

  • PIR Sensor

  • Temperature Sensor DHT11

Design/Components

For the camera the Digoo DG-M1Q was the way to go, and I found it on a super sale for just over $10 so it was a win-win. Wish I would have ordered more! Even at $20 it's a great buy. I'll show you later how that goes into the HA/NVR systems.

So the camera is good, what else do we need? Oh yea, a motion sensor, that would be important right? So there is a really generic PIR sensor that works really well. Only has a couple of adjustments that need to be made and we are ready to go.

The temperature sensor is next, and I went with the DHT11. I ordered some DHT22s but I'm having some issues with delivery so I had to get a DHT11. It does seem to work well though so no complaints. As a bonus I get humidity too!

Having all these in one box was important to not only save space but also it's nice to just hang one box and have it all. I got some project boxes and started making some holes.

  • Cutting the template out of a piece of paper. The camera is the little black circle. 

  • Bottom view with temp sensor.

     

  • Bad picture but here is the D1 mini

Coding

So the coding on this was a little bit of a pain in the butt. The PIR sensor was really easy, once it detects motion/heat then it goes high and that's it. You just need to monitor for the HIGH/LOW and you can report accordingly. I did have to play with the distance and time adjustments though but that wasn't too bad. There is a H/L jumper though which you need to pay attention to as that determines how the sensor reports. The H is "retriggering", which basically means that it stays high as long as it detects motion. The L is "non-retriggering", so it sends a pulse every second when there is motion detected. The H setting is what I'm looking for, basically when the wire is HIGH (insert joke here) there is motion.

The biggest pain was the DHT11, there were tons of examples but not of them seemed to work. I finally got it working and was able to get both reading with pretty decent accuracy. Below are a few highlighted code snippets.



Here is the DHT stuff. This library worked out well once I got it configured.

#include <DHT.h>
#define DHTPIN D5
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
char hchar[2];
char fchar[5];

Here is the check temp/humid function. I had to change the float to a char[] using dtostrf which was more fun than one person should have.

void checkTemp() {
    float h = dht.readHumidity();
    float f = dht.readTemperature(true);
    dtostrf(h, 2, 1, hchar);
    client.publish(humidsub, hchar, true);
    dtostrf(f, 4, 1, fchar);
    client.publish(tempsub, fchar, true);
    sendudp("living_room_temp value=" + String(f));
    sendudp("living_room_humidity value=" + String(h));
}
Final Product/Conclusion

Image Image Image
Image Image

All in all this turned out to be a good project! I will probably have these in most of the rooms downstairs, and a smaller version without the camera in every room. I'm also adding a gas/smoke sensor to it as well so I can report on that as well.

As always thanks for reading and please leave comments or reach out with questions. Hopefully in a few weeks I'll have the smaller sensors built and post those.

Until next time!

Share this Post

One Comment on “Security Cam (Part 1)”

Leave a Reply

Your email address will not be published. Required fields are marked *