Introduction: Easy Bee Counter
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.
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?
- 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
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).
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.
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.
2) install shift registers qty(6), SIP 22R LED resistors and 100k pulldown resistors.
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
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.
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
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
- Pin 10 for gates 0-11
- Pin 11 for gates 12-23
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.
- feather Huzzah from mouser
- feather esp8266 from mouser
- feather LoRa 900mhz from mouser
- ItsyBitsy M0 from mouser
- ItsyBitsy M4 from mouser
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.
This is an entry in the
PCB Design Challenge