Hardware Reference
In-Depth Information
Recording Activity to a File
Now that you have your Raspberry Pi able to detect when the light beams are broken and
unbroken, it is time to write a program to record this information. Ultimately you are inter-
ested in the direction that the birds are traveling in, which is deduced from the order the
beams are broken and unbroken.
Real Time or Post-Process?
he Raspberry Pi is more than capable of running a program that can process the beam break
information to determine bird direction in real time - in other words, as it happens. However,
for this application it is better to record the raw sensor readings and process the data later.
his approach means that information is not thrown away.
If you processed the beam break information and just recorded if a bird left or entered the
nest box, you would limit your options for future analysis. For example, what if you later
decided that you were interested in the speed the bird entered and left the nest? If you store
the time of every instance of a beam's breaking and unbreaking, you can process it later to
determine direction, and you can calculate the speed. If you stored only direction informa-
tion, this information about speed could not be calculated later.
Furthermore, as you will see later in the “Dealing with Sensor Noise” section, you will need to
ilter out noise from the sensors, and at a later stage you might develop a more sophisticated
ilter to process the raw data.
If you wrote a program to process the beam break data in real time and there was an error in
it, you would have lost valuable information about your birds. Before deciding to store the
unprocessed data, it's worth doing a quick calculation to predict how much data the bird-
logging program would produce. If a bird visited every minute, for 18 hours a day there
would be 1080 (60*18) events per day. Assuming the nesting period is at most 60 days, this
is 64800 (60*1080) events. If each visit results in 10 sensor events (due to noise) and each
takes 30 bytes to store, the total storage required is 19440000 (64800*30*10) bytes, or about
20 megabytes. Because there is plenty of low-cost storage available with a Raspberry Pi on a
cheap SD card, it is better to write a very simple program to store the raw beam break data
that can be analysed oline later.
Search WWH ::




Custom Search