IOT BIRD HOUSE

by Boateng in Circuits > Arduino

67 Views, 0 Favorites, 0 Comments

IOT BIRD HOUSE

IOT BIRD HOUSE
msg5676182169-1240.jpg

Birds have always fascinated me with their vibrant colors, graceful movements, and melodious songs. As a passionate birdwatcher, my goal has been to observe these beautiful creatures up close without disturbing their natural environment. Inspired by this love for birds and a desire to blend technology with nature, I embarked on creating an IoT Bird House. This smart solution allows me to monitor birds remotely and interact with them gently, and non-intrusively.

The IoT(Internet of Things,) Bird House project aims to revolutionize birdwatching by integrating modern technology. It combines sensors, a camera, cloud connectivity, and solar power to enable real-time monitoring of bird activity, environmental conditions, automated feeding, and instant notifications upon bird detection.

Supplies

Components Needed:

  • Arduino Uno R4
  • ESP32-CAM Module
  • DHT22 Sensor
  • PIR Motion Sensor
  • Servo Motor
  • Jumper Wires
  • Breadboard
  • Solar Panel
  • Battery
  • Charge Controller

Tools Needed:

  • Cutting Machine
  • Glue Gun
  • Ruler

HOW THE IOT BIRD HOUSE WORKS

Screenshot 2024-06-24 143232.png
Screenshot 2024-06-24 011022.png
Screenshot 2024-06-24 143159.png
Screenshot 2024-06-24 145131.png
photo1719243800 (1).jpeg
photo1719243772.jpeg

Sensors and Data Collection:

  • DHT22 Sensor: Measures temperature and humidity levels inside the birdhouse. Data is sent to the Arduino Uno R4 for processing.
  • PIR Motion Sensor: Detects motion, specifically bird activity within the birdhouse. Upon detection, it triggers subsequent actions.

Video Monitoring:

  • The ESP32-CAM module captures live video feed from inside the birdhouse. It connects to the local Wi-Fi network and streams video to the cloud for remote viewing.

Feeder Control:

  • A servo motor is used to control the bird feeder. Commands from the Arduino IoT Cloud instruct the servo to dispense food, ensuring birds are fed without direct human intervention.

Cloud Connectivity:

  • The Arduino Uno R4 connects to the Arduino IoT Cloud. It sends sensor data (temperature, humidity, and motion) to the cloud for real-time monitoring. Users can view this data through the cloud dashboard.

Notification System:

  • Upon detecting bird motion via the PIR sensor, the system triggers notifications:
  • Email Notification: Sends an email alert to the user, notifying them of bird activity.
  • Mobile App Notification: Sends a notification to the user's Arduino mobile app, providing instant updates on bird activity.

Solar Power Integration:

  • A solar panel is integrated into the birdhouse design to harness solar energy. This energy is stored in a battery via a solar charge controller, ensuring continuous power supply to the Arduino board.


Downloads

Designing the Birdhouse

1c81bbdd-300c-4c3e-8cb0-b46545d82827.jpg
2cccc8e6-64c5-44ce-9123-df8725ca3156.jpg
IMG-20240623-WA0026.jpg
SMART BIRD HOUSE (4).png
SMART BIRD HOUSE (5).png
SMART BIRD HOUSE.png
SMART BIRD HOUSE (1).png
SMART BIRD HOUSE (2).png
SMART BIRD HOUSE (3).png
d8f09b65-682f-41d5-a88e-1494aebec7d5.jpg
IMG-20240623-WA0014.jpg
d1879335-6b3f-4bbb-94a2-c18a4ae5fddf (1).jpg
4464038b-30c7-4bb4-ad02-11e0fa5506a1.jpg
00c53a71-a2bf-4364-a33d-5406ca524919.jpg

Design Concept:

  • Utilize Tinkercad or another design software to create a birdhouse enclosure. Ensure it's spacious enough to accommodate all components while providing adequate ventilation and access points for maintenance.

Dimensions and Features:

  • Design the enclosure to fit the Arduino Uno R4, ESP32-CAM module, sensors (DHT22 and PIR motion sensor), and servo motor for the feeder.
  • Include openings for the solar panel mount and a clear area for the camera view.

Preparing for Assembly:

  • Once designed, prepare to cut the necessary materials using a cutting machine based on your Tinkercad design. Ensure precision to fit all components.


Mounting Components

IMG-20240623-WA0041.jpg
IMG-20240623-WA0044.jpg

Mounting Components:

  • Install the Arduino Uno R4, ESP32-CAM module, DHT22 sensor, PIR motion sensor, and servo motor inside the custom-built birdhouse enclosure.
  • Use a glue gun to secure components in place. Ensure sensors and the camera have clear lines of sight and are correctly positioned for optimal functionality.

Wiring Connections:

  • Use jumper wires to connect the sensors (DHT22 and PIR motion sensor) and servo motor to the Arduino Uno R4.
  • Ensure connections are secure and follow the wiring diagram specific to your project.


Setting Up the Feeder Mechanism

IMG-20240623-WA0011.jpg
IMG-20240623-WA0040.jpg

