Showing posts with label xbee. Show all posts
Showing posts with label xbee. Show all posts

Wednesday, March 27, 2013

Raspberry Pi Mouser

I've taken a bit of a hiatus from the mousetrap project I began a few months ago. There were a couple of reasons for it, one of which was my disappointment with the range of the XBee connection, the other was short battery life of the traps. I believe I have now solved both of those problems.

Raspberry Pi
I've had issues with other 2.4 GHz transceivers in my home. Perhaps it is a noisy environment, or maybe it is walls lined with heavy metals. For whatever reason, my receiver would report very low RSSI readings from my mousetraps' transmitters when the transmitters were in the attic and garage and the receiver was in the office. In fact, some reports never made it to the receiver causing the logic of the software to timeout and set the mousetrap as offline.

I decided I needed to move the receiver to a more central location in my home (I also had to do the same thing with my Wifi AP). However I didn't want to drag a laptop or PC with it, so I opted to use a Raspberry Pi (raspi) board. The end result looks like this:
RaspberryPi in a case with XBee

The raspi has a nasty USB issue that gives me grief every time I attempt to use the USB ports for anything more than keyboards or mice. In fact, my adafruit usb to XBee adapter did not work when plugged into the raspi. I decided that if I was going to use the raspi I would need to use the built-in serial headers and enclose it inside a nice package. The plan was to place this somewhere central and I didn't want a bag of parts to be just hanging out.

My raspi Bill of Materials (BoM):
  1. RaspberryPi Model B 512MB RAM
  2. Slice Of Pi Breakout Board
  3. pIO - microSD card adapter
  4. Stealth Black Case from ModMyPi
These items are all available at http://www.modmypi.com (no disclosure needed, just a happy customer) as well as other places around the web. The nice thing about the breakout board is that it comes with the PCB traces and headers required for the raspi to communicate with the XBee. The only thing I needed to do was solder the main header which plugs into the raspi and the smaller headers used for the XBee.
Components of the Raspberry Pi Mousetrap
Take a close look at the next image. Notice how the breakout board sits at an angle:
Raspberry Pi with Breakout Board

Here is the point that I want to make: The case from ModMyPi is very well done and completes the setup very nicely. However with the extra standoffs from the XBee module it will not snap together completely. I debated for about 30 minutes if I was willing to solder the XBee directly to the breakout board, but ultimately decided against it because this is still a "project" and I often hook the XBees to X-CTU for configuration. If I had soldered the XBee down, I wouldn't be able to connect it to the special breakout board which the XBees plug in to for programming.

To get everything to fit, I first ensured that as much of the breakout board as possible was as low as possible, which is why I soldered the header at an angle. Next, the ABS plastic used in the case was pretty thick and I was able to grind out enough material on the underside of top so that the XBee board no longer kept the case from snapping together. Here is picture of the underside of the top of the case:
The arrow shows the hole that was drilled to allow the XBee antenna to protrude through the top of the case. The ground out area is where I used a Dremel tool to carve out enough material for the case to snap together. It isn't very pretty on the underside, but you'd never know it looking from the top! It would be nice if ModMyPi offered an extended case where the top was taller, then I would not have had this issue.

Here are some pictures of the final product in operation (notice the pIO microSD adapter shown in the first picture):


Battery Life
It turns out that XBees use a bit of power! Even using them to wake at intervals uses more power than I expected. I've revamped the settings to poll the Victor traps less frequently, which gives much longer battery life (still testing this). In the next entry, I will discuss and post the final python code, XBee settings, and raspi options needed to be able to use the built in serial headers in user code.

Stay Tuned!

Sunday, December 30, 2012

X-CTU on Ubuntu

Digi's X-CTU is a Windows only application. However, it can be made to run quite well under Linux. This is how I set it up under Ubuntu 12.10. (I used Google to find the answers to many of my questions. Thanks Lazyweb.)

Linux requires users to have permissions to access hardware. In this case the user needs to be a member of the dialout group. Do the following as the user you intend to run X-CTU under:
    sudo adduser ${USER} dialout
Note: You will have to logout and login for the changes to be fully realized.

First get wine:
   sudo apt-get install wine

Then symlink the Linux serial devices to:
   ln -s /dev/ttyUSB0 ~/.wine/dosdevices/com5
   ln -s /dev/ttyUSB1 ~/.wine/dosdevices/COM5
   ln -s /dev/ttyUSB0 ~/.wine/dosdevices/com6
   ln -s /dev/ttyUSB1 ~/.wine/dosdevices/COM6
Note: I used both uppercase and lowercase "COM" because it seemed that the lowercase worked when I was troubleshooting.

Go to: http://www.digi.com/support/productdetail?pid=3661 and click on "General Diagnostics, Utilities and MIBs" which will reveal the download for X-CTU. Download X-CTU (I used XCTU ver. 5.2.7.5):
    http://ftp1.digi.com/support/utilities/40003002_B.exe

Make the file executable:
    chmod 755 40003002_B.exe

Open X-CTU installer with wine program loader by right-clicking on the file in Nautilus and choosing: Open with Wine program loader. Install application.

Selecting Serial Port

Every time you run X-CTU you will need to add the user com port. I used '5' below for COM5, which represented /dev/ttyUSB0 on my machine:


You must select the COM port before the Test / Query operation will work

Updating firmware

One of the things that doesn't work in X-CTU under Wine is the auto firmware download from the web. However, when you download the files manually and extract them to the correct location, you can update the XBee just like under Windows.

Navigate to: http://www.digi.com/support/productdetail?pid=3661 and download the latest firmware. I used "XBee / XBee-PRO ZB firmware ver. 2xA7" which was the 82001817_G.zip file (Dec 2012). Then copy to the update directory:
    cp ~/.wine/drive_c/Program\ Files\ \(x86\)/Digi/XCTU/update/

Now from within X-CTU, add the updates using the Modem Configuration tab and clicking on "Download new versions..." button. Then click on the "File..." button and choose the zip file under the update directory. Restart X-CTU and the new firmware should be available.

Updating XBee Firmware

To update the XBee select the correct serial port and click on the Modem Configuration tab, then check the "Always update firmware" check box. Next select the correct Modem, Function Set, and Version (It appears that the list of versions are ordered in reverse, whereas the newest firmware is listed first). Once selected, click on the "Write" button. See screenshot below: