Before attaching sensors to the trap itself, it's a good idea to make sure everything works and logs data correctly. We'll start with a stock Raspbian install, and rely on a handful of software components:
- The
occi
configuration helper from Adafruit's Raspberry-Pi-Installer-Scripts. - tmux and mosh
- The Adafruit IO Python Library.
- Adafruit-MouseLogger's mouse.py - a simple wrapper script to read the Pi's GPIO pins and push data to io.adafruit.com.
Log in to your Pi by way of SSH or serial cable, or get a terminal. As an optional first step, run the following command to install tmux
and mosh
:
sudo apt-get install tmux mosh
tmux
is a terminal multiplexer I recommend you use to edit code and run long-running scripts inside of. It's a completely optional step, but if you're interested, you can read the Use a Terminal Multiplexer section in our shell magic guide.
Next, I used occi, our configuration helper provided with Occidentalis, to configure the Pi's hostname and wireless connection. Begin by cloning the Raspberry-Pi-Installer-Scripts Git repository and running occi
's built-in installer function:
git clone https://github.com/adafruit/Raspberry-Pi-Installer-Scripts.git cd Raspberry-Pi-Installer-Scripts sudo ./occi --install
I edited /boot/occidentalis.txt
to look like the following:
hostname=mousetrap wifi_ssid=[my wireless router's network name here] wifi_password=[my wireless password here]
This way, with a wifi dongle plugged in, my Pi will always connect to the wireless network at boot, and I can log in via SSH as [email protected] instead of worrying what IP address it's been assigned. This is really handy when the Pi is sitting in a corner next to a mousetrap instead of on my desk near a keyboard and monitor.
mouse.py will rely on Adafruit's Python client for IO, which provides a clean, simple interface for talking to the service. Clone and install this like so:
git clone https://github.com/adafruit/io-client-python.git cd io-client-python sudo python setup.py install
Finally, clone the Adafruit-MouseLogger repository from GitHub:
cd ~ git clone https://github.com/adafruit/Adafruit-MouseLogger.git cd Adafruit-MouseLogger
Once you have mouse.py, you should be able to test your sensors. Just run like so:
sudo ./mouse.py
Fiddle with the sensors and see if you get readings - this might take a few seconds, but you should start seeing output like so:
Text editor powered by tinymce.