Cart 0

Prototyping a Wildlife Camera

Posted by Matthew Little on

This blog post covers the main design choices and prototyping stages from developing a wildlife camera unit. I had seen the ESP32-CAM, which is based on the ESP32 wifi module. It's incredibly low cost and does some amazing things (including face recognition) with the example code other people have written.

I got hold of a couple of samples and thought they would be perfect for a low-cost, solar powered wildlife camera which might be useful in lots of applications. This post covers the work I did on firmware design and PCB design for the unit. 

All of the code and PCB design is available in this open-source github repository:

Please note: This is under development and may not work as expected as I add new features.


Firmware design

The first thing was to look at using the ESP32 with the Arduino IDE. There are lots of websites with information to get you started. Some websites that helped me were:

I would say that the Random Nerd Tutorials have been the most help and are the best starting point if you are interested in this kind of project!

When updating this project I found this video which is basically exactly the same thing as I am presenting here:


One of the most annoying things with the EXP32-CAM is that it does not have a USB-Serial converter on-board. I assume this is for cost savings. You can use a USB to serial converter, along with adding a jumper to put the unit into programming mode when it starts up. This is a bit of a hassle so I invested 12 whole Euros in the cam-prog from bitluni on Tindie. This has the USB to serial converter on a nice header board. It also has an automatic reset so that you don't need to press the reset button after programming. This makes everything nice and easy, so I would recommend getting one from bitluni. 

This all got me to the point of uploading code to the ESP32-CAM. Uploading the ESP32->camera->cameraWebServer example through the Arduino got a pretty usable webcam which also had face recognition that worked pretty well! Amazing for just a few ££!

