Honey Bee Counter II





Introduction: Honey Bee Counter II

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

Hello, I've made this project easier to build, data log, and post data. This bee counter like the last design counts bees going in and out through twelve gates.

We've teamed up with some new researchers and business owners to provide bee metrics. You can reach me at Thomashudson.org.

.... and we're still interested in helping you build your own bee counter and this new design allows you to add dattalogging, connect to ethernet, wifi, or cellular. It also makes it easy to protect your most sensitive electronic parts..

Step 1: What You Need

What I like about this project is you can build it in pieces as you get comfortable with the parts...

You need a uController... say an Arduino

You need the bee sensor board:
Printed Circuit Board via Oshpark $19 for 3...
Qre1113 reflectance sensors (24 sensors for 12 gates) $10.08
Shift registers qty(3) $1.08 74HC165
pull down resistor array 100k qty(3) $2.04 100k resistor array
resistors LED qty(1) $0.68 47ohm resistor array
Headers qty(13) $5.85 six pin headers for the gates!

you need some plastic or wood pieces to surround your bee counter
you might want an ethernet, wifi, or data logging shield to log data
a plastic enclosure for your ucontroller

Step 2: How It Works - Electronics

Each gate has two QRE1113 sensors. When a bee is present, reflected IR light triggers the IR sensor HIGH and the shift register reads HIGH. Otherwise the 100K resistors pull the IR sensors low (to ground).

This design uses 3 shift registers. Each shift register can read 8 sensors or 4 gates for a total of 24 sensors and 12 gates. The shift registers continue to track the presence of bees and determines which way the bee is going.

Only one led from each sensor is used; such that, one IR LED provides enough light for reflectance to trigger both IR receivers when a bee passes under one. This reduces parts and simplifies the board.

The parts list for the main board is as follows:

Costs Per Board $6.5 via oshpark
Qre1113 reflectance sensors (24 sensors) $10.08
Shift registers qty(3) $1.08 74HC165
resistors 100k qty(3) $2.04 100k resistor array
resistors LED (47 or 100) qty(1) $0.68 47ohm resistor array, 100ohm resistor array
Headers for gates qty(13) $5.85 six pin headers

You connect the bee counter to your Arduino with five wires.

VCC=> 3.3V or 5V (for 3.3 volts use 45ohm LED resistor and for 5volts use 100ohm LED resistor)
MISO - master_in_serial_out, connects to QH
SCK - clock
Load - Parallel load pin
Gnd - ground

These are very standard connections for reading shift registers. Here is the classic button example from arduino

You may notice that I've broken out the VCC for the IR LEDs. This is done if you want to pulse (PWM) the LEDs and save on power.

Step 3: Soldering... Putting the Parts on the Sensor Board

Ok, brace yourselves... This is a great project to learn surface mount soldering!

All the parts are surface mount accept for the gates. The gates are made from 6 pin headers. You need to cut the middle 4 pins. Only the two outside pins are soldered.

There are a lot of surface mount soldering tutorials out there...but all you need for this project is:

Once you get everything soldered you can apply power and test your LEDs using a camera. Remember we only are powering one of the two LEDs so you will only see the the LED closest to the center lit up.

Solder the V2 jumper (labeled VCC) if you don't want to control V2 separately. Per the schematic, V2 allows you to control the LEDs independently. This might be useful for PWM of the LEDs. I've not tested this yet but it should work to reduce power.

Step 4: Hooking It Up and Getting Data

Before you get data... and even before you solder your gates on... I suggest testing your sensors with this easy shift register code.

pload Pin = 5; // Connects to /PL aka Parallel load aka latch pin the 165
dataPin = 6; // Connects to the Q7 aka MISO pin the 165
clockPin = 7; // Connects to the Clock pin the 165
plus VCC and GND.

I use a piece of white paper and slide it about 3-5mm over each sensor. The IR light will hit the sensor and reflect back into the receiver and trigger a 1 on your test code above.

Once that code is tested with your sensors you can try to save the data to an SD card... send it to your serial monitor, or post it to a webservice. You then need to come up with some simple data to COUNT BEES! This can be as simple as an if then statement. If the IN sensor is triggered first, followed by the OUT sensor ... you know the bee was going OUT. If the OUT sensor is triggered first, followed by the IN sensor is triggered, you know the bee is going IN. I can expand upon this code but it quickly becomes application specific.

I posted code here: github

Step 5: Bee Counter Enclosure

You need two enclosures. You need to wrap your bee counter in thin wood or 1/8" plastic. Then you have an ~18" cable from the hive entrance to your uController. You need an enclosure for the uController too.

I used ~3/16" pieces of plastic for the top of the bee counter and 1/16" at the bottom. I got this from the scrap bin at Tap Plastics. You want your top piece sturdy enough to overhang your entrance by 1" to stop direct sun light from triggering your sensors. The bottom of your bee enclosure must be black or painted black so it doesn't inadvertently reflect IR back into your sensor even though the spec sheet says the range is only ~1/4".

