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..

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: 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.

Animal Innovations Contest

Participated in the
Animal Innovations Contest

1 Person Made This Project!


  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest

50 Discussions


5 months ago

Hello,I'm digging into this project again. It's been so long sense the last design I plan to make some improvements.
The price of Printed Circuit Boards (PCBs) has come down quite a bit so I'm making a large sensor board, 24 gates and about 14.5" long to go all the way across the hive body. Also about ~1.5" wide to block out any IR from the sun. Let me know if you have any questions/ideas.

5 replies

Reply 2 days ago


nice design, have you worked on the improvement yet? I just see your message, after I fully rerouted the PCB and (almost) placed the order.

as I said below, you can chain it to have Nx12 gates so it still works for small hives. You may also be able to trim it in order to cut away the last 4 gates, not totally sure though I need to double-check that

I just signed up on instructables and will probably fork this project somewhere with documentation



Reply 5 months ago

Thomas, I have just acquired and hive and being middle aged the creation of this is beyond me, even though I an in technology I was never good with soldering, electronics or coding. I have a Pine A64 but what would it take for you to build with all parts and then send to the UK. Would you even be prepared to do this?


Reply 2 days ago

I would. see my comment below, in reply to Edkraus' question.


Reply 2 months ago

Hi Thomas, great project. Just wanted to see if you have an update on the the improvements you were planning to make?


Question 8 months ago on Step 3

I know this is an OLD probably dead thread, but now with the availability of the Arduino ESP32 that has dual band WIFI and Bluetooth onboard it would make for an amazing upgrade, and the are just $5 ordered from China! I'm just no good at PBC design and I don't know how to adjust your board in Eagle design software to house it.
my other actual question is, Are the version 1 and version 2 using the same PBC board
and do you have any left over wasting space in your drawer?

5 answers

Answer 2 days ago


since I can do PCB design and felt some improvements were needed, I designed a 3.14159 version.

It features fewer vias, cleaner layout and tracks, also it is chainable (you can append more or less as many boards as you want to the end of the previous one).

one of the best features, IMHO, is probably the presence of motivational messages for the bees on the PCB, depending whether they go in or out.

I looked into a few sensors, and decided to keep the QRE1113 because they are cheap and the single-LED arrangement is smart.

I am about to order a batch from production, how many would you want? Leave your comments below, I might wait a few days for your feedback. Cost for a single 160x16mm is expected to be around 3$ without shipping and handling.

Those who are wondering about raspberry pi will know that I am planning on using such a device to monitor the hive, also with temperature sensors and a few other things as I get the time to implement it. Arduino is so dead-slow when it's not running inside an interruption I find it pretty much useless except for very basic stuff (this project _could_ be considered basic but I won't bother with arduino anymore)


Reply 17 hours ago

I think it’s great you picked this project back up. Sadly the Pi is not feasible for me and many other beekeepers that have to run off batteries and solar. That’s why my project is based around the ESP32 and Variants for the micro amp usage. I done have the ability to have a dedicated power source at my apiary. I tried again and failed to use a PCB program to drain a board around the ESP32 it’s just not in my skill set. This is where I’m at with a solar add on


Reply 18 hours ago

duh.. I forgot to mention I added holes for mounting screws and wider tracks for all the power lines


Answer 5 months ago

I'm digging into this project again. It's been so long sense the last design I plan to make some improvements.
The price of Printed Circuit Boards (PCBs) has come down quite a bit so I'm making a large sensor board, 24 gates and about 14.5" long to go all the way across the hive body. Also about ~1.5" wide to block out any IR from the sun. Let me know if you have any questions/ideas.


Reply 5 months ago

That would be great I’d love to try an upgraded board out. I spent a week+ watching videos on PCB design although I grasped the concept I was unable to design or retro fit your board to fit the ESP32 I posted above. I’m currently running boards with BME280 that read humidity, temperature, and barometric, also have a lux (light) sensor. The ESP32 utilize deep sleep mode to maximize battery, run on solar charging li-ion 18650B 3400mah batteries. Frame below represents a concept of a drop in, still have to enclose the sensor and esp with a mesh or mini box. I have many ideas please feel free to message me. I’ve just been fooling around with this on my days off.


Question 11 months ago on Introduction

Dear Thomas. I'm Marlon. Thomas your Bee Counter II, only work with Arduino? I want to know if working with Raspberry Pi series. Thank you.


1 year ago

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,



2 years ago

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 ! :)


2 years ago

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.


2 years ago

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.



3 years ago

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,


2 replies

Reply 3 years ago

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


Reply 3 years ago

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

Thank you!!