First you would like to check, if the LEDs and pushbuttons are working and you would also like to find the right resistor value for a good gain. Remember, that the LEDs and pushbuttons work while the circuit is USB-powered, but for the receiver you need to supply a higher voltage.
testing the board
This simple software helps you testing the board and I also introduce my favourite method of detecting incoming ultrasonic signals – an interrupt service routine increments a counter, so that the software does not have to poll the input actively. Normally I try to avoid interrupts, but in this case I think it makes programming easier and the program-sketches are also easier to read: batshield_demo.ino
measuring „time between calls“
The ultrasonic frequency band is not used by bats exclusively – insects also use high frequencies and of course there is also noise (wind, rain, man-made-noise). So the first approach to filter out bats is measuring the TBC („time between call“) value. Of course these values are depending on your local bat species. In my area the smaller bats, which can be picked up by the 40 kHz transducer of the Ardubat, have TBCs in the range of 70-80ms. So I wrote a software which displays different TBCs in this way:
- green LED: below 50ms
- yellow LED: 50ms-90ms
- red LED: above 90ms
This would filter out crickets, which I measured at 40ms and below. Most random noise is above 100ms, but this method cannot be 100% perfect, since reflected or missing calls will confuse the algorithm. Keep this in mind, when testing the batshield_tbc.ino sketch. My first video shows a bat being detected and the following video shows insect noise (TBC too low for a bat):
TBC sketch analyzing insect noise
Sooner or later you would like to log bat activity with the Ardubat. You could send data via USB cable to an attached PC, f.e. to the serial terminal window of the Arduino IDE, but this means, that a PC must be in range of a few meters (USB is very limited) and running all the time. You could also use the EEPROM.write() function and store data on the Arduino board, but the space is very limited (512 bytes) and you still have no date/time values. So I think everything leads to using the data logger shield from Adafruit, which provides a realtime-clock and nearly unlimited storage on SD-card.
Here is my data-logging sketch batshield_log.ino – it writes a log to SD-card and also includes some code for setting the RTC via a file called „date.txt“, including date and time.
installing the RTC lib
When using the adafruit datalogging shield with RTC, you need to install the RTClib into your Arduino IDE. There is good description from adafruit. Actually it is rather simple – you just have to download the zipped library from github.com, unpack it to the libraries-folder of your IDE and rename it „rtclib“. Restart the IDE and the sample programs should compile without errors.
After running into problems with the String class I found this interesting article about dealing with the limited RAM space (reserving string space, moving strings into program memory, …): Arduino Memories
I also found a function which tells you the amount of used/available memory space: AvailableMemory
Finally you probably would like to reduce the power consumption of your Arduino project. For that topic I found this very interesting posting: ArduinoPower
We are working on that topic – stay tuned…