### Welcome to our site!

#### Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Status
Not open for further replies.

##### New Member
I have completed my project wherein I am controlling a stepper motor through a VB form and displaying the temperature of the surrounding also on it.
Right now I have done it using the RS232 port on the desktop. I wish to now convert this to Bluetooth serial comm... From what I understand I have to buy a Bluetooth serial adapter which costs around$50. So before buying one I just wanted to clear a few doubts. 1. Do I just have to replace the DB9 female connector with the Bluetooth? 2. If so then all I have to do is change the code of VB to support the corresponding COM port>? 3. Is there anything else that I would have to do?Any problems I might face? #### aforadi ##### New Member I am using PIC18F4550 and MAX232 and ULN2003 and LM35 temperature sensor #### blueroomelectronics ##### Well-Known Member Which bluetooth adapter do you plan to use? #### arhi ##### Member depends on the BT adapter but it is not "that" simple ... in general 1. you need to write routine on your uC to pair BT module with PC (on some button press or whatever) 2. before you start - you need to "initialize" BT adapter so in general this means 1. you need one C function for pairing (cca 30lines of code) 2. before you start using the rs232 - you need to init BT module (2 lines of code) that's it for most of the modules ... there are some modules (bit more expensive then 50$) that do automatic pairing and they automatically establish serial line so you do not have to do anything on the pic side ... the problem is you would have to have 2 modules, one on the pc side and one one the uC side

I'd recommend you use ZIGBEE modules .. they cost ~same, complexity to modify your application to use them is ~same, you will have to get 2 of them (one for PC) ...

in any case, on your uC side you use max232 to change levels from uC to DB9 and vice versa. When using modules (BT or ZIGBEE or ..) you do not need to shift levels to 12V... You might need to shift levels down to 3V (for example parani esd bluetooth module is 3V)

##### New Member
Which bluetooth adapter do you plan to use?
I was hoping you guys could suggest me one.

##### New Member
depends on the BT adapter but it is not "that" simple ...

in general

1. you need to write routine on your uC to pair BT module with PC (on some button press or whatever)
2. before you start - you need to "initialize" BT adapter

so in general this means
1. you need one C function for pairing (cca 30lines of code)
2. before you start using the rs232 - you need to init BT module (2 lines of code)

that's it for most of the modules ...

there are some modules (bit more expensive then 50\$) that do automatic pairing and they automatically establish serial line so you do not have to do anything on the pic side ... the problem is you would have to have 2 modules, one on the pc side and one one the uC side

I'd recommend you use ZIGBEE modules .. they cost ~same, complexity to modify your application to use them is ~same, you will have to get 2 of them (one for PC) ...

in any case, on your uC side you use max232 to change levels from uC to DB9 and vice versa. When using modules (BT or ZIGBEE or ..) you do not need to shift levels to 12V... You might need to shift levels down to 3V (for example parani esd bluetooth module is 3V)

Isn't there one which I could just connect to uC?Like the SENA EDA 110 adapters?
So I just have to modify my code a bit to establish the pairing and initialize it.
Can't I use the Bluetooth unit which is already present in my laptop?

#### arhi

##### Member
esd110 is gread device (That's the one I use most of the time) ...

the way BT work is that you have to "pair" devices and you have to "connect" ... so you will have to slightly modify your code .. check out the pdf for parani esd* devices

if you modify your code to add pair & connect, yes, you can use internal bt from your laptop

##### New Member
Right so... I just ordered ESD110 ...in the mean time... I will start studying its datasheet...
I hope you guys would be able to help me out if I get stuck in my code anywhere.
Thanks a lot arhi.

##### New Member
So what i understand is that the following connections are to be made
tx of uC goes to rx of bt through a 68kiloohm resistor and the other end to ground a 115kohm resistor.
rxx of uC to tx of BT
gnd to gnd and cts of bt
3.3 v power supply to vdd
some port bit to rst through same resistor pattern
cld u pls confirm if the connection is right
cld u also pls give more info abt pairing,the code and how to do it?

#### arhi

##### Member
tx to rx, rx to tx .. only you need to do level shifting if your uC is operating at 5V as esd is 3V device.

you can do a level shifting different ways but you have example in the datasheet but I had problems with it as my uC did not want to recoghise 3V3 signal as 1 so I added some mosfet driver (attached)

#### Attachments

• screenshot2.png
45.1 KB · Views: 318
• screenshot3.png
14.3 KB · Views: 239

##### New Member
Could you also help me out with the code?
If you could post yours or tell me where to start from...I have searched the net and couldn't find anything

##### New Member
I am using the PIC18F4500. Also which MOSFET driver did you use exactly...cld u give me a link

##### New Member
I have attached the connection which I should be making as I am not using any hardware flow control.
There will a slight change in this diagram to account for the 5v to 3.3v and 3.3 to 5 v conversion as my uC is pic18f

#### Attachments

• connection.jpg
29 KB · Views: 360

#### arhi

##### Member
the connection is ok but you need to account for the 3v / 5v difference ..

check out the https://www.electro-tech-online.com/custompdfs/2009/04/3_3vto5vAnalogTipsnTricksBrchr.pdf for examples

with regards to code, I gave up on BT and went for ZIGBEE (modules arrived but still had no time to play with them) .. I'll try to digg up source that worked with BT but that's gonna be gcc for TI MSP430 as that's what I finally used with BT module

##### New Member
Could you give a link to zigbee modules you used?(exact ones)
Thanks

##### New Member
""worked with BT but that's gonna be gcc for TI MSP430 as that's what I finally used with BT module""
Could you please explain what you mean...I didn't quite get it

#### blueroomelectronics

##### Well-Known Member
XBee and XBee Pro are common, cheap and work well.

#### arhi

##### Member
""worked with BT but that's gonna be gcc for TI MSP430 as that's what I finally used with BT module""
Could you please explain what you mean...I didn't quite get it

TI == texas instruments ( Analog Technologies, Semiconductors, Digital Signal Processing - Texas Instruments )
MSP430 is a line of micro controllers made by TI ( **broken link removed** )

GCC is Gnu C Compiler

The difference between MSP430 and PIC is great but with regards to BT module, it is not that big as the part that is important is "usart_send()" and "usart_receive()"

with regards to zigbee, I got the modules, not tried them yet ... waiting to get some time to play with them, I got
- pair of MRF24J40MA-I/RM - you have to implement the network stack yourself
- XBP24-BWIT - ready to use module (network stack implemented in module)

but, they are still on the shelve .. I do not believe I will have time to play with them for at least another 2 months

##### New Member
K..Thanks a lot
Any idea where I could start working on the code from?...Where did you start off from?

#### arhi

##### Member
for the BT module ... first thing I did is make max232 interface and connected parani esd110 to desktop and used putty to talk with it ... paired it with my laptop and talked from laptop to desktop via BT ... then I implemented the same thing to uC (what I typed manually via serial console I implemented in uC) ...

in general, everything you need is in the datasheet .. basically - the AT commands are all you need

Status
Not open for further replies.

Replies
3
Views
1K
Replies
16
Views
4K
Replies
1
Views
2K
Replies
7
Views
7K
Replies
1
Views
2K