bluetooth: a wireless arduino (nearly)

having got the stepper motor running the next thing to do is to send signals to the arduino chip (the ATMega 168) over bluetooth. for an intro to the arduino see this post).

the bluetooth chip i picked up is a “SparkFun – BlueSmirf – Bluetooth Embedded Module (Gold)” from SparkFun electronics or rather it’s uk distributor “robosavvy”. It looks like this:


the bluetooth dongle (my laptop hasn’t got didn’t have bluetooth) on the right is also from SparkFun/robbosavvy (£12.82). best advice is apparently to buy this one for use with the Smirf.

so, first, installed bluetooth dongle. v straightforward.

then, wired up chip to arduino as in the image below (ignore the LED on pin 13 for the moment): VCC to 5 volts and GND to ground. and, critically, connected CTS-1 and RTS-0 to each other (wish that I’d known that 2 hours earlier than I did). some have also found that you need to wire tx and rx to each other. I not hit that one. the wiring ended up like this:

With that wiring (and no attempt to connect to the laptop) the smirf flashes its red led. it flashes quickly for a minute or so and then it slows down after a bit. it seems that you can only make the ‘initial connection’ (and therefore change the smirf’s critical settings like it’s baud rate) during the fast rate section.

the serial COM port that’s been assigned by the laptop can be discovered by right-clicking on the bluetooth icon in the bottom right corner of the screen and go to advance settings – client applications. mine went to COM8 (but sometimes goes to COM7). in time will have to find a way of assigning that.

next up: making a connection over bluetooth.
here things slowed down a bit too. initially, I tried windows hyperterminal and got v frustrated. then downloaded a different terminal programme which is suggested by roving networks – the bluetooth chip makers. apparently windows hyper teriminal is a bit buggy – although microsoft would probably have more than that to say about my computer skills. anyway. this programme worked: ‘teraterm’.

on opening teraterm, I selected serial (rather than TCP/IP) and then Port COM8. having clicked OK, the bluetooth icon flashes up and teraterm stopped loading. the bluetooth application needs the security code. the smirf’s first code is ‘1234’. having entered that, teraterm fires up. at this point, the bluetooth icon on the laptop turned green, and the smirf’s red led turned off and a green one came on. all good.

next. a couple of changes to the default settings for teraterm. first: in “setup” – “terminal” I checked the ‘local echo’ box to ensure I could read what was being ‘sent out’ to the smirf. second, in “setup” – “serial port” I used the settings in the image on the right.

i should just record a couple of things at this stage in case anyone else has a go at this:
i) some say theirs only worked with hardware flow “off” – even though the documentation says turn it on. not my experience but worked for some. (believe me when this thing isn’t working you’ll try anything!)
ii) serial baud rate has to be 115,200 (at least at the beginning).

now, then, a bit of a fiddle! having made those changes to the serial connection you have to disconnect and then reconnect to ensure the changes take effect. you also have to ensure that the smirf is in it’s ‘fast flashing’ mode. in other words, you have to both disconnect the bluetooth connection in teraterm, AND remove the power to the smirf. Then (and only then) you can (i) reconnect the power to the chip, (ii) reconnect in teraterm, and (iii) type $$$ (3 dollar signs).

That’s it! After that procedure the smirf’s green light stays on. In teraterm you see “CMD” which has come back from the chip – so you know you’ve made a connection over Bluetooth. Having connected to the Bluesmirf, now need to change a couple of the default settings. Typing ‘D-‘ (must be capital D) in Teraterm and then ‘enter’ returns the smirf’s original settings as follows:

***Settings***
BTA=000666009A48
BTName=FireFly-9A48
Baudrt(SW4)=115K
Parity=None
Mode =Slav
Authen=0
Encryp=0
PinCod=1234
Bonded=0
Rem=NONE SET

So, the amendments:

First, change the name. Typed the following and clicked enter:

SN, "capeM-Blue"

Smirf responds: AOK. sounds good. check with “D-” and it’s changed. hurrah.

Second, change the baud rate. This is important because the arduino only works at 9600 baud rate (not the smirf’s original 115,200). just typed the following (no spaces) and clicked enter:

SU,96

“AOK” in response.
“D-” shows its working.

so that’s it. Up and running.

Ben

postscript:

these links i found useful:
bluesmirf blues was v helpful and was an apt description for various parts of this process;
• TriggerDog’s ‘trying to do the arduino projects‘ blog was also useful.

post a comment...

you must be logged in to post a comment.