Monday, 9 June 2014

Starting with the LightBlue Bean

LightBlue Beans by PunchThrough

I have just received my LightBlue Beans. I ordered them before they were made, rather like Kickstarter (they used the dreadful word preorder). These boards are pretty neat, they have Bluetooth LE, motion sensors, temperature sensors and they are Arduino compatible with a few Arduino pins exposed and a small prototyping board to add extra functionality.

One nice thing about them is that they can be programmed wirelessly over BlueTooth, a great boon if you have one in your ceiling monitoring the mouse population up there!

Here they are in their boxes, along with a couple of developer's kits, resistors, leds, spare batteries etc.

My new goodies
Clearly labeled holes
It has a battery!

Installation on a Mac

Uh, oh! I do hope the devices themselves are better than the installation problems I've had. I have followed their instructions very carefully. Download Arduino 1.0.5 (not 1.5.x), move it into Applications. Download and install the Teensyduino software. Ok, that bit went well. Now all I have to do is download the LightBlue software installation package and I'm good to go. Great! No errors! Let's see, what's next?

"Choose the LightBlue Bean board" erm. What LightBlue Bean board? Nothing there! I deleted my Arduino and reinstalled many times, no go, the LightBlue Bean installation package simply did nothing, I just cannot see LightBlue Bean under the Arduino Board menu at all.

I checked out their web site and could see that quite a few people are complaining about similar problems. Someone from PunchThrough uploaded a zip file that was supposed help but that didn't work either, it was old software and was missing drivers.

So, I had a look inside the installation package. The first thing I saw, and didn't like, was that it expects to install software in /Application/ (it still didn't work when I put my Arduino IDE there). It was also looking for specific versions of Teensyduino so maybe I didn't have the correct version but I had the only one I could download. Anyway, I didn't follow that through, I could see what had to be done (instructions lower down in this post) so I extracted the files from the package and installed them by hand.

Once I restarted the Arduino IDE everything finally worked.

Battery Woes

Well, almost everything!  I could only see a few of my eight boards and even then it was hard to connect to them.  I checked the battery on one and it was 2.7V, I checked a few others, well under 3V. Hmm, these batteries should be 3V, time to open the new ones that came with the boards and pop them in. This is a little worrying, these are new boards with (I imagine) new batteries in them but now they are run down; this does not bode well for future projects.

At least they are fairly easy to check using the BAT and GND holes

Feeding the Beans

Now the batteries are replaced I can see the beans. I have to connect to each one with a right mouse click but how do I know which is which?

Confusing display, it would be nice if they had the MAC address
All I have is signal strength and once they are connected, they are all called Bean.

So, which is which?
Once connected, the right-click gives me a few other options including Blink LED.

I tried that with one and a box lit up momentarily, it made me smile, nice design.

Here it is!
Ok, what else? Firmware upgrade. That is advised on the site so off we go, with new batteries I feel confident in upgrading the firmware. It takes a while, it is registering increments of 0.1%, I hate doing this, I always feel I am going to brick something.

Fingers Crossed!

Ok, firmware upgrade complete, time to get to work with them tomorrow!

Installing the LightBlue files by hand (Mac OS X only)

These instructions require you to use the terminal. If you haven't used it before take extra care typing in the commands, it is easy to make mistakes and you might move files to the wrong locations.

I am going to present the commands as a complete block that can be copied and pasted. You can do them one command at a time if you feel uncomfortable or want to see what is happening with each step. Notice that the last if statement covers several lines. Personally I prefer putting the commands in a file and executing them from there. However, I have tried copying and pasting them directly into a terminal and they worked fine.

Assuming that you have downloaded the installation package into Downloads and it is called LightBlueBean-MacLoader-1.0.0.pkg and your Arduino IDE is called Arduino in /Applications, you can finish your setup with the files using the following commands (adjust the first few lines as necessary, the .app after the Arduino name is hidden in the finder).

# Assume that the pkg file is in Downloads
cd ~/Downloads

# No need to change the following lines
echo "Checking directories and files"
if [ ! -e "$IDE" ]; then echo "$IDE not found"; exit 1; fi
if [ ! -e "$PKG" ]; then echo "$PKG not found"; exit 1; fi

# Open the package
echo "Unpacking the package"
pkgutil --expand "$PKG" "$TMP"

# Extract all the files
echo "Extracting files"
cd "$TMP/Arduino.pkg"
gunzip < Payload | cpio -i

# Now copy the files into place
echo "Copying files"
cd "./Applications/"
tar cf - Java | (cd "$IDE/Contents/Resources" && tar xf -)

echo "Checking to see if the library was installed: "
LIB="/usr/local/lib/libBean OSX Library.a"
if [ -e "$LIB" ]; then 
    echo "yes, library ok"
    echo "$LIB not found"
    cp "$TMP/Arduino.pkg/usr/local/lib/libBean OSX Library.a" /tmp

# Tidy up
rm -r "$TMP"

If you get a message saying /usr/local/lib/libBean OSX Library.a not found then you will need to install this by hand because it requires administrator privileges. The following command will copy it over for you and it will ask for your password in order to be able to do it (note that this command is all on one line):

sudo cp "/tmp/libBean OSX Library.a" /usr/local/lib/.

Ok, now restart the Arduino IDE and you should see the correct board type and the LightBlue-Bean examples in the examples directory.

Saturday, 7 June 2014

RF24 with Energia and MSP430

Energia pinout on TI Launchpad
The MSP430 is a considerably easier target for RF24 than the ATtiny because it actually has its own SPI interface, see above.
// Set up nRF24L01 radio on SPI bus plus pins 8 & 9
RF24 radio(P2_1,P2_0);

// sets the role of this unit in hardware.  Connect to GND to be the 'pong' receiver
// Leave open to be the 'ping' transmitter
const int role_pin = P2_2;

Making the changes above to the pingpair sketch, allows a TI Launchpad to play an equal role in this proud application via Energia.

It's still early days for this project, this is really just a proof-of-concept. Things to be done include: porting RF24Network and reducing the library footprint, the pingpair sketch comes in at just over 8000 bytes (I think that unwanted parts of the stdio library are being included). Stay tuned!