Bluetooth modules from Roving Networks are popular among DIY enthusiasts – they are small, powerful and cheap. They are used in many projects; I’m currently building Yanis Android Wireless EOS Controller which uses Bluetooth module for communication between Arduino and Android phone. I know from experience that radio links are not always easy to establish and sometimes hard to troubleshoot, that’s why I have the habit to test radio component in stand-alone mode before other pieces of the project. In this article I show how I do it with RN-42 serial Bluetooth module using simple setup and test procedure. Other Bluetooth modules can be tested in similar fashion.
In general, any Bluetooth link is established in two steps. First is called “pairing” and the result of it is an exchange of credentials, which are then stored on one or both devices. Usually, pairing needs to be performed only once – for all subsequent connections stored credentials are used. Second step is actual connection – an application on one device connects to the other device and data exchange starts.
In order to test my RN-42, I need to somehow power the module and then be able to send and receive serial data. To achieve this, I made couple connections using pieces of thin wire (actually, cut-offs of resistor pins), which can be seen in detail on the picture below. Power connector for small LiPo battery is comprised of two wire strips on the right. A serial loopback, which connects TX and RX pins (more on this later) can be seen on the left. Title picture shows the module with battery connected.
When all necessary soldering was completed, I powered the RN-42 using small LiPo battery paying special attention to polarity and went to Network Settings on my phone. First, I made sure Bluetooth is checked and then went to Bluetooth Settings and started Scan for Devices. By default, RN-42 starts in discoverable mode on power-on so there is no need to do anything special. When device is discovered, I select it and enter 1234 as pin. When device is registered as “paired”, I can check the data transfer.
To send and receive serial data over Bluetooth, I need terminal program. There are several applications on the market, my favorite is BlueTerm. To check data transfer between RN-42 and Android, I start BlueTerm, connect to RN-42 and start typing. If RN-42 works correctly, characters I type will appear on the screen.
This happens because TX and RX pins on Bluetooth module are shorted together by a loopback wire. Data sent from the phone will appear on TX pin, then RX pin, then sent back to phone and then to the screen. To see if this is indeed the case I disconnect power from RN-42. Character echoing should stop.
This is all that needs to be done to check the module. Troubleshooting is also easy. If powered-on RN-42 won’t appear in discovery, check polarity (reverse polarity survival is not guaranteed – don’t make this mistake or you may need a new module). If polarity is correct, check battery voltage with multimeter. If voltage is within specs, check if it applies to correct pins. If everything is good but no pairing occurs, replace the module. If device is paired but no characters are echoed in terminal, check loopback pins and soldering quality.
When I confirm that my module is good, I can continue building the controller. I’ll write another post as soon as I get it working.
Oleg.
It is Android not Andriod, I think this is already the second time such error in the title, is it intended?
Thanks for catching this – corrected!
“paying special attention to polarity”
Very important piece of advice here, people.
Triple check before you boot up the module…you’d be surprised how fast these things can get fried.
it is not work for me :-(.
It would help if you elaborate a little…
Hi there, i just received my RN-42 module but i can’t seem to get it to work on either my hyperterminal on my pc or Blueterm on my android phone, i can see the device with the phone and pair with it, but it says device paired but not connected, when i open up Blueterm and try to connect to it it says unable to connect to device, can you give me any pointers, i need to figure out what am doing wrong, i really need to get this working so i can continue working on my project, any help will be greatly appreciated
check your soldering – if you accidentally shorted any of the pads adjacent to power/ground/rx/tx your module may start in some odd configuration.
I tried with different Modules, but the modules don`t work. The datasheet don’t help. I use Lab-equipment to see the signals and i use a Lab-Power-Supply. But alle the moduls seems dead to me. I can’t imagine that your setup (Only Power-Supply @ 3.3V) will work with this modules.
your setup works 🙂
thanks
Hi Oleg, i trippled check all my connections and they are all fine, i also checked the Tx and Rx signals with an oscilloscope and i get nothing, I also spoke to a support tech at Spark Fun electronics, but he was clueless, i tried resetting the module to it’s factory default but still the same, i can not get it to connect to my hyperterminal on my pc or Blueterm on my android phone, i can pair with it but can not connect to it, any ideas?
It could be defective – try a different one.
Hahaha, i’m going to have to buy another one, ugh 🙁
One thing i noticed on your picture above where the module is connected to Blueterm on the title bar above it says connected to RN42-136D, when i try do discover mine with my phone it shows as firefly-A150, why is that?
It either means your module is not RN-42 or you’re establishing connection with some other non-SPP device. The latter would explain why you can pair with it but not connect.
Actually the Datasheet does mention that is the name that will appear when the device is discovered plus i checked the MAC Adress number and it matches with the one the label of the module, so i guess it’s just a defective module, am going to have to buy another one, were you able to finish your project using this module after all?
Or yeah, it works quite nicely.
Hi oleg,
its amazing how simple things can be done when you know where to solder and have expertise :-). I would have a question if you don’t mind.
If you want this device to be a stand alone device, how would you configure it? i mean, there are some pins for leds (connection status, power on/off, etc), but how would you connect a LiPo battery with a micro usb charching system like headsets normally have?
I’m not sure I understand your question. Power doesn’t need configuring, you just connect it. If you need charging, there are several standalone lipo charger ICs, Sparkfun sells them.
Hi Oleg,
which battery model did you use? could you advice me a cheap but functional IC charger to connect to the power pins? using a LiPo without a charger is useless from my point of view.
this will likely work for you -> http://www.sparkfun.com/products/9876
But oleg, if you need to maintain the costs the lowest possible, what would you use with this RN-42? i mean, if you would want to buy more than 500 units. I i have to spend 13$ RN-42 + 20 $ for Lipo and charger, it goes up to 40$ taxes included per module, that i think is so much if we know that there are complete headset solutions (bluetooth module + dsp + microphone + speaker + LiPo + charger) out there under 10-15$.
For commercial project I suggest hiring an engineer. I am available, contact me off-list if interested.
Hello,
I have setup a bluetooth module as you have described. Letters do appear in Blueterm.
I would like to use this bluetooth module for the Yanis EOS controller project.
But i think my bluetooth mite not be the correct one.
How can i check if my bluetooth module has a SPP profile?
It bought it here:
http://www.dealextreme.com/p/wireless-bluetooth-rs232-ttl-transceiver-module-80711
If you see letters in Blueterm then this module does have SPP profile.
Excellent news.
I still can’t capture with the my CANON EOS 450D using Samsung Spica GT-I5700 (Android 2.2.1, CyanogenMod 6.1.1 Spica Alpha 8.4, Yonip Kernel Final Rev.04 24Bpp)
I noticed my phone cannot download the Yanis EOS app anymore, it tells me my phone doest not support it. But i remember downloading v1.0 beta version without any problem a few weeks before.
Instead, i downloaded it(App 2.0) manually else where, installed it without any problem.
Then i tried it using the old version of arduino code. Doesn’t seem to work with Yanis EOS v2.0
I have tried compilling v2 of Yanis Android code, but it doesn’t compile. Error. Before i post the error, i am going to redo everything, make sure i am not doing something wrong.
It still doesn’t work.
I have Arduino Uno v3 + bluetooth module + usb connected to EOS.
The arduino sketch code compiled and uploaded successfully. Once the arduino is powered and everything connected, the TX led, RX led, Power led, Pin 13 Led are on. These are all the led i have on my arduino nano.
The power led and pin13 led are not too much of concern. What intrigues me is the RX and TX led that stay on(HIGH). They stay like all the time except when i press a button on my camera. Then they stay off, even if start selecting buttons in the app.
My phone pairs and connects correctly to the module without any errors.
Nothing happens when i press button in the app.
My 450D has a blue led in middle of a print/sync button as a indicator. That led is always on, i suppose that is normal indicator for usb port on the cam.
Here all the details i have noticed, but can’t figure out the problem.
Any Ideas?
Can i check the baud rate using blueterm? Maybe i have wrong baud rate settings.
Thanks in advance.
you can write some simple sketch generating traffic into serial port. In fact, you can load EOSRemote sketch, open Blueterm and control your camera from Android the same way you would do it from a PC terminal. Just make sure your baud rate is correct, EOSRemote has it set to 115200 by default, you’d have to change it to 9600.
Hello,
Please you can use the RN Talk applicantion for Android on Google Market it is my and is free too.
Regards
Marcel
Can you please guide how to connect phone via bluetooth module . I have Japenes Belta (Yaris) .The LCD is in japanene language.
pls help
thanks
Hi Oleg,
I’m using a RN-42 for my project as well. When I’m doing the testing guide by following your guide, it’s working for me. Then I take out the short circuit between Tx and Rx, and typing on Blueterm, what I’m typing still shows up on screen. Do you know why that’s happening?
You may have local echo turned on in the terminal or in the module.
Hi Oleg,
I’m trying to connect RN-42 with Android. Later I’ve connected to RN-42 with my PC-Bluetooth-Module and with another RN-42. Those solutions works great.
But when I’m trying to connect to BT-Module via BlueTerm it says:”Unable to connect device”. When I’m trying to initialize connection via RN-42 it answers:
TRYING
CONNECT failed
What I’m doing wrong?
Hi Andrew, as I read, to connect with android requires a RN-42 module with version 6.03 or later and must be configured with SSP UUID = 0000110100001000800000805F9B34FB.
Hi,
we are using the RN-42 for a school project and noticed that your testing solution is exactly how we want to use the chip in our project. But we studied the datasheet and noticed that there is a low-active reset pin. So is there no need to pullup the reset pin or pulldown the pio-configuration pins?
Regards,
Daniel
Works like a dream. Thanks for the tip.
Hey, I’m a beginner-beginner in this electronics stuff (I’m more of a software guy)… So I got an RN-42, but I can’t solder it!! The solder never sticks it to the module… How exactly did you get such a clean solder? Is there some technique I’m oblivious to? I just use some core solder with a soldering iron, but nothing works… it always seems like I’m going to burn the module up… It looks like you pushed the wire into the module… How did you do that? I am, like I said, a true beginner in this electronics stuff, so any guidance as to how I would solder the wires on would help!
Thanks,
Brandon
Use some rosin flux – it makes soldering easier.
hi
i want to know the compatibility of AUBTM-20 Bluetooth module. i mean to which phone it can connect easily and data can be send from mobile to micro-controller via Bluetooth module?
Im using AUBTM 20 with atmega128. I wanted to know how to establish an L2CAP layer link as im trying to implement SDP myself on the uC
For this battery, how long it can last? If you turn on the Bluetooth all the time, how long it can transmit?
Could I stream video from my phone to the arduino and out to some acquisition software?
Hi,
I have been trying to use this module and I want to save power when I am not transmitting.
Here is the user manual – http://www.sparkfun.com/datasheets/Wireless/Bluetooth/rn-bluetooth-um.pdf
Now My requirements are these
1. keep the module connected to my pc
2. transmit “Hello” to pc when a button pin 12 goes high on the arduino, this will happen by button press
So when I am not transmitting, I want to be able to keep the device in sleep mode. The command for that is SW,8000
However my module is still consuming 25 miliamps when not transmitting. Has anyone tried this?
since you powered the module with 3.7v lipo, you exceeded the 3.6v max input voltage for this module.
Did everything worked fine under this voltage or you eventually damaged your RN42
Hi, i cannot connect the RN 42 XV bluetooth module. It pairs with my Samsung S2, but will not connect in blueterm. Using android 2.3.5. Appinventor forums said worked with 2.3.2 or earlier..
Pair with bluetooth on computer. No probs. says connected RNI-spp, outgoing on port com9, incoming on port com10. led flashing. use putty on port com9:115200-8-NONE-1-NO RTS
PUTTY connects led goes solid, no reply to commands. tx connected to rx module returns typed text..
Any ideas?
Managed to get the BT module to connect to app inventor . Just connect with UUID and set the UUID to 00001101-0000-1000-8000-00805F9B34FB
Hi,
i am also using RN-42 bluetooth to communicate with Android. Did you have to make any changes to the bluetooth module? Or can I just buy it as it is and do all the steps you have done to check for connection. Some websites mention something about bluetooth stack…I am not sure if that’s something I need to do with the module. Any suggestions?
Thanks
This module has on-board stack. After applying power, it’s ready ti use.
Thanks!
I have a question about the Bluetooth range.
The RN41 has range of about 100m I think but the RN42 has only 20m. If I am using the Android phone as the master, then should it matter whether I am using RN41 or RN42? Shouldn’t the BT range of Android (which I think is about 10 or 15 m) be the limiting factor?
The range of the link is not easy to estimate. The range of one side of the link determined by the power of the transmitter plus the sensitivity of the receiver on the other end. You have 2 pairs, the one which has shorter range will determine the range of the whole link. It’s hard to predict performance from the specs, I suggest buying better radio if you can afford it – chances are it has more powerful transmitter and more sensitive receiver so you can get better range even if other radio is no match. On the other hand, more powerful radios consume more electricity – so try to figure out the range you really need.
Well I am new to this RN-42 module. Can you please help me? I want to connect two RN-42 modules for transmitting a continuous digital signal. The received signal will then be processed further.
1. How to connected two modules. One for transmission and another for reception.
2. Which pin in the transmitting RN-42 should have the main digital signal?
3. Which pin in the reception RN-42 will have the received digital signal?
Hi Oleg,
This is a nice small BT Module. I’m also interested in the small battery because i have to build a slight project. Question: Since i’m new to this, is it possible to let’s say, attach a force sensor like this: https://www.sparkfun.com/products/9376 to the BT Module and send the data wirelessly to another Arduino? Thank’s!
BTW: I would more be interested were you got this tiny battery from.. Thanks!
Sparkfun used to sell these; don’t know about now.
iSee. Found it. One of these Polymer Lithium Ion Batterys. However it is a bit confusing because you used a 3.7V battery but the datasheet of the BT Module says 3.3V. Thank’s anyway.
Hi, I’m using the RN42 with ATmega32u4, I can detect the device in my bluetooth devices but I want to be able to change its name, how do I change the settings inside the RN42?
Oleg, I’m wanting to place this module on my door and have it realize when a connection is made. Is it possible to have my phone automatically pair with my phone and then, from that input, have an output to trigger a locking mechanism? For instance, if a password is needed, do I need to open the App every single time or can it be autonomous after the information is sent once? Any response is greatly appreciated.
*correction* Is it possible to have my phone automatically pair with the module *correction*
Should be possible if you set a fixed PIN for the device. Not sure if you want your door lock to operate in this mode as it is quite insecure.
I feel like the only part of this that would make it insecure would be if someone figured out I had the lock set up this way and then figured out the PIN. Which actually wouldn’t be too hard if someone had some time and a macro on their hands.
Hi Oleg,
I have had success both pairing and connecting to my RN-42 with BlueTerm, but when I short the RX and TX pins I don’t receive the same data that I am sending. An LED indicator shows that the module is receiving data whenever I type, but the data is either not sent back at all, or is usually the wrong character. (Once in a while it is correct)
Would this be the fault of a faulty module?
P.S. Thanks for the guide!
More info that could be useful:
I am using a RN-42-SM
I have changed some settings including baud, but have tried setting factory defaults
I am fairly certain that I have not shorted any of the other connections
Bad contact in the short, maybe?
Thanks! work well for me!
hi.
I developed an android app for receiving data from arduino though RN-42 Bluetooth module.
ITs works fine with android 2.3 but i am not able to receive the data when i install it to 4.2, But the Bluetooth and android device is getting connected.
You should check out the Android app I wrote for the Balanduino: https://github.com/TKJElectronics/BalanduinoAndroidApp.
The relevant parts of the code are here: https://github.com/TKJElectronics/BalanduinoAndroidApp/blob/master/src/com/tkjelectronics/balanduino/BluetoothChatService.java and https://github.com/TKJElectronics/BalanduinoAndroidApp/blob/master/src/com/tkjelectronics/balanduino/DeviceListActivity.java.
Hi,
Im using RN42 bluetooth module & android mobile.,
I am unable to connect with module, on mobile i am getting some wrong paring key.
Rechecked the hardware setup and its quite good.
Do you have any solution for me?
Thanks In Advance!
You could try to change the pin by connecting the module via USB to your computer and then send the following command via the serial port:
This will change the pin to “0000”. It should respond something like this:
See: http://www.rasmicro.com/Bluetooth/EGBT-045MS-046S%20Bluetooth%20Module%20Manual%20rev%201r0.pdf for more information.
Made some other changes and now its working well! 🙂
Thank You!
Please tell what are changes you have made to connect RN 42 module with Android mobile, because I am stuck here.
AFAIK everything has had stock settings. Are you able to pair?
Hi,
I am working on a project where we are developing a product which has two main components namely :- An android tablet and a PCB(contains an RN 42 Bluetooth chip).The product has few physical buttons which is connected to the PCB.
Working:Whenever any of the physical buttons on the product is pressed,the PCB will send 1 byte of data(representing the particular button) via Bluetooth to the android device(wherein its received and an activity is invoked)
My doubts:
1) When two devices are paired and a Bluetooth connection is established between them,then will this Bluetooth connection last/exist forever ? (if we assume that both the android device and PCB remains ON/plugged in indefinitely and are always in close proximity to each other).
2) If point 1 is true, then internally does the Bluetooth module in both the devices send any data periodically to maintain this connection? If so ,what is this data and how often is it exchanged?
3) If point 1 is false, then do I need to send signals from my android device to the PCB module periodically to maintain the Bluetooth connection ?
Thanks in advance !
hello.,
Sir, I’ve a question out of above discussions,I’m working with android robot and here i have Bluetooth device and i am not able to find Tx & Rx port. And I am using Bluetooth headset as a communication medium. Here there are 6 pins spk+ spk- bat+ bat- 5v gnd. now which pin is Tx & Rx..?? A big confusion for me..! expecting your suggestion.
Are you sure it is a serial device and not an audio device? The pin labels suggest that you have audio.
Thanks for the reply Sir.,
yes, it’s my mobile’s headset. so I can’t use it in my project.?
With audio class BT module you can only send audio to it.
please, I have issues with reading normal characters from the stream while connected with rn-41 bluetooth module. I have successfully initiated pairing,connection and sending to the stream with the module using 32feet.net. the only issue now is that anytime i send “hello” to the stream,(normaly i looped the tx and rx together) im supposed to get hello back on my pc, but what i get is “??????!”. Please help me. Thanks in advance
How easy would it be to wire two push type buttons to this module? My goal is to automate certain actions with the bluetooth module on my computer. When I push one of the buttons on the module an application is started for example. I’m having trouble finding good resources for this, any advice?
Hi dear Oleg,
I find that what you’re doing is a great job! I’ve one question : Pairing and connection are working with my Galaxy S3, RX and TX are linked, but when I’m typing on BlueTerm, I’ve got no response of what I’m writing.. However, the red LED lights up when I hit a key on my Samsung.. Do you have an idea of why it doesn’t work?
Thank you!
IMPORTANT!!! I’ve found what was the problem.. You have to link RX and TX together, but you have to do the same for CTS and RTS too! It works perfectly now!
Dear Oleg,
we are using the RN42 in an application where we measure data with a samplerate of 400Sps. We put this rn42 with the rest of the electronics into a plastic case. After attaching the case to a human body while walking arroud (area of 5m to the receiver) we are seriously loosing data. When laying the case near the receiver everything works fine. I must say that the case is made of an antistatic plastic. I think this is really not ideal.
We also tried removing the electronics from the case. And tried with covering the electronics with the hands and there again data got lost.
I was wondering the the human body is effecting the signal that much. Could this be? Do you think manufacturing the case of “normal” plastics will improve the signal strength?
All the best
Ronny
I’ve never used those enclosed in any type of case. Live tissues absorb radio waves quite well, too.
hi
As i m beginner ,i m having problem in connecting one RN-42 with other laptop bluetooth
please help me out
and also how i can set communication between one RN-42 connected to laptop and android phone(HTC 620)
please sort it out
thank you
Somebody – please give advise. I’m experienced in electronics, but trying RN42 for the first time with Android phone. Default settings, just connected the module per manual. Shorted TX and RX as you suggested. I can see the device name on the phone, as RNBT-6AD7. Bluetooth pairing request: Confirm passkey 377491 (every time there is different number), OK, or CANCEL. I press OK and it says RNBT-6AD7 is paired, but on the module the LED still blinks in discoverable mode, which means it’s not paired. So the phone thinks it is paired but the module says it’s not and keeps blinking waiting to get discovered. Blueterm also says Not connected. Power is 3.3V. Any pointers?
I don’t think this pairing mode is supported. You need to turn it off, use the one where you are entering the PIN manually and then enter what was hardcoded into the module. See manual for more details.
I’m very interested in the RN42 for transmitting analog readings from a remote sensor to another device (PC, Android, Whatever). I have a sensor that takes a measurement and the reading is translated to a low variable voltage between 0 – 2.5vdc. I was wondering if any of the inputs of the RN42 would accept these readings from the sensor and then be configured to send/stream those readings in realtime over bluetooth to another device that its paired with? For the the sake of discussion lets just say the sensor is a temperature sensor. If this is possible i’ll pick one up right away. Since it can stream audio i would think it could handle 0-2.5vdc signals. AM i right?
Thanks for the write-up. I just did this with an RN-41 and was able to get a about 150 feet away inside of a building with walls in between me and the RN-41. I used a Galaxy S4 to talk with it. Further than that distance it would no longer repeat the characters, but was still connected. When I walked back toward it I suddenly got all the characters at once when I was in range.