Introduction: Honey Bee Counter
Where the honeybee's division of labor has stayed on a steady progression for 25 million years... our human superorganism has grown more complex and in all directions... hence the bee counter... By: thomashudson.org
See the improved design here: Honey Bee Counter II
4/28/19 - 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.
Live data from - June 25, 2012
I've moved away from live data... my version 2 has an SD card and I'm partnering with a university to do some research... feel free to make your own WIFI enabled swarm detector and I'd love to partner someone that wants to sell them to the masses.
Attachments
Step 1: Manifesto
Bee Counter - Version 2, October 14, 2012
- micro SD datalogging
- real time clock turns OFF the counter at night for reduced power
- decoupled the LEDs from the microcontroller to reduce average power to 6.6 ma when not in use
- small battery will last for months
- solar cell power ready
- unlimited temperature sensors
- can perform estimates of size of the bee (worker vs drones) and therefore monitor drone/worker activity
- 3D printed turn-styles or gates
- for sale complete without battery $400 or make your own (see below)
Here are the specs for Version 1. This instructable details out Version 1 which is easily upgradable to version 2 though I've not provided complete plans.
- 95% Accuracy
- Runs off USB power
- should be rain resistant with a top cover
- bees adapt to new opening in a few minutes
- real time monitoring on google docs
- USB connection dumps data onto your laptop text file
Here's the plans to build your own. There are general instructions for prototyping or you can go to the circuit page and copy my exact board and circuit.
1. Buy a couple of infrared (IR) sensors
- Sparkfun: http://www.sparkfun.com/products/9542
- Get some 30K 50K and 100K resistors for testing the digital input sensitivity..
- Get some 10 , 20, and 50 ohm resistors for powering the IR LED
2. Prototype your parts with an Arduino
- I used a dead bee on a wire
- its an easy circuit
3. Select a Microcontroller... I used the Teensy ++
- same user interface as Arduino..
- has 46 inputs/outputs,
- its cheap, and
- designed locally here in Portland..
4. Design your Printed Circuit Board with EAGLE for free
- i took a 4 hour class at dorkbotpdx.org here in Portland. the software is free.
- have it printed through dorkbot in Portland $45 for 3 boards
5. put everything together
- solder your components on the board
- calibrate your sensors
- fine tune your programming
Rough cost and components for my board ~ $110
- Printed Circuit Board $45
- qty(44) QRE1113 IR Sensors $33
- Teensy ++ $24
- resistors and pins $10
- my time $ouch!
Message me if your interested in me putting together a kit as it would probably be $130 if you want to do the soldering and hot glue gunning yourself!
- micro SD datalogging
- real time clock turns OFF the counter at night for reduced power
- decoupled the LEDs from the microcontroller to reduce average power to 6.6 ma when not in use
- small battery will last for months
- solar cell power ready
- unlimited temperature sensors
- can perform estimates of size of the bee (worker vs drones) and therefore monitor drone/worker activity
- 3D printed turn-styles or gates
- for sale complete without battery $400 or make your own (see below)
Here are the specs for Version 1. This instructable details out Version 1 which is easily upgradable to version 2 though I've not provided complete plans.
- 95% Accuracy
- Runs off USB power
- should be rain resistant with a top cover
- bees adapt to new opening in a few minutes
- real time monitoring on google docs
- USB connection dumps data onto your laptop text file
Here's the plans to build your own. There are general instructions for prototyping or you can go to the circuit page and copy my exact board and circuit.
1. Buy a couple of infrared (IR) sensors
- Sparkfun: http://www.sparkfun.com/products/9542
- Get some 30K 50K and 100K resistors for testing the digital input sensitivity..
- Get some 10 , 20, and 50 ohm resistors for powering the IR LED
2. Prototype your parts with an Arduino
- I used a dead bee on a wire
- its an easy circuit
3. Select a Microcontroller... I used the Teensy ++
- same user interface as Arduino..
- has 46 inputs/outputs,
- its cheap, and
- designed locally here in Portland..
4. Design your Printed Circuit Board with EAGLE for free
- i took a 4 hour class at dorkbotpdx.org here in Portland. the software is free.
- have it printed through dorkbot in Portland $45 for 3 boards
5. put everything together
- solder your components on the board
- calibrate your sensors
- fine tune your programming
Rough cost and components for my board ~ $110
- Printed Circuit Board $45
- qty(44) QRE1113 IR Sensors $33
- Teensy ++ $24
- resistors and pins $10
- my time $ouch!
Message me if your interested in me putting together a kit as it would probably be $130 if you want to do the soldering and hot glue gunning yourself!
Step 2: Circuit
more details to follow but its super simple...
Sparkfun sells the Infrared sensor or IR sensor. It is an LED AND a Sensor! crazy useful!.
When the bee crosses under the LED the light is reflected back to the sensor..(its a photo transistor) and triggers a digital input to the Arduino.. (or teensy in my case).
I lined up two chips right next to each other... as the bee goes through the gate if it hits the inside sensor first... its going out.. if it hits the outside sensor first its coming in. More on the programming...
See the full schematic and GERBER files attached.
- I used 4 LEDs in series with one 10 ohm resistor at the end.. that equals 1.2 volts drop per LED.
- you can check your LED voltage drop with an online web tool like this one
- if you end up building the same set up as me you can get the IR sensors for a little cheaper through Digikey here.
- Pololu also sells the same IR sensors on a board (array) and they have code and examples here.
- per the large schematic below, I used 100k ohm resistors to ground. this increases the sensitivity. If you use a smaller resistor it becomes less sensitive. It is an NPN Phototransistor.
Rough cost and components for my board ~ $110
- Printed Circuit Board $45
- qty(44) QRE1113 IR Sensors $33
- Teensy ++ $24
- qty(11) 10 ohm 0805 resistors
- qty(44) 100k 0805 resistors
- 26 headers and 26 pins for attaching the Teensy to the board $3
- my time $ouch!
Message me if your interested in me putting together a kit as it would probably be $150 if you want to do the soldering and hot glue gunning yourself!
Sparkfun sells the Infrared sensor or IR sensor. It is an LED AND a Sensor! crazy useful!.
When the bee crosses under the LED the light is reflected back to the sensor..(its a photo transistor) and triggers a digital input to the Arduino.. (or teensy in my case).
I lined up two chips right next to each other... as the bee goes through the gate if it hits the inside sensor first... its going out.. if it hits the outside sensor first its coming in. More on the programming...
See the full schematic and GERBER files attached.
- I used 4 LEDs in series with one 10 ohm resistor at the end.. that equals 1.2 volts drop per LED.
- you can check your LED voltage drop with an online web tool like this one
- if you end up building the same set up as me you can get the IR sensors for a little cheaper through Digikey here.
- Pololu also sells the same IR sensors on a board (array) and they have code and examples here.
- per the large schematic below, I used 100k ohm resistors to ground. this increases the sensitivity. If you use a smaller resistor it becomes less sensitive. It is an NPN Phototransistor.
Rough cost and components for my board ~ $110
- Printed Circuit Board $45
- qty(44) QRE1113 IR Sensors $33
- Teensy ++ $24
- qty(11) 10 ohm 0805 resistors
- qty(44) 100k 0805 resistors
- 26 headers and 26 pins for attaching the Teensy to the board $3
- my time $ouch!
Message me if your interested in me putting together a kit as it would probably be $150 if you want to do the soldering and hot glue gunning yourself!
Attachments
Step 3: Programming - Easy
The Teensy is programmed in Arduino... or C++ but I'm a little familiar with Arduino...
The code is attached below.
/*
This is for the first two gateways: A and B.
*/
// this constant won't change:
const int ain = 44; //pin 44 is the first digital input for Gate A
const int aout = 45; // pin 45 is the second digital input for Gate A
const int bin = 42; // same for Gate B
const int bout = 43; // same for Gate B
// Variables will change:
int ins = 0; // counts ins and outs
int outs = 0;
int ai = 0; // Gate A 1st pin status
int lai = 0; // Gate A last status of 1st pin
int ao = 0; // Gate A 2nd pin status
int lao = 0; // Gate A last status of 2nd pin
int bi = 0;
int lbi = 0;
int bo = 0;
int lbo = 0;
int count = 0; // this just tests if there has been a change in our bee count
int lcount = 0;
void setup() { // initialize the button pin as a input:
pinMode(ain, INPUT);
pinMode(aout, INPUT);
pinMode(bin, INPUT);
pinMode(bout, INPUT);
// initialize serial communication:
Serial.begin(38400); //a bit different than the Arduino here.... 38400
}
void loop() {
// read the pushbutton input pin:
ai = digitalRead(ain);
ao = digitalRead(aout);
bi = digitalRead(bin);
bo = digitalRead(bout);
if (lai != ai){ // has the status if the 1st pin changed?
if (ai > ao) { // if yes, is the bee going in or out?
ins++; // if its going in add one bee to ins
}}
if (lao != ao){
if (ao > ai) {
outs++;
}}
if (lbi != bi){
if (bi > bo) {
ins++;
}}
if (lbo != bo){
if (bo > bi) {
outs++;
}}
lai = ai; // updates the last status
lao = ao;
lbi = bi;
lbo = bo;
count = ins + outs;
if (lcount != count){ // if the count has changed we print the new count
Serial.print("number In: ");
Serial.println(ins);
Serial.print("number Out: ");
Serial.println(outs);
lcount = count;
}
}
I added a debeebouce sequence. Here is the latest calibration video from today 06/26/12. Its 91% accurate but there is still a little room to improve:
The code is attached below.
/*
This is for the first two gateways: A and B.
*/
// this constant won't change:
const int ain = 44; //pin 44 is the first digital input for Gate A
const int aout = 45; // pin 45 is the second digital input for Gate A
const int bin = 42; // same for Gate B
const int bout = 43; // same for Gate B
// Variables will change:
int ins = 0; // counts ins and outs
int outs = 0;
int ai = 0; // Gate A 1st pin status
int lai = 0; // Gate A last status of 1st pin
int ao = 0; // Gate A 2nd pin status
int lao = 0; // Gate A last status of 2nd pin
int bi = 0;
int lbi = 0;
int bo = 0;
int lbo = 0;
int count = 0; // this just tests if there has been a change in our bee count
int lcount = 0;
void setup() { // initialize the button pin as a input:
pinMode(ain, INPUT);
pinMode(aout, INPUT);
pinMode(bin, INPUT);
pinMode(bout, INPUT);
// initialize serial communication:
Serial.begin(38400); //a bit different than the Arduino here.... 38400
}
void loop() {
// read the pushbutton input pin:
ai = digitalRead(ain);
ao = digitalRead(aout);
bi = digitalRead(bin);
bo = digitalRead(bout);
if (lai != ai){ // has the status if the 1st pin changed?
if (ai > ao) { // if yes, is the bee going in or out?
ins++; // if its going in add one bee to ins
}}
if (lao != ao){
if (ao > ai) {
outs++;
}}
if (lbi != bi){
if (bi > bo) {
ins++;
}}
if (lbo != bo){
if (bo > bi) {
outs++;
}}
lai = ai; // updates the last status
lao = ao;
lbi = bi;
lbo = bo;
count = ins + outs;
if (lcount != count){ // if the count has changed we print the new count
Serial.print("number In: ");
Serial.println(ins);
Serial.print("number Out: ");
Serial.println(outs);
lcount = count;
}
}
I added a debeebouce sequence. Here is the latest calibration video from today 06/26/12. Its 91% accurate but there is still a little room to improve:
Attachments
Step 4: Data Logging on Google Docs
I used Processing to upload the data real time through a laptop...... Here is the first data I got...
- Live Date from today June 25, 2012
The values are uploaded via the code attached. The general idea is to use a 'formkey' link that is accessed when filling out a Form for Google Docs.
1) log onto google docs
2) create a new FORM with as many inputs as you have data points
3) go to the 'live form' and review the source code... look for the 'formkey' and the input identifiers... here is what I found:
4) its easy to figure out once you get the source code and start cutting and pasting values right into your browser to test your assertions... try its pretty powerful..
In Processing (you can probably post it right from the Arduino but I thought I'd try in Processing ..)
String [] docs = new String[8]; //this 'string' just puts all the pieces of the URL together 0 through 7 or 8 total....
docs[0] = "https://docs.google.com/spreadsheet/formResponse?formkey=dHNHNWtZQ3lJSzFCZ1kyX0VVVmU0LUE6MQ&ifq&entry.0.single="; //this is the formkey from the FORM source code
docs[1] = pairs[1]; //this is my first data point # of bees IN.
docs[2] = "&entry.1.single="; //this tells google doc my first my 2nd variable comes next... search the source code to figure out but it will look similar...
docs[3] = pairs[3]; //this is the second variable # of bees OUT.
docs[4] = "&entry.2.single="; //this tells google doc my 3rd variable comes next..
docs[5] = Delta_in; // # of bees in minus last number of bees in
docs[6] = "&entry.4.single=";
docs[7] = Delta_out;
String docs2 = join(docs, "");
loadStrings(docs2); //once you put all these bits together it posts your spreadsheet!!... test your own bits in your browser... I have it posting every 5-10 minutes...
I attached the processing code... I still need to change the INT variables to FLOAT because after a few hours the values exceed 32,000 bees!!! woops..
- Live Date from today June 25, 2012
The values are uploaded via the code attached. The general idea is to use a 'formkey' link that is accessed when filling out a Form for Google Docs.
1) log onto google docs
2) create a new FORM with as many inputs as you have data points
3) go to the 'live form' and review the source code... look for the 'formkey' and the input identifiers... here is what I found:
4) its easy to figure out once you get the source code and start cutting and pasting values right into your browser to test your assertions... try its pretty powerful..
In Processing (you can probably post it right from the Arduino but I thought I'd try in Processing ..)
String [] docs = new String[8]; //this 'string' just puts all the pieces of the URL together 0 through 7 or 8 total....
docs[0] = "https://docs.google.com/spreadsheet/formResponse?formkey=dHNHNWtZQ3lJSzFCZ1kyX0VVVmU0LUE6MQ&ifq&entry.0.single="; //this is the formkey from the FORM source code
docs[1] = pairs[1]; //this is my first data point # of bees IN.
docs[2] = "&entry.1.single="; //this tells google doc my first my 2nd variable comes next... search the source code to figure out but it will look similar...
docs[3] = pairs[3]; //this is the second variable # of bees OUT.
docs[4] = "&entry.2.single="; //this tells google doc my 3rd variable comes next..
docs[5] = Delta_in; // # of bees in minus last number of bees in
docs[6] = "&entry.4.single=";
docs[7] = Delta_out;
String docs2 = join(docs, "");
loadStrings(docs2); //once you put all these bits together it posts your spreadsheet!!... test your own bits in your browser... I have it posting every 5-10 minutes...
I attached the processing code... I still need to change the INT variables to FLOAT because after a few hours the values exceed 32,000 bees!!! woops..