Tuesday, February 26, 2013

It Worked For Me - Raspberry Pi

Pi Shell - Clear Raspberry Pi Case

After waiting all last summer to get my hands on a Raspberry Pi I finally was able to order one and get it shipped to me from Adafruit Industries last September.  When it arrived I was interested to see what it would take to get it up and running and found that it was very easy.  The biggest challenge was to determine what associated parts to buy to have a useable configuration.

When I ordered the pi I hadn’t looked into what items I would need to make it a running system.  I figured that I could pull what was needed from spares I had on hand.  For my initial test configuration I used the HDMI connection on one of my existing monitors, a usb keyboard and mouse I had sitting around, a power supply from my cell phone, and a 4GB SD card.

After some initial successful testing I decided to upgrade to an 8GB SD card and to add wifi so that I didn’t have to tethered to my ethernet switch. To this I added an existing externally powered USB hub that I had so that I could have the wifi dongle, keyboard and mouse all connected at the same time.  I also power the pi off the hub.

I decided that while I liked the barebones look of the Raspberry Pi that having a case would be a good idea to protect it.  After looking at some options I decided on the Pi Tin which I ordered from Sparkfun.

By December I had decided on a project for the pi which required sensor data collected using an Arduino and displayed using openFrameworks.  To get the data from the Arduino to the Pi I used a Sparkfun Bluetooth Mate Silver and an bluetooth adapter.

In January I was far enough along on my project that I decided to purchase a second Raspberry Pi for some testing.  For this pi I got the pi and the same case from Adafruit Industries and added a 7 port externally powered hub, a wifi dongle and another IOGear bluetooth adapter all purchased from Micro Center.

On the hardware side both Raspberry Pi's and the components I have all have been working very well together. I would suggest using the Tenda wifi dongle as it has been working well and costs much less than the Trendnet dongle.

From a software perspective I am running Raspberrian Linux and openFrameworks.  More on the software in a future update.

Rapsberry Pi #1 Configuration

Raspberry Pi #2 Configuration

The above links were good as of the original posting date.  I apologize if they don’t work at some point in the future.

Friday, February 8, 2013

It Worked For Me - Loading Arduino Sketches Using Bluetooth

For a project I am working on I wanted to be able to load Arduino sketches using Bluetooth.  A number of people have attempted to do this and many have been successful and some have not.  Here is how I did it.

My goal was to be able to load sketches from the Arduino IDE using a Bluetooth Mare Silver connected to an Arduino using a standard FTDI cable pin out with reset supported.

Here is the finished product:


Using Google I came up with a good bit of reference material.  Below are the links that I found especially useful:

Ryan Lorite’s arduino remote programming with the bluetooth mate (RN-42)

Ersin Ried’s post in the Arduino Forums Road to solve the delay on the Arduino IDE

Roving Networks’ Data Sheet for the RN-42

The Electronics Club’s A transistor inverter (NOT gate) (at the bottom of the page) circuit

Step 1 – Modifications to the Bluetooth Mate Silver

Reading the data sheet for the RN-42 we find that DTR is on pin 33.  Pin 33 is located on the side opposite from the onboard antenna.  Hold your board so that the onboard antenna on the RN-42 is to the left.  In this orientation pin 33 will be on the right side of the RN-42 and four pins up from the bottom.  It is the one that the left side of the white wire is connected to in the picture below.

Once we have located the DTR pin the next step is to connect it to the RTS position as defined by the FTDI pin out which will result in it being connected to the green wire.  In my case I disconnected the header pin from RTS on the board and then ran a wire across from DTR to that position on the header.

In the upper right corner of the picture below you can see the open hole where the header is normally connected to RTS and the white wire connected to that header position.


Step 2 – Supporting connections using the FTDI pin out

You now have DTR on the bluetooth device connected to the pin to support resetting the Arduino.  Unfortunately, with the RN-42 the DTR pin is active high and to reset the Arduino it needs to be active low.  However, this can be taken care of with a simple transistor inverter circuit using an NPN transistor and two resistors.  I used a NPN2222 transistor, male header pins and a female header socket.

The key to assembling the circuit is to bend pins in position 6 up so that they do not touch when you solder the other 5 pins together.  Once this is done

  1. Solder the emitter on the transistor to ground (pin / position 1 on the connectors).
  2. Solder the collector through a 1K resistor to VCC (pin / position 3 on the connectors).
  3. Solder the base through a 10K resistor to where you terminated DTR from the RN-42.  If you followed my example above this will be where RTS normally is.  This would be pin / position 6 on the connector to the bluetooth board.
  4. Solder the final connection from the collector before the resistor and connect it to the pin / position 6 on the side going to your Arduino.


Step 3 – Change to the Arduino IDE so it will play well with Bluetooth on Windows

You now have a hardware compatible replacement for the FTDI cable you normally use to download sketches to the Arduino.  The final thing that you need to do is to make a change to the Arduino IDE to change the way it scans for COM ports. 

Ersin Ried’s has done a great deal of work in figuring out the cause of the problem and how to get around it.  His work is documented in the following post iin the Arduino Forums: Road to solve the delay on the Arduino IDE.  Basically what needs to be done is you need to replace the existing rxtxSerial.dll module with a modified one.  The modified version can be downloaded from his website at: http://servicios.ried.cl/arduino/temp/rxtxSerial-2.2_fixed_2009-03-17.rar.

The copy of rxtxSerial.dll in the archive needs to replace the copy that is located in the directory where the Arduino IDE is installed.  I would suggest renaming the copy that is there before you replace it so you can easily go back to it.

If you start the Arduino IDE on Windows with bluetooth it will be very slow to come up and anytime you try and access the tools menu.  Once you have the updated copy installed this should go away.

Step 4 – Configuring the Bluetooth Mate Silver so that the your PC can connect to it and download sketches.

There are two things that need to be configured on the Bluetooth Mate Silver.  The first thing is to set the speed to 57600 baud and the second is to change the profile so that modem signals are supported.  This enables the PC running the IDE to toggle DTR to reset the Arduino so the bootloader will accept the sketch.  The speed is set to 57600 as the when the IDE runs avrdude it sets the speed for avrdude at 57600.

To do this you will need to connect to the Bluetooth Mate Silver with a terminal emulator program, enter command mode via the three dollar sign command within 60 seconds of power on, enter two commands to update the configuration parameters and then exit command mode.

  • Set the RN-42 to DUN-DCE mode enter: S~,1
  • To set speed rate of the RN-42 to 57600 enter: SU,57.6

Below is how this looks using ReadTerm:


On thing to note is that the speed for the Bluetooth Mate Silver is set to 115200 out of the box.  So if you have not changed it you will need to have your terminal emulator set to 115200 to enter the configuration commands.

Now you should be ready to download sketches from the Arduino IDE to your Arduino using bluetooth.

If you use the Arduino serial commands you will need to make sure to set the speed when you call Serial.begin to 57600 so that it is set the same as the Bluetooth Mate Silver.

This work was built upon the work of others. I post it here not as an example of original work but as an example for reference. If I didn't appropriately credit you for your work please let me know and I will add you.