I looked around and saw that there was a huge variety of 'trail cameras' available. Most seem set up for hunting (which I'm not really into), but they also seem to be good for wildlife monitoring as well. They are available ready-made for prices from around £30 up to £400.

I wanted a slightly hack-able version with lots of features, but at a lower price point. I also like DIY kits, so this would be a DIY system, with through hole components as much as possible.

I developed my version of the code to achieve the following specifications:

  • Must react to a PIR trigger
  • Must react to an external switch input
  • Can be set to do time-lapse photos, if required
  • Flash can be set on/off
  • Unit will be in sleep mode most of the time to conserve power
  • Unit is solar powered with a li-po 18650 cell
  • Unit must be easy to configure in the field with no code upload required.
  • Timestamp added to photo file

Please check out the github repository for the code, which hopefully has explanations of how it works.

Settings file

I developed the code so that, when the unit wakes up, it looks for a "settings.txt" file on wake up. From that file the unit can be configured.

The settings are:

  • FLASH_FLAG - Use a flash with the photo? (0 (OFF) or 1 (ON))
  • NUMBER_PHOTOS - How many photos to take when waking up?
  • TIME_TO_SLEEP - How long (in seconds) between wake-ups (when in LAPSE mode)
  • MODE - The mode to use is either LAPSE (wake up every TIME_TO_SLEEP seconds) or TRIGGER (either wake up on PIR trigger or external trigger)
  • PHOTO_DELAY - delay (in milli-Seconds) between taking the photos.
  • FLASH_START_DELAY - Flash will switch on then wait this time before taking photo (in milli-Seconds)
  • FLASH_STOP_DELAY - Flash will be on and wait this time after taking photo (in milli-Seconds)
  • DEBUG_FLAG - See debug info on serial port (0 (OFF) or 1 (ON))
  • DEBUG_PHOTO - See debug info on serial port (0 (OFF) or 1 (ON))

This allows for multiple configuration settings. If there are no settings uploaded then the defaults (programmed into the unit) are used.

Real Time Clock

I added a DS3231 real time clock module. This is read using the I2C interface. Some pins have to be shared with this line, so eventually I found that using GPIO14 and GPIO15 worked as the I2C interface when configures with the "wire.begin(I2C SCL, I2C DAT)" line. Please check the code for the details on this.

One thing I still need to implement is how to configure the time. At the moment I set the RTC clock time directly using another sketch then use the RTC module in my circuit.

There is an annoying red power LED on the RTC module I used. This needs to be removed to save a bit of power, as every mA matters when things are solar powered!

The RTC module can be seen in this photo of the prototype, along with the repurposed solar 18650 charger PCB I used below.

This has been updated to a smaller RTC module (but samer IC) and also the solar charger has been added to a circuit board:


I wanted the unit to wake up either with a sleep timer, so that it wakes up at regular intervals, or with an external trigger. The external trigger happens on GPIO13.


I wanted to use a low cost PIR sensor to trigger the unit when a moving heat source goes by. Most of the PIR sensors I found work at 5V but not at 3.3V. Eventually I found the AM312 module which is designed to run at 3V so will work with the 3.3V I have available.

You can adapt other PIR modules to work at 3.3V by bypassing the regulator, but I didn't want that hassle!


I also added an input to run the camera from an external switch input. This is buffered through a transistor. There is also a push switch to trigger this, so you could make your own little photo booth!

This switch input could be used to trigger the camera, say when a trap or external detector has been set off.

Real Time Clock

I added a DS3231 real time clock module. This works through I2C, so I added the SCLK and SDA lines to two pins on the ESP32-Cam. I chose the wrong ones initially and it stopped the unit programming along with SD card! I used

Solar Power

I had already designed a 18650 li-po battery charger using the BQ24210 from Texas Instruments. This IC can take a solar PV panel input voltage from 4.5 to 18V DC and recharge a single lithium-polymer cell (such as the commonly available 18650 cells) with up to 800mA. This can give up to 2.5W into the battery, so a maximum of 2.5Wp solar PV panel should be used. I had some 1W panels so have rigged that up to work with the prototype.

WiFi Connection

As we have WiFi on the module, I added a bit more code to send the photos to an email address. I followed this guide, again from Random Nerd Tutiorials.

I used the ESP32 Mail Client library by Mobizt. NOTE: This is now depreciated!

DEC 2021: I have now updated to the new ESP Mail Client, also by Mobizt

I set up a new email account from which to send my photos (as you need to make it low-secure (allowing less-secure apps, such as this one), don't use your normal email for this!).

I took AGES trying to figure out how to both use 1 bit mode for the SD card (and hence get more pins to control the LEDs and the I2C) but also use the mail client. It turns out this is quite easy. When you set up your SD card you can use the line " MailClient.sdBegin(14, 2, 15, 13) " rather than SD_MMC, which what I used before. This solved everything (but took several nights of figuring it out).


I designed a PCB for this and got some made up. I made a few mistakes, but eventually got it work, as shown here:


I have updated the PCB and schematic file in the github, but have not had any new circuit boards made yet. I'm going to develop a bit more with what I have until I know it's working OK.

Night Vision

Edit: Night vision is a bit difficult. It involves removing the IR filter from the ESP camera and then adding an additional IR cut filter, which I found a unit with simple cut in/out. I'll try and add this on my next version.

The last thing I wanted for the camera was to run some external LEDs to add to the flash capability. This can be done by taking an output from GPIO4 (which controls the on-board bright white LED) and using an external transistor to run even more LEDs. This worked perfectly for adding a 3W white LED to give an even brighter flash (the on-board LED is pretty darn bright, though).

I also needed to check if the camera would react to infra red (IR) light, so I could then do some basic night vision.

I ran a bank of 950nm IR LEDs from the power supply to trigger along with the flash. These were picked up by the camera, so I think it does react quite well to IR light. At the moment a bank of 4 IR 940nm LEDs does not give a very bright image, even when run at high current.

I am ordering some more ultra-bright IR LEDs to add to this and test. It might be that many more IR LEDs are required to produce the brightness required. This needs more testing - any input useful, if you can comment!

I tested the unit by putting it all in a cardboard box and triggering the camera (with the flash white LED covered in tape).

There are two main wavelengths for infra red LEDs, 850nm and 940nm. As 850nm is closer to visible wavelengths then they sometimes have a visible red/purple glow, whereas 940nm LEDs cannot be seen by humans.

I read that most cameras are sensitive to 850nm, but fewer are sensitive to 940nm.

Also, with most cameras there is an IR filter on the lens. This blocks the IR so that the unit works well in daylight, but means that it is not sensitive to the IR light for night vision. I found this very useful post on removing the IR filter from the ESP32-CAM:

So it seems that there will have to be two options - a daylight version and an IR version. I'll try one with the IR lens removed.

Here are some more links for using the ESP32-Cam with IR for night vision:

I have added an electronic controller IR cut filter. This mechanically adds an IR filter to the camera. It requires an H-bridge power control circuit to reverse the applied voltage to the IR cut filter unit. This needs two more digital pin to control the filter, with the pins set high-low or low-high to set or remove the filer. When the filter has been set then these pins can be left floating. This might be more pins than we have available on the ESP32-CAM unit. This needs more work!

Time Lapse Function

One really nice feature I wanted to add was to have the unit as a low-cost solar powered time-lapse camera that can either save the photos to SD card or email them to a specific email address. Maybe like a very slow motion film! One frame a day from your garden!

This has been implemented by loads of other people - please do a search for them!

Once you have the photo taking and email control then actually setting a sleep period is pretty easy. I added some setting in the SD settings file which controls the mode: it can either be TRIGGER or LAPSE. TRIGGER will wake up on the PIR or push button trigger. LASPE will wake up every TIME_TO_SLEEP seconds. This involves two different methods of going to sleep, one setting an external wakeup (as detailed above) the other enabling a timer wakeup.

    To Do

    There are still a few problems to iron out with this unit:

    1. I need a nice, low-cost and waterproof enclosure for the unit. Most I see have camouflage covering as well, which would be a nice touch!
    2. Figure out adding IR and night vision to this.
    3. Update of PCB to fit in nice enclosure.

    Share this post

    ← Older Post Newer Post →


    • Hi Paul,
      Thanks very much for the comment and the links and information.
      I think this could be useful for lots of applications, especially for the price!
      I do have a microwave radar unit to play around with as I have also had problems with the triggering of PIRs. I’ll keep this page updated with any tests and info.
      It would be really intereting to add the AI element to the system – I was amazed by how good the face recognition was for the ESP32-cam out of the box!
      Best regards,


      Matt on
    • I really like what you are doing here.

      There is an enormous amount of effort going into AI and wildlife cameras for good, y’know, conservation, anti poaching etc.

      This project should really get picked up by them.

      I don’t want to pull you off track when you are clearly full-tilt into this, but I’m having pretty good results with RCW-0516 microwave radars ( instead of PIRs, they are really cheap.

      Take a look also at Andreas Spiess’ efforts to find the best performing ‘super power’ project and corresponding discord channel – single battery, low power, solar charging. He’s got together some known low power designers there from what I’ve seen (@burgduino)

      Paul Geraghty on

    Leave a comment

    Please note, comments must be approved before they are published.