I use this smart photo trap in my terrarium. You can inspire and use it, where you want. Final output of these project is collect data and insert them into database.
This projects has two main parts:
- Collect actual climatic data in terrarium.
- When capturing motion between 9 - 12h, run the video sequence and save the climatic data at the time of acquisition.
You will need folowing things:
Computer - Any work machine, which we use as server. That's mean, that computer will permanently running. Feel free to use Linux or Windows OS.
Database - In this project I use MongoDB, because red-NODE works with format JSON. Of course if you are prefer other database like MySQL you can go for it as well.
PlayGround - Its BigClown software, which help us faster basic config and include Node-RED aswell.
Node-RED - Is software which help us to program our hardware.
IP Camera - You can use any wireless IP camera. I use camera, which works with http/rstp protocol.
We will build one PIR kit and two climate kits. One out terrarium second one in terrarium.
Modules
At first we make basic config of our modules. There are two option how to make it.
For Windows user I recommend you to use PlayGround. How to setup PlayGround
Summary in steps:
- Connect radio dongle with computer and get ready up all modules.
- PlayGround => Firmware => Check Firmware.
- PlayGround => Devices => Connect dongle and start pairing.
- PlayGround => Functions => Node-RED setup.
- PlayGround => Messages => Check if you getting datas from modules.
For Linux user I recommend you to follow official documentation.
Step 3: Setup Node-REDFor Windows users use PlayGround => Functions.
For Linux users install node-RED: For more deatails follow documentation.
npm install -g --unsafe-perm node-red
Explanation:
When PIR detect motion and timeswitch node is true (9-12 h) exec node will start bash script, which take a photo and then save name of video to help file. Finall function trap just collect all datas together and then insert into database. What functions does? Mostly just save data into flow.
In Node-RED click on Menu => Import => Import and paste this code. Might you have to add mongodb plugin into Node-RED, before you insert code. Updated data part should be in code as well.
nano /home/camera/camera.sh
#!/bin/bash
DATE=`date '+%Y-%m-%d_%H-%M-%S'`ffmpeg -i <camera_IP> -c:v copy -t 15 -an /home/camera/files/$DATE.mp4echo "$DATE" > /home/camera/helperchmod +x camera.sh v daném adresáři
Step 5: Setup MongoDBFor Windows users folow these documentation
For Linux users follow these documentation.
If you are using Debian 9. MongoDB is part of official repository.
apt-get update && apt-get upgrade -y
apt-get install mongodb
systemctl start mongodbsystemctl stop mongodb
Step 5: Final OutputWe are almost finished. We got data into database. Now we can do whatever we want. I personally wrote webservice and use these data in mine webside. Of course you can use blink or dashboard instead of using database.
There is my example of website.
Comments
Please log in or sign up to comment.