Attaching the Servo Motor:

  • Securely attach the servo motor inside the birdhouse enclosure, positioning it near the feeder mechanism.
  • Use screws or adhesive to mount the servo motor in place.

Preparing the Feeder Mechanism:

  • Attach a small platform or mechanism to the servo motor's shaft.
  • Connect a bottle filled with bird food to this platform.

Feeder Assembly:

  • Position the bottle with bird food above a feeding tray or platform inside the birdhouse.
  • Ensure the servo motor's mechanism can open the bottle mouth to dispense food when activated.


Setting Up the Solar Power System

msg5676182169-1222.jpg
msg5676182169-1241.jpg

Mounting the Solar Panel:

  • Attach the solar panel to the top of the birdhouse enclosure using screws or adhesive, ensuring it's positioned to receive maximum sunlight.

Connecting the Charge Controller and Battery:

  • Wire the solar panel to the charge controller and then to the battery inside the birdhouse. This setup ensures continuous power for the Arduino Uno R4 and ESP32-CAM module.


Setting Up Arduino IoT Cloud

msg5676182169-1237.jpg

Create an Arduino Account: Sign up on the Arduino IoT Cloud.

Add a New Device:

  • Go to the "Devices" tab and click on "Add device".
  • Choose "Set up a third-party device" and select Arduino Uno R4.

Create a Thing:

  • Go to the "Things" tab and click on "Create Thing".
  • Add your device to the Thing.
  • Create variables for temperature, humidity, motion, and feeder control. For instance:
  • temperaturepin (Type: CloudTemperature, Read-Only)
  • humiditypin (Type: CloudRelativeHumidity, Read-Only)
  • motionpin (Type: CloudMotionSensor, Read-Only)
  • servopin (Type: CloudSwitch, Read/Write)

Set Up Dashboard:

  • Once your Thing is created, go to the "Dashboard" tab.
  • Click on "Add Widget" and select the widgets you want to display (e.g., temperature, humidity, motion, feeder control).
  • Configure each widget to display the respective cloud variable (e.g., temperaturepin, humiditypin, motionpin, servopin).




Wiring the Components

msg5676182169-1232.jpg
msg5676182169-1231.jpg
msg5676182169-1224.jpg

Connect the DHT22 Sensor:

  • VCC to 5V
  • GND to GND
  • Data pin to digital pin 7

Connect the PIR Motion Sensor:

  • VCC to 5V
  • GND to GND
  • Data pin to digital pin 2

Connect the Servo Motor:

  • VCC to 5V
  • GND to GND
  • Signal pin to digital pin 9

Connect the ESP32-CAM:

  • Connect the ESP32-CAM to the FTDI programmer:
  • GND to GND
  • 5V to 5V (or 3.3V if your FTDI supports it)
  • U0R to TX
  • U0T to RX
  • GPIO0 to GND (for programming mode)


Writing the Code for Arduino Uno R4



#include <Arduino_ConnectionHandler.h>


/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/b56cac9d-ecf7-4e18-8881-650ae71a60d5 


  Arduino IoT Cloud Variables description


  The following variables are automatically generated and updated when changes are made to the Thing


  CloudBool motionpin; // Change type to CloudBool
  int lightpin;
  int servopin;
  int servopin2;
  CloudRelativeHumidity humiditypin;
  CloudTemperature temperaturepin;


  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/


#include "thingProperties.h"
#include <DHT.h>
#include <Servo.h>  // Include the Servo library


#define DHTPIN 7
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);


#define MOTION_PIN 8 // Define the pin for the motion sensor
#define LIGHT_SENSOR_PIN A0 // Define the pin for the light sensor


float temp;
float hum;
bool motionDetected;
int lightLevel;


Servo myServo1;  // Create a Servo object for the first servo
Servo myServo2;  // Create a Servo object for the second servo


void setup() {
  dht.begin();
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 


  // Initialize the motion sensor pin
  pinMode(MOTION_PIN, INPUT);
  
  // Defined in thingProperties.h
  initProperties();


  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
  */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();


  myServo1.attach(9);  // Attach the first servo to pin 9 (change to your desired pin)
  myServo2.attach(10); // Attach the second servo to pin 10 (change to your desired pin)
}


void loop() {
  ArduinoCloud.update();
  
  temp = dht.readTemperature();
  hum = dht.readHumidity();
  motionDetected = digitalRead(MOTION_PIN);
  lightLevel = analogRead(LIGHT_SENSOR_PIN); // Read light sensor value


  // Pass temperature, humidity, motion, and light values to cloud variables
  temperaturepin = temp;
  humiditypin = hum;
  motionpin = motionDetected; // Update motionpin variable
  lightpin = lightLevel; // Update lightpin variable


  // Your code here 
}


