Easy Bee Counter




Introduction: Easy Bee Counter

About: just have to figure out how all these things go together....

2019 Easy Bee Counter V.1

This version of the bee counter is easy to solder and assemble (all through-hole). It's been tested and works* with sample code provided.

The current tested design is easy to program and approachable to beginner programmers. The printed circuit board accepts multiple Arduino platforms made by Adafruit including their line of Adafruit Feather type micro-controllers and Adafruit ItsyBitsy micro-controllers. The Adafruit feathers include wifi and long range radio features (esp8266, esp32, and LoRA). All the ItsyBitsy 3V models (M0, M4, and 32u4) should work fine.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Data Analysis - Why Count Bees?

Possible Uses

  • the rate of expansion or decline of bee flights might indicate hive health
  • the expansion or decline of orientation flights over days might signal queen health
  • the time shift between peaks of bees leaving and returning might indicate number of foragers and distance to pollen/nectar source.
  • comparison between two or move hives to test for manipulations; such as,
    • adding/removing honey supers
    • internal sugar syrup feeding
    • oxalic acid mite treatments
  • introduction to electronics, soldering and micro-controller programming
  • honey bee education or museum type installation

Hive health

Equating bee flight data and orientation flights to over all hive health or queen health seems possible. Orientation flights is a behavior of 'middle aged' bees about 20 days old. Before foraging bees of this age will leave the hive as a group at around mid day resulting in an easy to see ~45min peak in data.

If there is a drop in orientation flights it might indicate a reduction in egg laying ~42 days prior (22 days hatch + 20 days till forage).

Foraging distance

It's easy to see in the data small but distinct shifts between bees OUT and bees IN. This indicates both a volume of bees that are leaving and returning together as well as a rough distance or time to the foraging location.

Step 2: Improvements on Previous Design

  • All through-hole components for easy soldering
  • Dual footprint, socketed, off-the-shelf uControllers => Feather and ItsyBitsy
  • Program in Arduino, Lua, and microPython - A total of 24 gates, 48 sensors, 6 shift registers
  • ~14.75" long stretching the entire opening of a langstroth hive for easy placement
  • using 2 PCBs to create a sandwich is an inexpensive quick solution. The PCBs must be ordered black (see instructions) so the IR LED emitter is absorbed into the material.
  • using 6 pin headers to create the turn-styles or gates
  • N-Ch mosfet controlled IR LEDs such that LEDs can be controlled ON for short periods during while sensing (~75us). Allows for reduced power to less than 1ma (plus uController).

Step 3: General Operation

Infrared (IR) Sensors

Honeybees are forced through 24 gates where optical sensors (48 sensors) determine whether the bee is present and determine the direction of the bee movement. Each optical sensors has an IR LED and an IR sensor. If no bee is present the IR light is absorbed into the black surface. If a bee is present the IR light reflects off the bee and triggers the sensor.

The 48 LEDs are divided into two sets of 24 with each set controlled by an N-ch mosfet. The normal forward voltage of each IR LED is 1.2V and about 20ma as shown on the data sheet. Two LEDs are connected in series with a 22ohm resistor. There are jumpers on the board that allow the LEDs to bypass the current limiting resistors. Do not solder the jumper until fully tested! Refer to assembly instructions.

Shift-in registers

There are 6 shift-in registers. Here's a great description for how to connect and program shift registers. The micro-controller's SPI pins read the shift registers. All six shift registers are read at the same time. The sensors are normally pulled low and show 3.3V or HIGH when a transistor is triggered and a bee is present.

The PCB design connects the USB power pin from the micro-controller to the 3.3V regulator so that a USB cable connected to the micro-controller can power the entire project.

Step 4: Assembly Instructions

This version of the bee counter is all through hole components. It's easy to solder and assemble. This is the 2nd version of the board (V1) completed March 2020. If you got the Version 0 board (Jan/Feb 2020) you just have to fix some of my previous mistakes including adding a jumper wire shown here.

1) Install IR sensors - QRE1113 or ITR8307

2) install shift registers qty(6), SIP 22R LED resistors and 100k pulldown resistors.

- Shift registers, qty(6) 74HC165
- 22ohm resistors, bussed, qty(4) SIP Packaged, bussed
- 100k ohm resistors bussed, qty(6) SIP-9, 8 resistors, 9 pins

3) install power mosfets qty(2), - N-Channel Mosfet FQP30N06

4) install small capacitors

5) place/solder 3.3V power regulator

- 3.3V Regulator, (input, ground, output - IGO, pinout), qty(1)

6) install large Capacitor

- 560uF, 6.3V Capacitor

7) install green screw terminals, qty(3)

- screw terminals Two pin, 0.1", qty(3)

8) install headers for microprocessor

