Vending Machine for Birds

Simple, inexpensive bird feeder that dispenses peanuts in exchange for dropping stuff in a hole. A vending machine for clever birds.

Similar projects worth following
An inexpensive, simple bird feeder that dispenses a nut for dropping stuff in a hole and can be built from analog components and discarded or scrap objects. Pest-resistant, runs on 5V, one moving part. No 3D printing or laser cutting required, just some basic hand tools. Lots of improvement and customization possibilities. Lots of possibilities for the enclosure.


- portable
- battery/solar or mains powered
- keep-alive for USB power banks
- cheap to build
- accessible components and materials
- highly customizable
- can be built as an outside platform or into an operant conditioning box
- optional external monitoring and control

This is not a new idea. I have a page here listing some of the similar projects I have come across in the past few years.

A vending machine for birds that rewards them with food when they drop something in a hole. Electronics and enclosure materials cost <100 USD/EUR. I've designed a PCB and PVC pipe enclosure and dispenser (described below). The circuit is not complex, but I think a custom PCB makes it easier for people who are not electronics hobbyists to build this. I've made a few different enclosures out of scrap for this, but will share the PVC pipe enclosure details since it's sturdy, waterproof, and the materials can all be found at the hardware store.

There were two main inspirations for me to start and  document this project

  • Hans Forsberg - designed his own machine and was the first person I learned of that had birds (magpies) bringing items to deposit on thier own
  • Josh Klein - makes his Crowbox designs freely available and supports people who want to build it

I would like to thank PCBWay for helping me get the PCB made.


  • portable
  • saves power until a warm body is present
  • battery or mains powered
  • one moving part
  • accessible components and materials
  • rodents can't break in and get the food
  • cheap to build
  • customizable


The circuit is all analog, using four NE555 timers and one LM358 dual op amp. The sensors are all made using IR phototransistors and IR LEDs. The PCB has headers broken out so you can monitor and control it with a microcontroller or SBC. It runs on 5-6VDC, but be sure to use 5V if you are planning to power a USB device (like a camera) with the vending machine's USB ports. If you use a USB cable to power the vending machine, be sure it can deliver enough current. I found that some 10-year-old 2-meter USB 2.0 cables were resulting in a voltage drop from 5 to 4.5-4.8 volts on the vending machine power rail.  Cables that didn't work so well had a resistance >1Ω. Ones that did had a resistance of <0.5Ω. NE555's should get at least 4.5 and Raspberry Pis need at least 4.7V. If things are not working as expected, use a multimeter to check the rail voltage - it should be around 4.9V. Shorter cables are less lossy and take up less space inside the enclosure. 

Power consumption at 5V is as follows:

Without RPi Zero W

  • Idle with Powerbank Keep-Alive and TImer enabled: 18mA
  • Timer uses 8mA
  • Powerbank Keep-Alive uses 4mA
  • ^With both of these disabed it uses 6 mA
  • IR LEDs on: 320mA
  • IR LEDs and motor on: 510mA

With RPi Zero W and wide-angle camera module

  • Idle with Powerbank Keep-Alive and TImer enabled: 220mA
  • IR LEDs on: 520mA
  • IR LEDs and motor on: 820mA

So with the Rpi and camera you could get about 2 days out of a 20,000 mAh power bank. With just the vending machine you could get about 10 days.


  • Powerbank Keep-Alive: 555 sinks current every 7-22 seconds for 0.7-2.2 seconds to keep USB power banks on while sensors are in standby - the powerbank keep-alive can be disabled.
  • IR LED ON/OFF: 555 keeps the IR LEDs used by the sensors on for 22 seconds after the last PIR trigger
  • Op Amps: LM358 used as comparators to adjust the threshold of the sensors and send signals when they are triggered
  • Motor Controller: 555 turns on the dispenser vibration motor when the deposit sensors are triggered, tuns it off when the dispense sensor is triggered
  • Timed Dispense: 555 dispenses food every 10-100min - timed dispense can be disabled
  • Daytimer: Phototransistor that puts the timer in reset while it's dark outside - brightness threshold can be adjusted or disabled (Rev. B)
  • PIR Sensor: Sends a signal to turn on the sensor IR LEDs
  • Deposit/Dispense Sensors: IR phototransistors and IR LEDs used as proximity sensors to monitor the deposit and dispense chutes
  • Hopper Level Sensor: IR phototransistor and IR LED to detect when the food level gets low (Rev. B)
  • Monitoring/Control: lines for monitoring and triggering events with an external controller (Rev. B)