/*
  Since Lightpin is a READ_WRITE variable, onLightpinChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onLightpinChange()  {
  // Add your code here to act upon Lightpin change
}


/*
  Since Servopin is a READ_WRITE variable, onServopinChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onServopinChange()  {
  myServo1.write(servopin);  // Move the first servo to the position specified by servopin
}


/*
  Since Servopin2 is a READ_WRITE variable, onServopin2Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onServopin2Change()  {
  myServo2.write(servopin2);  // Move the second servo to the position specified by servopin2
}


/*
  Since Motionpin is a READ_WRITE variable, onMotionpinChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onMotionpinChange()  {
  // Add your code here to act upon Motionpin change
}


Writing the Code for ESP32-CAM

Open the Arduino IDE and create a new sketch.

Install the necessary libraries

#include "esp_camera.h"

#include <WiFi.h>

#define CAMERA_MODEL_AI_THINKER // Has PSRAM

#include "camera_pins.h"

Use the following code to set up the ESP32-CAM

//Camera code
#include "esp_camera.h"
#include <WiFi.h>
#define CAMERA_MODEL_AI_THINKER // Has PSRAM
#include "camera_pins.h"


// Enter your WiFi credentials
const char* ssid = "newtons1";
const char* password = "newtons1234";
void startCameraServer();
void setupLedFlash(int pin);


void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
Serial.println();


camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer= LEDC_TIMER_0;
config.pin_d0 =Y2_GPIO_NUM;
config.pin_d1 =Y3_GPIO_NUM;
config.pin_d2 =Y4_GPIO_NUM;
config.pin_d3 =Y5_GPIO_NUM;
config.pin_d4 =Y6_GPIO_NUM;
config.pin_d5 =Y7_GPIO_NUM;
config.pin_d6 =Y8_GPIO_NUM;
config.pin_d7 =Y9_GPIO_NUM;
config.pin_xclk =XCLK_GPIO_NUM;
config.pin_pclk =PCLK_GPIO_NUM;
config.pin_vsync= VSYNC_GPIO_NUM;
config.pin_href =HREF_GPIO_NUM;
config.pin_sccb_sda = SIOD_GPIO_NUM;
config.pin_sccb_scl = SIOC_GPIO_NUM;
config.pin_pwdn =PWDN_GPIO_NUM;
config.pin_reset= RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.frame_size= FRAMESIZE_UXGA;
config.pixel_format = PIXFORMAT_JPEG; // for streaming


//config.pixel_format = PIXFORMAT_RGB565; // for face detection/recognition
config.grab_mode= CAMERA_GRAB_WHEN_EMPTY;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.jpeg_quality = 12;
config.fb_count =1;


// if PSRAM IC present, init with UXGA resolution and higher JPEG quality
//for larger pre-allocated frame buffer.
if(config.pixel_format == PIXFORMAT_JPEG){
if(psramFound()){
config.jpeg_quality = 10;
config.fb_count = 2;
config.grab_mode = CAMERA_GRAB_LATEST;
}
else {
// Limit the frame size when PSRAM is not available
config.frame_size = FRAMESIZE_SVGA;
config.fb_location = CAMERA_FB_IN_DRAM;
}
}
else {
// Best option for face detection/recognition
config.frame_size = FRAMESIZE_240X240;
#if CONFIG_IDF_TARGET_ESP32S3
config.fb_count= 2;
#endif
}
#if defined(CAMERA_MODEL_ESP_EYE)
pinMode(13,INPUT_PULLUP);
pinMode(14,INPUT_PULLUP);
#endif
// camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
return;
}
sensor_t * s = esp_camera_sensor_get();
// initial sensors are flipped vertically and colors are a bit saturated
if (s->id.PID== OV3660_PID) {
s->set_vflip(s, 1); // flip it back
s->set_brightness(s, 1); // up the brightness just a bit
s->set_saturation(s, -2); // lower the saturation
}
// drop down frame size for higher initial frame rate
if(config.pixel_format == PIXFORMAT_JPEG){
s->set_framesize(s, FRAMESIZE_QVGA);
}
#if defined(CAMERA_MODEL_M5STACK_WIDE) ||defined(CAMERA_MODEL_M5STACK_ESP32CAM)
s->set_vflip(s, 1);
s->set_hmirror(s, 1);
#endif
#if defined(CAMERA_MODEL_ESP32S3_EYE)
s->set_vflip(s, 1);
#endif
// Setup LED FLash if LED pin is defined in camera_pins.h
#if defined(LED_GPIO_NUM)
setupLedFlash(LED_GPIO_NUM);

#endif
WiFi.begin(ssid, password);
WiFi.setSleep(false);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
startCameraServer();
Serial.print("Camera Ready! Use 'http://");
Serial.print(WiFi.localIP());
Serial.println("' to connect");


}
void loop() {
// Do nothing.Everything is done in another task by the web server
delay(10000);
}

Conclusion

photo1719243772 (2).jpeg
photo1719243772.jpeg
photo1719243800 (1).jpeg
Screenshot 2024-06-24 145131.png

By following these step-by-step instructions, you can successfully build an IoT Bird House that enhances your birdwatching experience through technology. This project not only provides real-time monitoring, feeding capabilities, and environmental data collection but also promotes environmental awareness and conservation efforts in a practical and engaging manner.