Pages

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:

BluetoothMateSilverMod-Adapter

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.

BluetoothMateSilverMod

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.

BluetoothMateSilverAdapterDiagram

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:

BluetoothMateSilverSetup

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.

Tuesday, December 18, 2012

It Worked For Me - Evil Mad Scientist Arduino ISP Shield

I recently decided to try my hand at programming another member of the AVR family. After doing some reading I decided on the ATtiny85. Online I found a good tutorial on programming the ATtiny85 using a breadboard. I ordered up some ATtiny85s and followed the instructions on the tutorial and was quickly able to program it.

Plugging the ATtiny85 into and taking it out of the breadboard got old fast. Poking around the MicroCenter website I noticed that my local store had several Evil Mad Scientist Arduino ISP Shield kits in stock. On the Evil Mad Scientist website I found a link to an Instructable for hacking the shield to allow programming of the ATtiny85.

I picked one of the kits up from MicroCenter, built it with the great instructions on the Evil Mad Scientist website and then made the mods outlined in the Instructable to allow programming ATtiny85s.

View of the top of the shield.


View of the bottom of the shield.

Note the wire wrap wires used for the ATmega168/328 to ATtiny85 mod.


A Hack of My Own

I extended the mod from the Instructable to allow for multiple clock speeds for both the ATtiny86 and thge ATmega126/328. I connected the the clocking pins from the standard ATmega168/328 location to the ATtiny85 pins. I did this using wire wrap wire as done with the other pins. I then installed female headers in place of the capacitors and crystal. I took the capacitors and crystal and soldered them to sets of mail header pins. This way I can plug in different speed crystals.


Thanks to the folks at Evil Mad Scientist for producing such an affordable and hackable product, thanks to the folks at the High Low-Tech Group at the MIT Media Lab for instruction on how to program ATtiny85s using the Ardunio IDE and thanks to rleyland for posting instructions for his hack.

Monday, October 22, 2012

Heart Rate Monitor Project – Phase 1: Software

Over the weekend I developed some initial code to work with the hardware setups posted last week. The code was developed in Arduino 1.0.1.

Ant+ Heart Rate Monitor Code for Arduino

Sunday, October 14, 2012

Heart Rate Monitor Project – Phase 1: ANT + Arduino Hardware Setup

As outlined in a previous post I am working on a project to interface an ANT+ Garmin Hear Rate Monitor Strap to an Android tablet.  The first phase is to get heart rate statistics sent via ANT from the heart rate monitor to an Arduino.

I am working on solutions with two ANT modules: Sparkfun’s USB ANT Stick and Dynastream Innovations ANT11TS33M4IB Module

Sparkfun USB ANT Stick Hardware Setup

Both modules run at 3.3V so I wired up an 8Mhz breadboard Arduino running at 3.3V.  Connecting the Sparkfun USB ANT Stick was easy.  All that was required was soldering four pins into the holes located on the board.  If you look at the insert of the board in the picture below you will see the four pins.

SparkfunSetup

Once the pins were connected the board was plugged into the breadboard with power connected to the power rail running at 3.3v, ground to the ground rail, receive to D7 and transmit to D8 on the Arduino.

Dynastream Innovations ANT11TS33M4IB Module Hardware Setup

Connecting the Dynastream module was a bit more of a challenge than the Sparkfun module.  The Dynastream module is a square board that measures roughtly 0.75” of an inch. On two sides of the board there are 7 holes / pads and on a third there are 3. Given the spacing of the holes and their locations the module isn’t breadboard friendly.

I found that the individual wires in a Cat5 LAN cable were the right size to fit into the holes. I cut a section of Cat5 cable, extracted the individual wires and soldered them to the board and then plugged them into the breadboard.

DynastreamSetup

Additional pictures from the sides showing the connections:

      

The following pin out was used.

Module Pin Pin Name Connected To
1 GND GND
2 /RESET 3.3v
3 Vcc 3.3v
4 GND GND
5 GND GND
6 /SUSPEND 3.3v
7 SLEEP GND
8 GND GND
9 GND GND
10 BR2 GND
11 TXD0 D7
12 RXD0 D8
13 BR1 GND
14 BR3 GND
15 GND GND
16 GND GND
17 RTS D12 w/1Mohm to 3.3v

The 1M ohm pull up resister on pin 17 is key. If you don't have it the board goes into sensRcore mode and will not respond to async communications.

Next Steps

With the hardware all setup the next step will be to program the Arduino and test communications from the heart rate monitor strap through the ANT module to the Arduino.  This will be the subject of the next post.

Heart Rate Monitor Project

As the summer drew to a close I decided that monitoring my hear rate as part of my indoor training regime would make for an interesting project and might make cycling indoors a bit more interesting. To do this I decided to interface the heart rate monitor with my Android tablet.

BikeStrapTablet

After doing some research I decided that there were three approaches I could take.

  1. Get a bluetooth heart rate band and interface with the tablet via bluetooth.
  2. Get an ANT capable heart rate band and interface with the tablet using ANT and the android open accessory protocol.
  3. Get a heart rate band from Polar and interface with the tablet using a Polar wireless interface board and the android open accessory protocol.

I decided to go with the ANT approach. This was partly because of cost but also due to the fact that there are other sensors including ones that measure cadence and speed that make use of ANT.

What is ANT?

ANT is a 2.4GHz wireless networking protocol and embedded system solution designed for low power wireless sensor networks. It has a focus on sensors for measuring various aspects of exercise and while it isn’t restricted to this it does seem to be a popular us case.

For the most part ANT sensors are used in combination with GPSes which provide readout and recording of the sensors. There are also a few smart phones that are ANT capable.

Heart Rate Belt

An ANT heart rate monitor consists of the sensors for picking up your heart beat and a small lower power transmitter attached to a belt or strap that is worn across the chest. The sensor picks up the heart beats and then broadcasts them so they can be picked up by an ANT receiver.

For my project I chose the Garmin Soft Strap model HRM2-SS which I found on Amazon for $44.

ANT Modules

I started by purchasing Sparkfun’s USB ANT Stick.  This was a very nice module because it got me both a USB interface that could be plugged into a PC.  Also the board broke out power, ground, transmit and receive which facilitated connecting them to a microprocessor.  Unfortunately, shortly after I purchase this from Sparkfun they discontinued the product with no replacement.

I also ordered a Dynastream Innovations ANT11TS33M4IB Module as I felt the form factor of this module would work better in the final design.  The Dynastream module is I purchased is the module on the ANT website that is recommended for prototyping. It can be purchased from several sources. I purchased mine from Digikey.

Next Steps

My plan for moving forward is to start by interfacing the ANT modules with an Arduino.  Once I have done this I plan to leverage the Circuits@Home USB Host Shield that I purchased and tested out last spring to interface with Android.

Time Flies – June through September 2012

I was on a roll the first part of 2012 with 14 posts.  Over the summer I got busy with other things and see that I haven’t posted anything since May.  Now with the days getting shorter I have time again for a projects and some new ideas.