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.
beeBacker2.stl18 KBStep 1: Manifesto
- 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
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!
gerber files.zip73 KBStep 3: Programming - easy
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:
Step 4: Data Logging on Google Docs
- 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..
Serial_int2.pde1 KB











































Visit Our Store »
Go Pro Today »




Is the worker vs. drone recognition only done by the speed switching the two IR sensor? That means that the bees past the two gates by a average constant speed. Did you see this in the previous data? Interesting!
May you post the modified code for version 2 with bee type recognition. Is there also a 3D printing file for the gates downloadable?
I can send you the 3d gate file. send me an email that I messaged you. -tom
There are 2 problems with the idea of powering it from a usb cable.
1. USB cables are usually 6' long, which means your laptop for collecting the data is only 6 feet away from the hive. If you have 110v ac nearby, you can use a powered USB hub and get 12' away from the hive to collect data and for power, but that is still not very far. I've seen a lot of hives in the corners of fields that were hundreds of feet from a power source.
We did some calculations and with 22 gates (44 sensors) an 8-pack of rechargeable "c" cells will last less than 20 hours, which is not nearly enough for observing bees on a daily basis (unless you change the batteries 8 times a week).
USB works for a few sensors, but not 44 of them.
If anybody wants to know, my son (who has several degrees in engineering and related fields) can post the math involved.
putting 4 sensors with one resistor leaves you with only .2 volts of headroom above what the diodes draw at nominal values. There is a chart in the data sheet, figure 8, that shows the forward voltage vs Ambient temperature. Taking the temperature into consideration, say from 0 degrees to 100 degrees F. times 4 (for 4 sensors in series with 1 resistor) you can easily need more voltage than a USB hub can supply.
If you figure adding other things to be powered with this counter, such as temperature/humidity sensors, a readout screen, or anything else, you could be above the power available on even a USB powered hub.
We ended up with a 9v wall wart transformer capable of 1 amp. and calculated that that will work at temperatures from 0 to 100F with power to spare for an lcd screen, etc.
With the 9v wall wart, you get less than 3ma variation between 0-100F. With a 5v USB, allowing for temperature variation you can have about 100 ma variation.
But that links us to an extension cord and 110vac all the time.That may work for some Bee Hives, but probably not a lot of them.
We looked at a car battery, and it worked out to a week of life before needing recharged. Ant then you have to lug a car battery into the field with you to change it out once a week.
Also, when figuring the number of sensors needed, you would have to consider that bee hives comein 2 common widths, a ten-frame hive and an 8-frame hive. The width will be 2.5-3" different, so the maximum number of "gates" will be different.
We have 8-frame hives and using 3/8" width slots and 5/16" spacers between slots, we can get about 19 gates. Certainly enough for the bees, but it changes the power calculations as well as the size of the circuit board.
I was also thinking about the speed necessary to read 44 sensors and update the counts, but my son suggested if we use the atmel commands, instead of the arduino built in port reading, we can read 8 ports at a time, as that is the way the chip reads them--as a byte.
I have an idea for a case that I can make to take care of waterproofing everything, so that shouldn't be a problem.
We still need to find a way to get the data without going up to the hive and plugging something in or removing an sd card.
Has anybody else built one of these, even as a prototype?
still working on it some more.
I got the SD card modules off ebay for $2.95 each, and small sd cards are about $5 now. There is a library already for writing to an SD card with the Arduino, as well as examble code in the back of the book I bought: "Arduino Cookbook".
There are things to consider in code, what happens when it tries to write to the sd card you just pulled to exchange it, or what you do if you power down to change the sd card, etc. as well as how to make the sd card removable but watertight for during storms.
We did battery calculations too, and came up with shorter times than you did by a good bit. I don't know who is closer to actual battery life, lots of variables, but it seemed from the data sheets that your estimated battery life is close to maximum.
It also seems from the data sheet that 1 millimeter is a good sensitive range from the sensor and it looks like the bees might have more than that amount in height in the prototype, but it could be just optical illusion.
What dimensions did you use for the gates, and what width for the blocks? We figured .312 for gates and .375 for blocks for calculation purposes. And our hive is an 8-frame instead of a 10-frame, so that affects our total width. We went with 8 wide so the full supers don't approach 100 lbs in weight when full for harvesting.
How many sensors were in the unit that gave you 75ma draw?
Thanks for the link to the hobo-datalogger, I'll check it out. What University were you supplying? Do you know what they were using them to research?
If I wanted to send you a file, where would I send it?
SKM
smitchel at bnin dot net
I was thinking the better option for the backyard bee keeper.. would be to incorporate a swarm alert email... for this to work I thought it would be nice to use a WIFI card... maybe something like this: https://www.sparkfun.com/products/11049
The hardware is easy but the software takes a bit more thinking... I'm just not too interested in designing a complete product for sale. Sounds like a lot of work. I'd like to partner with someone who might be interested in this route.
The power measurements were done with all 44 sensors running. it measured higher amperage when the USB communication was running.
Has anyone figured out a way to track where your bees are foraging?
I had a go at doing this but not so good with hardware, so now working on a version tracking bees in the vicinity of the hive with a video camera - first results here: http://www.youtube.com/watch?v=o3a1_6tIAvA.
I might just build this now....
Cheers. Barry.
I was wondering if the video method you use has a way of checking that it is counting actual bees, or is it counting flying insects?
Great video and congratulations on getting the video counting/tracking going.
It looks like you know some about web cams, I have wanted to put one inside the hive, but the problem is the focus. It would have to focus a couple of inches in from of the lens. Do you know any way to get an ordinary webcam to focus that close?
Don't know much about webcams but I'd think the problem you'd have would be light levels. To focus maybe try getting some old reading glasses and use one of those lenses in front.
You might want to look at these sensors http://www.omega.co.uk/ppt/pptsc.asp?ref=OM-EL-USB-1&Nav=dase01 just drop it in the hive and leave it! I believe the internal hive temperature is supposed to be kept at about 33 degrees centigrade, so might be a boring trace!
Cheers. Barry.
I wrote it from scratch in c & perl using a c jpeg library to decode each frame. Haven't yet counted them, as I'm currently debugging a bit to follow the bee traces when they overlap.
Keen to build one of your counters. Cheers. Barry.
The queen's size is so different from every other bee in the hive that they sell a separator, a plate with a grid of holes, which bees fit through but queens cannot, that you put between the 2-3 supers that the colony needs to have full of honey to overwinter and the upper supers, where the honey will be stored (and that you harvest), so that the queen will not be laying brood in the area that you intend to harvest honey. I mention that to point out that how predictable the size of the queen is, and so much different than the resat of the bees. They are about double the size of regular bees.
So unless you make the gates big enough that a couple of bees can fit through (messing up your count), the queen won't fit anyway!
I'm going to make a couple of these, but I want to use a stand alone Arduino board, and also hook up temperature, humidity, light level, and maybe any other sensors that will tell me about conditions in the hive. Audio would be great if someone could show me how, as the pitch of the "humming" inside a hive tells what they are doing, i.e. they make a certain sound sound a week or two before swarming. If you know, you can act to prevent swarming and add a super. This was documented in a patent application as far back as the early 1950's.
An idea for an output more useful than an external display is to make it accessible by a cellphone.
This would be more useful as you might want to observe bee activity by the hour of the day, comparing to sunlight/cloud cover patterns of that day, so you might want a simple web interface to send the data to a nearby wifi network, like your house, to collect the data. Or use an SD card (on ebay for $5 or less) and write hourly data to that.
With the wifi boards available for the arduino, you could give your counter an IP address and check in on traffic, etc from an internet-enabled phone like the Nokia N900 without ever having to approach the hive.
That will take more power, so maybe add some more (AA or 9v)batteries to keep the runtime up into weeks instead of days.
I would like to collaborate with others who are building these now. I have some ideas for a case to keep things watertight, yet well enough attached that storms or skunks won't dislodge it.
skm
smitchel@bnin.net
Wondering how you dealt with bees hovering in the entry, or is that in that 5% error margin?
got a little suggestion here, hope you don't mind... :P
the miss-count can be a results of a bee triggering one sensor then changing it's mind and backs-up. can bees walk backwards? :)
if a bee can trigger both sensor simultaneously, you might like to wait for this state, before increasing the ins/outs. something like:
if(lai=1 && lao=1)
{
if(ai=0 && ao=1)
ins++;
if(ai=1 && ao=0)
outs++;
}
can't test it but in theory it may offer a greater accuracy.
If you could weigh the hive at the same time you could graph almost every aspect of the bees work and even predict production and determine health and activity of the hive over a year. This could be seriously scientific.
If you put on a alphanumeric LCD display and make it completely stand alone. Could always power it via solar and this would be the greenest tech going!
I like the solar idea for sure...