Hardware Reference
In-Depth Information
unbroken and run the program. Use a Ping-Pong ball or other object to break and unbreak
the light beams to check that your program prints the correct corresponding messages.
Press Ctrl + C to exit the program and check the events have been logged to the birdlog.
txt ile. You can quickly look at the contents of a ile in Linux by using the more command.
From the command line, type
more birdlog.txt
###starting up at:13 Jun 2013 16:07:29.425
0,1,13 Jun 2013 16:07:30.496
1,1,13 Jun 2013 16:07:30.572
0,0,13 Jun 2013 16:07:30.792
1,0,13 Jun 2013 16:07:30.961
Check that your ile looks similar to entries shown here. If so, it is time to write another pro-
gram that will analyse the log ile to translate the raw sensor data to bird actions.
You can download a sample log ile from www.wiley.com/g o/raspberrypiprojects .
Processing the Data
After you have the data of when the sensors break and unbreak it is time to write a program
to interpret this to know whether a bird is entering or leaving the nest box. To do so, you will
write a program that reads in the log ile and processes it with a state machine. You will also
see that it is necessary to ilter out noise.
hink about a bird entering the box, and how the sensors will record it. Here is the list of events:
1. he outer beam breaks.
2. he inner beam breaks.
3. he outer beam clears.
4. he inner beam clears.
When a bird leaves the nest box, the order will be as follows:
1. he inner beam breaks.
2. he outer beam breaks.
Search WWH ::




Custom Search