9) install qty(4) 10K Resistors (picture is wrong.. only shows 2 resistors) - i2c pullup resistors - pulldown resistors for power mosfets

Step 5: Initial Testing

TEST sensors Before you go any farther, test all your LEDs/sensors! It's much easier to test these now before going further. Run the sample code Blink_IR_Leds.ino

The IR LEDs are invisible to the human eye but many phones and cameras allow you to see the IR LEDs. See picture. (unfortunately most iphones have IR filters so try another phone until you see IR leds). This step is very important so make sure you can see all the LEDs.

LEDs look good? If no LEDs are blinking? Check to make sure you have 3.3V on the 3.3V pin header. If one or two LEDs are out, reflow your pins and/or replace the LEDs until you get 100% LEDs blinking together. LEDs good, great, next test the shift registers with the sample code test_shift_registers.ino

Use a white piece of paper to trigger the sensors. If some sensors are not working, check your pins, heat up and reflow solder on pins as needed.

Step 6: Final Assembly

Finish assembly once all sensors are tested. Install the headers that connect the top PCB to the bottom PCB. !

Ok, once everything is tested out, you can solder these jumpers.... Soldering the 24 jumpers increases the throw range of the IR sensors by increasing the forward voltage and current in the LED. This is fine to do if we keep the LEDs ON time to less than 100us. This is described in the data sheet.

Two scripts provided, both test_shift_registers.ino and bee_counting.ino satisfy this requirement by only turning the LEDs ON for 75us. This is shown on line 68 (shift register) and line 158 (bee_counting). Following the ON time there is a delay of ~15-20ms before turning them ON again which preserves the life of the LED.

Solder all 24 of the jumpers.

Step 7: Dual Footprint Micro Controller Pinouts

The printed circuit board accepts two Adafruit style of micro-controllers. The Adafruit Feather type micro-controllers and Adafruit ItsyBitsy micro-controllers. The Adafruit feathers include wifi and long range radio features (esp8266, esp32, and LoRA). All the ItsyBitsy 3V models (M0, M4, and 32u4) should work fine.

Hardware SPI

The example code is written for the Feather ESP32 and itsybitsy M0/M4 but should work fine with others. The hardware SPI pins are used for both: MISO & SCK.

Pin A5 on both the ESP32 and itsyBitsy is the Shift Register LOAD

Power Mosfets

Two pins are connected to the power mosfets driving the IR LEDs

  • Feather pins
    • Pin 15 for gates 0-11
    • Pin 33 for gates 12-23
  • ItsyBitsy pins
    • Pin 10 for gates 0-11
    • Pin 11 for gates 12-23

Extra Pins

There are Screw Terminals (green) to connect additional sensors to the i2C pins (SDA and SCL)
There is also an analog pin A4 connected to one of the screw terminals.

Step 8: Arduino Code

There are three arduino scripts attached.

  • Blink_IR_leds.ino - used to visually inspect LEDs working
  • test_shift_registers.ino - used to functionally test sensors
  • bee_counting.ino - used to count bees!


Soldering the 24 jumpers increases the throw range of the IR sensors by increasing the forward voltage and current in the LED. This is fine if we keep the LEDs ON time to less than 100us.

Two scripts above, both test_shift_registers.ino and bee_counting.ino satisfy this requirement by only turning the LEDs ON for 75us. This is shown on line 68 (shift register) and line 158 (bee_counting).

Calibrating the Bee Counter

I've captured some amazing data over the years. It's possible to calibrate the bee counter to achieve the required repeatability. There are different ways to calibrate the bee counter depending on the desired effect. One method is to measure the speed of the bees movement and only count known movements and throwing out all false triggers. This method misses a lot of bees but can give consistent values. It takes a bee about 180-350ms to traverse the sensor region.

The example code bee_counting.ino measures the speed of the bees through the sensor and counts bees moving faster than 650ms and demands the time between finishing one sensor and finishing the 2nd sensor is less than 150ms.

Some of the obstacles to calibrate for include:

  • although bees don't add propolis to sensors they will spend several days filling voids with propolis upon initial installation
  • bearding in the summer evenings and general guard bees mulling about give false triggers
  • direct sun light at a low angle will false trigger sensors (this can be mitigated pretty easily)

Step 9: Bill of Materials


The code was tested with the feather esp32 Huzzah and itsyBitsy M0 but will work with all these boards.

Printed Circuit Board from JLCPCB ~$16-25 with shipping.

Order the PCBs Black. See PCB ordering instructions.

Parts and Pieces

Here is summary pricing list from mouser. See alternative pricing below for cheaper options specifically for the reflectance sensors.

QRE1113 Reflective Sensors qty(48)

6 pin female headers 7mm high, 0.1" spacing, qty(~36)