Kicad Files (Github):
Gerbers, PCB and BOM (PCBWay):

Read more »


Getting a steady stream of magpies and jackdaws. Still in Phase 1 at this point.

MPEG-4 Video - 1.49 MB - 04/17/2024 at 13:21



First visitors to the unshelled peanuts version with VMFB-MC

MPEG-4 Video - 781.75 kB - 03/27/2024 at 17:04



Brief functional demo with the Rev B V 1.1 board from PCBWay and improved dispenser.

MPEG-4 Video - 2.79 MB - 10/29/2023 at 19:47



Brief functional demo with the new board from PCBWay

MPEG-4 Video - 27.06 MB - 06/04/2023 at 12:53


Vending Machine For Birds_16-29-47.mp4

Jackdaws are starting to use the bottlecap magazine.

MPEG-4 Video - 922.07 kB - 05/25/2023 at 14:31


View all 23 files

  • Some revisions after testing

    Stephen Chasey05/07/2024 at 14:10 0 comments

    I ran into some problems with the vending machine a few weeks ago. This led to a bit of code cleanup, but the real problem was too little space in the enclosure where I was putting the main PCB, RPi ZeroW and the camera. This led to some wires getting stress-damaged and led to some weird behavior.

    Once I found the cause I revised the enclosure to provide more space and better accesibility to the electronics. I replaced the 110mm/50mm T-joint hilding the camera with a 110mm T-joint and an eccentric 110mm-50mm adapter. Now there is more space and the electronics are easier to mount and get to.

    I'm also adding a "calibration mode" you can activate from the web interface so you can calibrate the deposit and dispense sensors without triggering events and optimizing the pin usage on the RPi to work better with the wire arrangement coming from the VMFB-MC PCB.

    I'm taking a break from this for a couple weeks, but should have the latest hardware and software deployed on the balcony again before the end of May.

  • Dispensing Unshelled Peanuts

    Stephen Chasey04/17/2024 at 13:22 0 comments

    I've made many adjustments to the dispenser assembly in the past two weeks of testing. Unshelled peanuts are more dificult to reliably dispense than shelled peanuts - they vary more in size and shape, they are less dense with a rougher surface. They jam very easily, and the size/shape variance makes it difficult to dispense just one. I usually get 2 or 3 peanuts at a time with this dispenser.

    First I had occasional jams in the hopper itself, leading me to

    • increase the size of the pathway from the hopper to the dispense chute
    • add a debridging arm

    Here is the underside of the vibration plate showing where the motor and sensors are mounted.

    These changes solved the hopper jams. Then I had jamming in the dispense chute. To solve this I removed the red cup that caught peanuts on their way out. This helped reduce the frequency of jams, but the real issue was using several segments of pipe in the chute. Each joint was an opportunity for a jam. Replacing this with a single piece of pipe seems to have solved this for now. If there is a jam, it is at the opening at the bottom and the birds can pick it out and remove the jam themselves.

    I'm getting a pretty steady stream of magpies and jackdaws now. Along with some pigeons that remember when this dispensed shelled peanuts :)

  • VMFB-MC for unshelled peanuts deployed

    Stephen Chasey03/27/2024 at 12:50 0 comments

    It passed some basic tests and is on my back balcony now.

    I think I may have put too much strain on the camera cable as blue and green are faded. I will fix that later. 

    UPDATE - I was using an IR camera... I replaced it with a normal one.

    Now hoping to get some jackdaws and magpies interested. I got my first visitors already.

    Here's what it looks liike on the balcony.

  • New enclosure ready for testing

    Stephen Chasey03/25/2024 at 15:31 0 comments

    To avoid problems associated with feeding pigeons in my neighborhood I revised the design to accomodate peanuts in the shell, which corvids love. After some trial and error (and some poor designs) I finally have my test candidate assembled. It's not as small or pretty as I want it to be, but I think it will work. This is my 7th enclosure design and the 5th one based on 110mm PVC. I also made a base out of a discarded wooden pallet so I can move it around easier.

    It does have enough room for batteries and an opening below the platform to get a mains line or solar charging cable in. The bottom comes off by loosening a hose clamp to replace batteries. The electronics are accessible by removing the top (everything above the camera arm). 

    A wide-angle camera is mounted on a rotatable mount so you can position it as you like. The deposit hole and dispense chute are on either side of the platform to reduce the chance that a bird drops food into the deposit hole and the dispense chute is 50mm instead of 32mm to accomodate the larger unshelled peanuts.

    Now to put the electronics inside and do some more tests before setting it outside. It should be out back by this weekend.

  • PCBWay 6th Project Design Contest

    Stephen Chasey03/14/2024 at 13:57 0 comments

    A while back I submitted the analog version of this project to the PCBWay 6th Project Design Contest, and I actually got a prize!

    PCBWay has been very supportive of this project since the beginning and I am excited that the first PCB I made with Kicad got some recognition.

    Now to finish assembling and testing the peanuts-in-the-shell enclosure for the microcontroller version.

  • Code is ready (functional anyways)

    Stephen Chasey02/23/2024 at 15:13 0 comments

    After a month of occasionally working on moving all the main logic to one python script and debugging I think it's ready. It's all interrupt- and timer-driven, just like the analog version. It took a little work to make sure it worked well with both op amps and comparators, especially since I did not really design the circuit to work with comparators (no feedback to reduce hysteresis) and did not include capacitors to absorb the initial blip you sometimes get with phototransistors.

    In the analog version, I had the camera recording while the sensor IR LEDs were on instead of using motion detection. For this version I'm still just enabling and disabling motion detection to trigger recording.

    I also optimized the status overlay for motioneye so it's more informative.

    The code works, but is as a friend of mine described it, "janky". There is still room for improvement, but for now it's usable and appears to work consistently.

    • You can enable and disable the powerbank keep-alive and timed dispense from the web interface.
    • You can trigger a manual dispense event from the web interface.
    • The video overlay indicates the state of PIR, deposit, dispense, feed level, sensor IR LEDs and the dispense motor. 
    • The video overlay also shows the count of how many times PIR, deposit, dispense, timed dispense and manual dispense were triggered that day.  
    • You can easily use other types of sensors or switches in place of the PIR and phototransistors if your situation calls for it.

    Here is a screenshot. The numbers are the result of testing and debugging. The sensor IR LEDs are on (SIR is red). The peanut level is low and the timer is enabled.

    I will share some better screenshots and a short video soon.

    I found a better way to mount a camera in the enclosure so it gets a good shot of the platform without being in the way or using a side-mounted arm. 

    Finally I found a better solution for rodent-proofing that should allow me to make the enclosure a little smaller without making it easy for rodents to get in there and have a feast. I have not had any rodent issues since I started this project, but this is a pervasive problem with bird feeders and I want to mitigate it as much as possible.

    I expect to have another complete prototype based on the VMFB-MC with the above improvements and dispensing peanuts in the shell ready in the next 3 weeks. Since the peanuts will be in the shell, pigeons will not be able to eat them, but the jackdaws, magpies and crows that come by my balcony love them. Hopefully this will keep me from running afoul of the HOA for feeding pigeons.

    I think these changes, along with the event logging and dashboard, will make this a more practical solution for students and researchers wanting to experiment with behavioral conditioning and collect data automatically. The VMFB can be adapted to use with other animals like rats or mice and apply to different use cases.

  • VMFB-MC PCB Populated

    Stephen Chasey01/07/2024 at 02:59 0 comments

    I found time to populate the board and am working on the code to make it work with an RPi Zero W and motioneyeos. Hope to be able to demonstrate it soon.

    From top left to bottom:

    Dispense Sensor, Empty Sensor (for peanut level)

    Deposit Sensor

    Main Board

  • VMFB-MC PCB Received

    Stephen Chasey01/03/2024 at 18:56 0 comments

    Fabricated, shipped and received in less than a week - and over the New Year holiday!

    Quality looks great as usual (PCBWay) - looking forward to populating and testing it.

    For anyone insterested, here's the PCBWay share project link:

    The all-analog VMFB and the VMFB-MC PCBs side-by-side to show how much smaller it is without all the 555's :) The main board is now about the same size as a Raspberry Pi Zero.

  • Update and smaller PCB footprint/BOM

    Stephen Chasey12/15/2023 at 18:08 0 comments

    It's been a little over a month since the student in Warsaw deployed one of these and despite freezing temps and lots of snow the thing has been working fine. It does get clogged with snow build-up though, so a small resistive heater on the plarform is a good idea if you are doing this when there is a lot of snow.

    I experimented with dispenser designs that could reliably dispense unshelled peanuts. The one I landed on is just a simplified version of the shelled peanut dispenser. One baffle at a 10-15 degree angle, one vibrating plate with an opening on one side. It works pretty well, and would allow me to deploy it where feeding pigeons is prohibited since pigeons can't eat unshelled peanuts and can't figure put how to open them. The larger openings makes keeping it rodent-proof a challenge. The dispense tube went from 32mm to 50mm. A rat or small squirrel could get in there and cause problems. I'll have to think of a solution for that.

    In an effort to make this a more useful research tool I designed a new PCB that relies on external GPIO to work. Sadly, no 555's in this one, but the BOM is smaller (44 components including headers) and so is the footprint (6.5x6.8cm including sensors). This should make it easier to build and install, and you can use prety much any microcontroller, development board, ot SBC to control and monitor it.

    It's not fully baked yet - I will create a version tag after I get one made and teseted.

    Current Schematic

    Current PCB

    Board Dimensions: 65x68mm




    Component Count: 44

    Ref Qnty Value
    D1, D2, D3, D4, D5, D6, D8 7 IR LED
    D7 1 1N4001
    J1, J2, J3, J6, J7, J8, J10 7 Conn_01x04_Pin
    J4 1 Conn_01x02_Pin
    J5 1 Conn_01x03_Pin
    J9 1 Conn_01x05_Pin
    Q1, Q2, Q3, Q4, Q5, Q6, Q9 7 SFH313FA-2/3
    Q7, Q8 2 TIP120
    R1, R2, R4, R5, R6, R7 6 150R
    R3 1 1K
    R8, R9, R10, R11, R12, R13, R14 7 10K
    RV1, RV2 2 100K
    U1 1 LM393

    Total BOM cost for all electronic components including a Raspberry Pi Zero W, 8GB micro-SD card, a wide-angle camera module, PIR sensor, a motor and a terminal strip (to make the vibration motor) cost €59.62 at Mouser (not  the cheapest place, but while I'm in the Dallas area for the holidays delivery is next day). Jumper wires (36x F/F) are not included in this BOM, but cost around €6 in most cases. The PCB will cost about €7 per board at PCBWay.

    Here is the Mouser cart (minus some non-informative columns).

    Mfr. NoManufacturerDescriptionOrder Qty.Price (EUR)Ext.: (EUR)
    TIP120STMicroelectronicsDarlington Transistors NPN Power Darlington20.7441.49
    SFH 313 FA-2/3ams OSRAMPhototransistors PHOTOTRANSISTOR70.6424.49
    LM393PTexas InstrumentsAnalog Comparators Dual Differential10.4280.43
    1N4001Diotec SemiconductorRectifiers Diode, DO-41, 50V, 1A10.2140.21
    15400594F3590Wurth ElektronikInfrared Emitters WL-TIRC IR THT Blue 5mm 940nm70.42.8
    61304011121Wurth ElektronikHeaders & Wire Housings WR-PHD 2.54mm Hdr 40 P Single Str Gold11.421.42
    MF1/4LCT52R151JKOA SpeerMetal Film Resistors - Through Hole 1/4 WATT 150 OHM 5>#/td###60.1010.61
    MF1/4LCT52R102JKOA SpeerMetal Film Resistors - Through Hole 1/4 WATT 1K OHM 5>#/td###10.1010.1
    MF1/4LCT52R103JKOA SpeerMetal Film Resistors - Through Hole 1/4 WATT 10K OHM 5>#/td###70.1010.71
    PT10WV10-104A2020-1CRPMAmphenolTrimmer Resistors - Through Hole 100K 20% 10mm POT CREAM COLOR SHAFT20.8861.77
    114992065Seeed StudioCamera Accessories Camera Cable for Raspberry Pi Zero12.32.3
    SC0065Raspberry PiSingle Board Computers Raspberry Pi Zero WH (With Pre-soldered GPIO Header)114.8814.88
    U054M5StackInfrared Detectors An M5StickC compatible human body induction sensor13.263.26
    PPN7PA12C1MinebeaMitsumiAC, DC & Servo Motors DC Brush Motor, Flat, 11605RPM, 5VDC12.72.7
    39100-1802MolexBarrier Terminal Blocks TERM STRIP 8MM HIGH PROF 2 CIR WHT10.7350.74
    114110130Seeed StudioCameras & Camera Modules OV5647-160 FOV IR Camera module for Raspberry Pi 3B+4B, suitable for large or night...
    Read more »

  • Shipped one

    Stephen Chasey11/08/2023 at 13:47 0 comments

    I received my packaging materials today, so I packed up and shipped one to Warsaw for the student I mentioned a couple of updates ago.

    This is what they will get:

    I had to break it down a little for shipping (I included mounting hardware):

    So it would fit in a 100x25x35cm box (weight 7kg):

    I used soooo much bubble wrap - I hope it arrives in good condition.


    They received it in good condition. Hopefully setup will go ok. I really want this to be easy to setup and use, so this is a good test.


    After fixing a few connections that came loose in shipping, it seems to work and is mounted. Now it's up to the birds. Kudos to the student for some excellent troubleshooting and fixing.

View all 105 project logs

Enjoy this project?



l.ennyburkdoll wrote 05/15/2023 at 06:11 point

That project is best for birds.

  Are you sure? yes | no

Stephen Chasey wrote 04/22/2023 at 10:24 point

A shortcut to useful logs:

Dispenser Detail:

Some things I learned during this project so far:

PVC Enclosure Detail:

Pics of my first two enclosures:

Similar projects:

  Are you sure? yes | no

John Opsahl wrote 09/23/2022 at 04:35 point

This project is way cool. Do you have a video of a bird dispensing an item and receiving a peanut? 

  Are you sure? yes | no

Stephen Chasey wrote 10/19/2022 at 14:52 point

Yes, there are a couple of videos in the files section.

  Are you sure? yes | no

Stephen Chasey wrote 08/07/2022 at 06:58 point

It could be adapted to dispense a peanut for each commit :)

  Are you sure? yes | no

fdufnews wrote 08/05/2022 at 14:22 point


When I read the title, I first thought of a system to feed a pool of programmers

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates