Smart Birdhouse
![IMG_20230617_153815518.jpg](/proxy/?url=https://content.instructables.com/FLU/P9EX/LJ00FL5M/FLUP9EXLJ00FL5M.jpg&filename=IMG_20230617_153815518.jpg)
![IMG_20230611_191124100.jpg](/proxy/?url=https://content.instructables.com/FOQ/LL9W/LIOLXTBT/FOQLL9WLIOLXTBT.jpg&filename=IMG_20230611_191124100.jpg)
A smart bird house, where the birds automatically get food, a place to nest where the temperature is monitored. Also a camera with a night filter that takes a photo when the motion sensor spots movement. Also a little bit of lighting outside for when it gets too dark.
The project is aimed at bird lovers or anyone who wants to attract and care for birds in their backyard. It can also be beneficial for the birds themselves, as they have a reliable place to build a nest and have food regularly.
You can keep track of the temperature and light level via the web app, if the motion sensor detects movement you can see this via the web app. Here you can also view the photo that the camera takes when there is movement, turn on the LEDs and also turn on the small fan to help control the temperature.
Supplies
For the electrical side of this project you will need the following supplies:
- Raspberry Pi 4 (I used the 2gb ram version and had some trouble when too much memory was being used)
- Breadboard power supply (3.3V, 5V) or batteries
- MCP3008
- LCD 2x16
- TMP36
- Light dependent resistor
- 2 PIR motion sensors
- Servo motor
- 12v DC fan
- 2 LEDs (I used White LEDs)
- RPi Noir camera (You could use the normal RPi camera)
For the housing of the project you can use the following materials:
- (Repurposed) wood
- Wood glue
- Materials for cutting the wood to the appropriate sizes
- A (clear) tube/bottle and cover (the cover connects to the servo, when moved food can dispense from the tube)
- Water resistant paint or clear coat
Connecting the Electronics
For the connection of the electronics i will be using a breadboard and a breadboard power supply on 5 and 3.3V. To read the values of my Light Dependent Resistor and Temperature sensor i used the MCP3008 to convert the analog signals to digital ones so i could read these signals via the PI. Connecting the MCP to the PI and the sensors to the MCP is shown in the documents.
The LCD will be useful for seeing the IP address on which the site is running so we can connect to it easier. Connecting the LCD screen can be done in some different ways but is chose to use all the wires. In the documents it is shown how you can connect the LCD.
The 2 motion sensors are connected via normal GPIO pins since these sensors only give 0 (no motion) or 1 (motion detected). Now that we have connected the sensors we can now connect the actuators. The LEDs are simple, just connect the positive leg to any GPIO pin and the negative leg to the ground of the breadboard. For the Power button it is the same, connect is to the ground and a GPIO pin.
For the servo motor you connect the positive leg to 5V, the negative to ground and the PWM wire to a GPIO pin, we can than control the servo using Pulse Width Modulation. For the fan i used a transistor since mine did not have a PWM wire, you connect the transistor by connecting the base to a GPIO pin, the emitter to the ground (using a resistor (470 ohm)) of the breadboard and the collector to the positive wire(s) of the fan. Then connect the ground wire of the fan to the ground of the breadboard. We can now control the current the transistor gives the fan and so we control the speed of said fan.
Last but not least connect the PI camera via the dedicated slot on the PI for a camera. I am using the RPI Noir camera which records better when it's dark but you can use any camera that can connect to the PI. If legacy camera support is enabled on the PI be sure to turn this off when using libcamera, it can only detect the camera if legacy support is turned off.
Building the Birdhouse
![IMG_20230605_130937072.jpg](/proxy/?url=https://content.instructables.com/FCF/QJX2/LIIV4N84/FCFQJX2LIIV4N84.jpg&filename=IMG_20230605_130937072.jpg)
![IMG_20230605_154333125.jpg](/proxy/?url=https://content.instructables.com/F6T/7LQL/LIIV4N8B/F6T7LQLLIIV4N8B.jpg&filename=IMG_20230605_154333125.jpg)
![IMG_20230605_154327425.jpg](/proxy/?url=https://content.instructables.com/FN2/6LOV/LIIV4N8C/FN26LOVLIIV4N8C.jpg&filename=IMG_20230605_154327425.jpg)
![IMG_20230605_154322594.jpg](/proxy/?url=https://content.instructables.com/FBR/Y590/LIIV4N8D/FBRY590LIIV4N8D.jpg&filename=IMG_20230605_154322594.jpg)
![IMG_20230605_150734651.jpg](/proxy/?url=https://content.instructables.com/FFB/9DVR/LIIV4N8E/FFB9DVRLIIV4N8E.jpg&filename=IMG_20230605_150734651.jpg)
First I measured how big the pieces needed to be and then drew templates on the wood so that i could easily cut out the pieces in the correct size. You can use the tools you like, I used a handsaw, and file to cut and sand the wood and to connect the pieces I used wood glue and nails.
Make sure the components u will use fit inside the designated places, don't forget the wires for the components also need to be guided through the birdhouse. For this I made a small opening on the left panel on the birdhouse itself, under the fan.
Integrating the Electronics
![IMG_20230611_191213783.jpg](/proxy/?url=https://content.instructables.com/F4F/0I12/LIOLUT6W/F4F0I12LIOLUT6W.jpg&filename=IMG_20230611_191213783.jpg)
![IMG_20230611_191205711.jpg](/proxy/?url=https://content.instructables.com/FMO/FVN7/LIOLUT86/FMOFVN7LIOLUT86.jpg&filename=IMG_20230611_191205711.jpg)
![IMG_20230611_191154073.jpg](/proxy/?url=https://content.instructables.com/FZ1/ACL1/LIOLUT9I/FZ1ACL1LIOLUT9I.jpg&filename=IMG_20230611_191154073.jpg)
![IMG_20230611_191143047.jpg](/proxy/?url=https://content.instructables.com/F5L/61LQ/LIOLUT9L/F5L61LQLIOLUT9L.jpg&filename=IMG_20230611_191143047.jpg)
![IMG_20230611_191137983.jpg](/proxy/?url=https://content.instructables.com/FG2/Z0H3/LIOLUT9Q/FG2Z0H3LIOLUT9Q.jpg&filename=IMG_20230611_191137983.jpg)
![IMG_20230611_191124100.jpg](/proxy/?url=https://content.instructables.com/FTU/6Q8V/LIOLUTCA/FTU6Q8VLIOLUTCA.jpg&filename=IMG_20230611_191124100.jpg)
![IMG_20230611_191223326.jpg](/proxy/?url=https://content.instructables.com/FAW/9KSD/LIOLUTCB/FAW9KSDLIOLUTCB.jpg&filename=IMG_20230611_191223326.jpg)
![IMG_20230611_191228081.jpg](/proxy/?url=https://content.instructables.com/FD7/SVP8/LIOLUTDL/FD7SVP8LIOLUTDL.jpg&filename=IMG_20230611_191228081.jpg)
![IMG_20230611_191231979.jpg](/proxy/?url=https://content.instructables.com/FF0/W0K9/LIOLUTEV/FF0W0K9LIOLUTEV.jpg&filename=IMG_20230611_191231979.jpg)
![IMG_20230617_153815518.jpg](/proxy/?url=https://content.instructables.com/F2W/RYHG/LJ00FM2P/F2WRYHGLJ00FM2P.jpg&filename=IMG_20230617_153815518.jpg)
When connecting the electronics, I made sure to have a compartment where i could house the pi and most of the cables and components. The camera will be mounted at the top and inside the birdhouse itself you will find the motion sensor for the camera and the temperature sensor. The LCD, power button and LDR are found at the front. The servo motor is controlled with the motion sensor next to it and will dispense food. For finishing this project and making it pretty/usable, you can paint the Birdhouse like I did or just cover it using a water-resistant clear coat.
Database for Code
![EER model.png](/proxy/?url=https://content.instructables.com/F7A/UD5H/LJ2VA2J2/F7AUD5HLJ2VA2J2.png&filename=EER model.png)
![Sensors.png](/proxy/?url=https://content.instructables.com/FQL/R4P1/LJ2VA2KR/FQLR4P1LJ2VA2KR.png&filename=Sensors.png)
![SensorsMetingen.png](/proxy/?url=https://content.instructables.com/F0H/XOKP/LJ2VA2KS/F0HXOKPLJ2VA2KS.png&filename=SensorsMetingen.png)
![Actuators.png](/proxy/?url=https://content.instructables.com/F2I/NISR/LJ2VA2KT/F2INISRLJ2VA2KT.png&filename=Actuators.png)
![Actuatorsstatus.png](/proxy/?url=https://content.instructables.com/FXO/1O8U/LJ2VA2KU/FXO1O8ULJ2VA2KU.png&filename=Actuatorsstatus.png)
For this project I created a database in MySQL Workbench. I will be storing my sensors, actuators, sensor measurements and actuator status. Above you see my ERD model of the relationships of the database and examples of what is stored in the database.
Code for Birdhouse and Site
To have this birdhouse functional you don't need a site because you could just run it in automatic mode. For our purposes we will be making a site for the birdhouse which will have several pages: The homepage, sensors page, controls page, history page and camera page.
- The homepage will give information about the project, who it's meant for and what it does.
- The sensors page will show us the current value of each sensor and give us the option to change the minimum for the temperature sensor.
- The controls page will allow us to run it in automatic mode or manual. Using manual will make it so that you can turn on/off the LEDs and fan but also allow you to dispense the food yourself when pressing the button.
- The history page will show us the history of the LDR and TMP36.
- The camera page will show us the last taken photo of the camera and allow us to take a photo ourselves.
Then there are some pages not listed in the menu:
- The edit minimum TMP page, on which you can edit the minimum value which says when the fan should be powered
- The edit minimum LDR page, on which you can edit the minimum value which says when the LEDs should be powered
Now comes the part where we make the Birdhouse smart, using Visual Studio code which is connected to the pi via SSH we can run a script (app.py). I won't go over all the code, but you can find the eventual code via this link: https://github.com/howest-mct/2022-2023-projectone-victor-van-hoecke.git