22ohm resistors, bussed, qty(4) SIP Packaged, 9 resistors, 10 pins

100k ohm resistors bussed, qty(6) SIP-9, 8 resistors, 9 pins

Shift registers, qty(6) 74HC165

3.3V Regulator, (input, ground, output - IGO, pinout), qty(1)

screw terminals Two pin, 0.1", qty(3)

0.1 uF Ceramic Capacitor, through hole, qty(6)

1 uF Ceramic Capacitor, through hole, qty(1)

560uF, 6.3V Capacitor low esr, 3.5mm lead spacing, 8mm diameter

N-Channel Mosfet FQP30N06, qty(2)

Alternative pricing from Chinese distributor LCSC

Someone pointed out some alternative pricing that can really bring the cost down.

Step 10: Printed Circuit Board Ordering

There are a lot of different PCB manufacturers to choose from. These instructions show JLCPCB. You need a manufacturer that can make black PCBs. The IR LEDs/sensors need to point to a black surface to prevent false triggers, so the bottom PCB has to be black. Minimum JLCPCB is qty(5) boards and you'll need 2 boards to sandwich together to complete one bee counter.

1. Download the zipped gerber files... Right click and 'save link as' to download "gerbers.zip"

2. Go to JLCPCB.com, create an account and click the ORDER NOW button.

3. Click on the "Add Your Gerber File" and upload the ziped files

4. Select 'Black' as the PCB color. Also for "Remove Order Number", select YES

The cost is about $8 for a minimum order of qty(5) PCBs plus $9-16 shipping depending on method.

PCB Design Challenge

This is an entry in the
PCB Design Challenge

Be the First to Share


    • Tiny Speed Challenge

      Tiny Speed Challenge
    • Clocks Contest

      Clocks Contest
    • PCB Design Challenge

      PCB Design Challenge

    18 Discussions


    2 days ago

    this is simple??? :D :D

    awesome job man!


    Reply 12 hours ago

    Electronics is a trap. be warned!


    3 days ago

    Wow what a great project !
    What software are you using to draw your graphs?
    I'm actually working on a bee hive scale that sends weight, temp, humidity and atmospheric pressure through Sigfox network, but I don't know what to use to make a clean web interface...
    Anyway, thanks for sharing !


    Reply 12 hours ago

    My buddy worked on the web interface couple years ago. He's going to pick up this project in a couple months once the bees start flying. So I'll update then. I don't know what's best to use right now. I think adafruit.iO might be something to look at.


    Question 3 days ago

    This looks like a great project to keep me busy until my new packages arrive. I attempted to order the PCB and when I uploaded the .zip the dimensions were cleared out. Are there particular dimensions I should input? Thank you in advance.


    Answer 12 hours ago

    You upload the zip files directly to the board manufacturer. If you'd like to see the files you can download Audesk Eagle PCB software and open the xxxx.brd file


    4 days ago

    Truly ingenious
    " 1. Having great inventive skill and imagination.
    2. adj. Marked by or exhibiting originality or inventiveness.
    3. adj.Having genius; brilliant. "
    Such a cool innovative project that touches so many of the Sciences.
    This really deserves a huge audience. Hope more people learn about it.


    Reply 3 days ago

    You bet! And thank you. Yeah I never get tired of studying bees.... super organisms have hints of humanity, keep secrets of botany, have engineering in their DNA, and support like a 1/3 of our food supply.


    4 days ago

    I'm amazed and inspired! Well written and documented. I've been considering adding a little science to my small bee yard and I've added this to my list.


    Reply 3 days ago

    Thanks and good luck!


    3 days ago

    Very interesting project...

    I'd like to make one for a beehive I'm looking after...

    I'm not sure on my engineering skills though...


    Reply 3 days ago

    Well the boards are fairly cheap and the micro-controller is not too expensive either. You can also just buy a few of the other parts (buy 3 of everything) and do a partial build and see how it goes. This is a great beginner soldering project.


    4 days ago

    I need this project, it's very simple and you've done a good job. Currently I measure the internal heat output and count the bees with a webcam.
    Thanks for your work.


    Reply 3 days ago

    Yeah I love seeing CV projects. It's definitely key to future research. I really want to do a CV project for bees too.


    3 days ago

    I really want to make this....don't have any bees, but it looks like a really cool project!


    Reply 3 days ago

    I get a lot of educational institutions looking for someone to build one for them. I'll try to pair you up with one.


    10 days ago

    Thanks for writing up this project. I am not a bee keeper but saw the link on the Adafruit fourms and took a look. Reasonably priced custom PCBs are a game changer for Arduino and other electronics projects.


    Reply 9 days ago

    Yea the cost of PCBs has definitely been a game changer. The cost to MFG/ship the boards for this project has dropped from ~$140 to ~$15