Also, I learned DON'T USE SILICONE. The bees hate silicone and will work feverishly to try to remove it.

The 2nd enclosure can be any water proof box that can house your uController.



    • Woodworking Contest

      Woodworking Contest
    • Planter Challenge

      Planter Challenge
    • Make it Move Contest

      Make it Move Contest

    We have a be nice policy.
    Please be positive and constructive.




    Hi Thomas,

    Thanks for the project, it's very nice I will try to make it. Right now I am traveling in China and I guess it's the best place where to buy all equipment for cheap.
    I send you PCB eagle.zip to a producer company here in Shanghai. They said they cannot print it, because they are missing some information. Do you have the full design to share ?

    Thanks again,


    Hi to all and tkns Mister Thomas for your sharing your work ! I am working on my 3rd bee counter and all goes just fine still working inside and I am learning a lot in this little project :) ... I wonder if some of you have actual experience to share on bee counting in the field... My mains wonders is about rain and light ... ? I am building a as complete as I can bee hive monitoring system ... any clue that can save me trouble in the futur will be very appreciate ! best regards to all ! :)

    Hi Thomas,

    I was buyed three PCB of Honey Bee Counter II via
    OSH Park, and mounted and connected to an Arduino Pro Mini. I also
    charged your code provided for the counter and seems to work, but now
    I'd like to count and store an amount of bees going in and out. Does
    your code have a continuity, an implementation to perform this?

    Thank you very much and regards.

    Hi Thomas,

    Great Project ! I appreciate your work on this. I just made two of your boards and tested them with the code your provided on git hub - worked great.

    Could you share example code for data logging - storing the data to an SD card with a time stamp? Or do you of know of someone who has posted this kind of example ?

    BTW, I fabricated the boards using the Controleo2 reflow oven setup


    I reflowed the sensor side first. After it cooled, I applied paste solder to the other side and then reflowed the shift register and resistor side.


    Hi Thomas,

    I was able to self-build
    your bee counter using white plastic materials for the gates and beam IR sensors. Into the
    lab all the gates worked fine but, outdoor, the sunlight cause problems,
    as you commented before. Now I want to forget this design in order to
    build a new one, following this instructable. But I can't find the
    Arduino sketch anywhere! Can you help me on this, please?

    Thanks in advance,


    4 replies

    I just posted some code here: https://github.com/hydronics2/Bee-counter-3.1/tree/master

    Wow! Great, Thomas. Now I can start testing the shift registers using your code.

    Thank you!!

    sorry I don't really have a good sketch to publish right now. I'll try to get it on github soon.

    Ok Thomas, thank you for your reply. I will wait for it.




    Any chance you would share your Eagle files? I'd like to order a solder mask from OSH. I'd also pondering adding an inexpensive wifi module.

    2 replies

    I added a zip file with eagle docs next to the schematics.


    I really appreciate your project. I'm working on a similar open source bee counter using two stacked HY810H 3/8" gap sensors instead of reflection sensing. The sensors form the gates and the current is very low at 1.5mA each @ 3V. I have a working prototype ref. http://hivetool.org/w/index.php?title=User:Adrian

    I'm wondering if you would be willing to consider the gap sensor? I'd really like to try your board design with the shift registers and modify it to use with the HY810H sensors. There are a few reasons for the change, less power, higher signal confidence using a narrow beam direct path, unaffected by target color. At least in theory. Please reach me at napaogdenatgmail.

    2 replies

    yes, I think a gap sensor would work great. I went with the reflective sensors because I thought at the time they were less expensive and then became interested in mfg with surface mount parts.

    Any chance you would be interested in collaborating on an updated design using the gap sensors and Nordic nrF52 BLE as a data processor and transmitter? I've picked out some nifty shift registers too. Everything low power to run off small LIPO cells.

    Well, I guess were going to develop independently at I have not received a response. napaogden_at_gmail.com

    Is this thread dead?

    Appreciate your effort! Great project! What is exact gate size? Side - wall to wall diameter and trough the gate diameter?

    Is it possible to distinguish drones from workers with current gate design?

    Thank you.

    2 replies

    the gates are 3/8 wide (9.5mm) and the headers are 8.5mm high. I've not completed the testing and finish the programming to distinguish between drones and workers but I think it should be pretty easy to do.

    Thank you for your answer. I have already ordered all components for 3 counters so we'll see it in action. :)

    Congratulations on a very useful project! I'd love to give it a go.

    What is your experience with it's accuracy when lots of bees are leaving (or entering) at the same time? Do two or more bees get counted as one? The gates obviously need to be large enough to allow drones (& queen) to go through but I wonder how much space that allows worker bees to crowd the gates?

    I have zero experience with Arduino, but I was wondering if your code can be directly used on a Pic MCU? I normally use Picaxe MCU's (easy to program) but translating your code will be a challenge.... Do you have a program flow diagram?

    Thanks again!