BLUETOOTH MODULE NOT WORK

An area to discuss 8-bit PIC specific problems and examples

Moderator: Benj

Post Reply
SILVESTROS9
Posts: 115
Joined: Wed Aug 03, 2016 10:45 pm
Has thanked: 24 times
Been thanked: 11 times
Contact:

BLUETOOTH MODULE NOT WORK

Post by SILVESTROS9 »

TIME-BT-01.fcfx
(11.29 KiB) Downloaded 293 times
Dear sirs,
I would like to use a bluetooth module, an HC-06, to make a device with RS232 port a bluetooth slave, and send data to that device with my tablet....so I tried to use a PIC16F1939 to interface with bluetooth module....i was used bluetooth component to change some parameters but nothing works...bluetooth module works as it appears as HC06, and paired with default code 1234...but I can't change anything . pairkey, or setname...I was checked connections ....C.7 (RX) to TX of bluetooth module, C.6 (TX) to RX of module, VDD and VSS ok...PIC works fine...I can't find what is wrong..I send the code for any opinion...also is it possible to send a long string >80 char.to slave device at once?
for info about module : https://grobotronics.com/bluetooth-modu ... -hc06.html

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by medelec35 »

RX is not 5V tolerant so you need a level shifter on the RX.
For resistors I used a 1K8 from TX of MCU to RX of BT.
3K3 from RX of BT to 0V
The TX of BT can be connected directly to RX of MCU.

I have used both HC05 and HC06 including renaming them and changing paring key.
The HC06 and HC05 AT commands to set up BT parameters are very different, so I don't know how the BT component within Flowcode is compatible to both? :?

Within your flowchart you have got both BT and UART setup for the same hardware channel which is wrong.
You only need either hc05 or UART.
What do you want to do with received data from the tablet?
Send to terminal via UART or send to LCD or control something?

For debugging purposes you can use a terminal program.
For now you can use USB to UART converter (if 5V signals then use voltage level shifter) connected to BT.
Use terminal program to sent AT command so you can set name,, change pair key etc..

If not got a USB to UART converter then a flowchart can be produced to change the settings for you.
But that will use UART instead of HC05 component.
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by medelec35 »

I have just created a quick flowchart that changes the HC06 name and pin.
Confirmed working with my HC06.
Just alter the string within calculation boxes to change name and pin to your own.
Automatic error detection can be added, so if pin or Name not successfully added then there could be a warning generated on the display.
Attachments
HC06 Name + Pairkey Changer 1c.fcfx
(15.75 KiB) Downloaded 370 times
Martin

SILVESTROS9
Posts: 115
Joined: Wed Aug 03, 2016 10:45 pm
Has thanked: 24 times
Been thanked: 11 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by SILVESTROS9 »

Thanks medelec35 for help...let me explain what I would like to do ....I have a tablet that runs Windows-8 ...I've a small program that works as real time clock....that info I send to a device that has rs-232 port to correct the time....that info send to device with cable..I would like to send that info wireless using a BT module...is it possible to send me a sample code for FC7 to do that? also I'll use a max232 to connect with my device port...can you tell me what are the connections between BT , pic16f1937 and max232 rx,tx input? thanks in advance.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by medelec35 »

I used a HC06 connected to a microcontroller.
The RS232 converter was not required for me.
If Tablet has Bluetooth built in then you won't require MAX323 either.

In my previous post, I mentioned that RX of Bluetooth goes to TX (Pin 25) of Microcontroller via a level shifting potential divider.
The TX Bluetooth goes directly to RX (pin26) of Microcontroller, no level shifting required.
The microcontroller was also connected to an I2C RTC.
I created an app so when tapped on a button on my mobile the time and date was sent to the RTC via Bluetooth which works very well.
So it's very doable.
Yoy can send strings and Bluetooth will just act like RS232 at 3V logic level.
I would suggest staring at the basics and just get the HC06 to change name and password and go from there.
I
Martin

SILVESTROS9
Posts: 115
Joined: Wed Aug 03, 2016 10:45 pm
Has thanked: 24 times
Been thanked: 11 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by SILVESTROS9 »

Dear medelec35,
thank you for info..I used the code in your previous post but I've a message "unable to pair"when I set the new code...there is a detail about program that send rtc info to my device....my device accepts only rtc info from that program, maybe the info is coded....I can't use a common rtc to send the info to my device....so the only way is to send the info wirelessly from my program in the tablet ( when I tapped on a button ), to my hardware with BT and MCU and connect rx , tx with a connector to my device...so, what is your opinion about transmission of data from tablet to the input of my device ? I make connections rx, tx between HC-06 and PIC16F1937(with a divider at rx of BT)...the connection to rs-232 port of my device is from that lines in parallel?. is correct to switch AT commands and data with EN/KEY pin (EN=HIGH=AT COMM., EN=LOW=DATA)? how can I control transfered data with mcu? thanks.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by medelec35 »

If you upload a full circuit diagram, I can check out all the connections for you.
With the HC06's I have they are automatically in AT command mode when not paired.
As soon as they are paired they go into data transfer mode.
En high is normally for HC05 modules.
You can tell from the LED flashing/solid what mode it's in.

There should not be any issues sending data from tablet to Microcontroller via BT so long a range is not to far and BT baud matches MCU baud. With Android there is an app called Serial Bluetooth Terminal.
It works well, so you can check data received is correct.
Martin

SILVESTROS9
Posts: 115
Joined: Wed Aug 03, 2016 10:45 pm
Has thanked: 24 times
Been thanked: 11 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by SILVESTROS9 »

Dear medelec35,
many thanks for your help...I send you circuit diagram....about HC-06 red led flashes quickly 3-4 times/sec...it seems that there is no change from AT command to DATA mode, because there is no communication between mcu and BT module...about Android the problem is that the program runs only in windows...if its possible to run that in android it will be easy to send info from mobile phone...thanks.
Attachments
HC-06 + PIC16F1939.JPG
HC-06 + PIC16F1939.JPG (46.4 KiB) Viewed 14159 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by medelec35 »

SILVESTROS9 wrote:Dear medelec35,
many thanks for your help
You're welcome.
SILVESTROS9 wrote:C-06 red led flashes quickly 3-4 times/sec...it seems that there is no change from AT command to DATA mode, because there is no communication between mcu and BT module
No that's not the case at all.
I Did state
medelec35 wrote:With the HC06's I have they are automatically in AT command mode when not paired.
That's not strictly true.
It needs to be paired and Software with windows device e.g. Tera Term has to be connected to BT before it will go into data mode.
Hardware looks correct but what are you connecting to Device Input Port?
SILVESTROS9 wrote:about Android the problem is that the program runs only in windows.
So long as you have software that connects to bluetooth and sends ASCII data, does not matter if Andriod or Windows.
Either will work as I have used both.
Martin

SILVESTROS9
Posts: 115
Joined: Wed Aug 03, 2016 10:45 pm
Has thanked: 24 times
Been thanked: 11 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by SILVESTROS9 »

Dear medelec35,
thanks again for your help...about device is an electronic world clock that needs update perodically...what is wrong with data transfer? You said that that the code that you send me works at your HC-06...why not work for me? it's about different programming of my module? is there a way to test that? why don't use HC05/HC06 component to setup the module? finally is so difficult to send data with BT? another question...is it possible to run a windows program in android platform? thanks.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by medelec35 »

Hi SILVESTROS9,
Had a bit of time spare so took another look at your diagram.
It will not work with 2 devices connected to one UART channel.
For this to work, you need to choose a device with 2 separate UART channels.
Bluetooth on one channel and RTC on the other.
If you must for some reason keep 16F1939 then Bluetooth on software and RTC on the channel.
To find a suitable device you can look at the devices Steve001 compiled.
Or you can look at parts within Matrix's own database.
Just scroll to Program your embedded devices:
& click on the down arrow for UART.
Or you can look at Microchips Product selector
Change CPU Type to 8-bit PIC MCU
Then for UART select 2 in the left drop down box.

As for getting HC06 working.
Since you would have changed the target device to 16F1939, can you post the updated flowchart?
Have you completed a 1 sec flash test?
If that is working and only HC06 connected to MCU just use the change name for now.
Then you can use forget device on the tablet and then pair again to see if the name has changed.
Reason for not using HC05/06 component is the commands to change parameters are very different for HC05/06 devices as I have pointed out here.
So until the component is sorted out I used UART.
Do you have a USB to UART converter which you can connect to PC and microcontroller or Serial Bus Decoding equipment?
Martin

SILVESTROS9
Posts: 115
Joined: Wed Aug 03, 2016 10:45 pm
Has thanked: 24 times
Been thanked: 11 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by SILVESTROS9 »

Dear medelec35,
many thanks for your help...about HC-06 working, I send you the updated flowchart for PIC16F1939...The flasher test is ok, but nothing works for HC-06.....no change name , no change pairing code....I have no problem to change the mcu , just I used that to make a working test for HC-06....If BT module works, i'll use for harware a PIC18F24J50 that has 2 uart...is it possible to work the BT module with that cpu, or it's better to change with PIC18F24J50, make new connections and update the flowchart? what is your opinion? thanks.
Attachments
HC06 Name + Pairkey Changer 1c.fcfx
(16.83 KiB) Downloaded 237 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by medelec35 »

I'm a bit puzzled.
You have nothing connected to MCLR in your diagram, yet you state flasher is working OK.
You have 6 connections for BT and wired up 4.
how many pins is soldered on to your BT and is there a reset switch?
Martin

SILVESTROS9
Posts: 115
Joined: Wed Aug 03, 2016 10:45 pm
Has thanked: 24 times
Been thanked: 11 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by SILVESTROS9 »

Dear medelec35,
thanks for your help...about connections BT with mcu, I think that there is no need to use a resistor to pool HIGH MCLR pin of PIC16F1939...I connect 4 pins to BT as it shows at schematic....pin EN is data/at command according to HC-06 details for connection....for command mode I set this pin to HIGH....with an oscilloscope I have no data at pins RX, TX ...it seems that cpu don't send data with TX...I change cpu with a new one, but the same results... there is no RESET switch at BT at connection pins...that seems to works because it scanned from bluetooth as device HC-06....the red led indicates command mode...is there a mistake at flowchart? is it better to test an HC-05 ? what can I do to make a wireless connection between 2 devices? below I send you a post to get some info.thanks
https://forum.allaboutcircuits.com/thre ... 06.115145/
http://www.pictutorial.net/2015/10/how- ... -step.html

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by medelec35 »

SILVESTROS9 wrote: think that there is no need to use a resistor to pool HIGH MCLR pin of PIC16F1939
One the Flowchart you have got:
MCLR Enabled.png
(2 KiB) Downloaded 5613 times
Which means If MCLR is not pulled high then microcontroller will be permanently in the reset state.
So how comes the LED on your hardware was on for a seconds then off for a second?
If you have not cot MCLR pin connected, then you MUST selected Disabled for MCLR Pin Function
I asked about the pins since you had six on your circuit, so that would Be a HC05 which will rewire either switch pressing, or better still EN line pulled high, I would use a port to do that.
But as BT only has 4 pins, that's not required.
Just to double check, I downloaded flowchart you just posted, only changed Name and pair code to something different within the call macros, and change the name and pair code changed successfully.
New changed name of HC06 appeared when I selected forget connection and re-paired BT on my phone.
So its defiantly your set-up!
Do you have a USB to UART converter?
Martin

SILVESTROS9
Posts: 115
Joined: Wed Aug 03, 2016 10:45 pm
Has thanked: 24 times
Been thanked: 11 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by SILVESTROS9 »

Dear medelec35,
many thanks for help....about BT , I set Disabled MCLR Pin Function Select..I was checked wiring again...BT module has 6 pins (photo)...I was connected 4 pins and pin EN as LOW/HIGH to switching data/at command mode...pin STATE I don't know what it is....I made a new test, no results...it's very strange why don't work at my hardware....I have not USB to UART converter....As the code works at your hardware , I think that maybe there is a problem with programmer, or bad connection , because I use a breadboard to make tests...I'll check that...thanks.
Attachments
20180727_182146.jpg
20180727_182146.jpg (39.38 KiB) Viewed 14042 times
20180727_182102.jpg
20180727_182102.jpg (40.73 KiB) Viewed 14042 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by medelec35 »

State is just an output that is high when there is an established connection.
Do you have an LCD you can use that for diagnostics?
Your hardware is different to mine.
I have both HC05/06 from a few different suppliers.
All HC05 are 6pin with an enable switch + enable state pins that must have enable pin high and 38400 baud for AT commands to be accepted if not being accessed
All HC06 have 4 pins an in AT mode if not being accessed.
Perhaps you could get hold of the standard 4 pin HC06?
I don't believe I can help you any further unless you have an oscilloscope?
Martin

SILVESTROS9
Posts: 115
Joined: Wed Aug 03, 2016 10:45 pm
Has thanked: 24 times
Been thanked: 11 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by SILVESTROS9 »

Dear medelec35,
I would like to thank you for your efforts...yes I have an oscilloscope (Rigol DS-1054), also LCD 4x20...I made some changes to lcd component and I connect LCD ...i get the info as below...about BT module, it seems that my module is HC-05....I have no module with 4 pin...Ι get some measurements at RX, TX pins with Rigol but no data..is there a way to test that ? thanks.
Attachments
20180727_233720.jpg
20180727_233720.jpg (100.38 KiB) Viewed 14025 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by medelec35 »

The difference between HC05 (EN connected to +5V) and HC06 when power is first established.
HC05 LED will go on and off every 2 seconds, that's what mode you need to be in.
If that is the case then I can send you an updated flowchart to change parameters.
HC06 LED will go on and off about 4 times a second.
So there is a big difference.
However with HC05, if nothing is connected to EN then LED will go on and off about 4 times a second.
That's the same as HC06 but commands will not work as it's not in AT mode.

After all the above, can you determine which module you have
SILVESTROS9 wrote:I would like to thank you for your efforts
Not a problem.
Clicking on the thumbs up (Far right Icon at the top of my posts) is sufficient.
SILVESTROS9 wrote:yes I have an oscilloscope (Rigol DS-1054)
I have the same scope.
Great scope for the cost.
4ch plus serial decoding:
DS1Z_QuickPrint3.png
(42.04 KiB) Downloaded 5553 times
I have attached Flowchart that works with HC05
Attachments
HC05 Name + Pairkey Changer 1a.fcfx
(17.92 KiB) Downloaded 208 times
Martin

SILVESTROS9
Posts: 115
Joined: Wed Aug 03, 2016 10:45 pm
Has thanked: 24 times
Been thanked: 11 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by SILVESTROS9 »

Dear medelec35,
I think that my BT module is HC-06, but not work, I don't know why...maybe there is a mistake to hardware but what? is there a way to test it? would you like to inform me for your connections in your hardware and with what flowchart the HC-06 works? is there some photo of your module?thanks.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by medelec35 »

Sorry, not seen this post.
Are you sill having problems?
I can send you links where I bought my modules from, as not had issues with any of them.
Do you still require a diagram?
Martin

SILVESTROS9
Posts: 115
Joined: Wed Aug 03, 2016 10:45 pm
Has thanked: 24 times
Been thanked: 11 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by SILVESTROS9 »

Dear medelec35,
sorry for delay, but i've some problems with internet connection. About bluetooth modules , my supplier not give me info about modules, the 2 modules HC-05 and HC-06 that he was give me to test, is the same as hardware. if there is data sheet for both , or diagram to understand the differences will be useful. I think that the 2 modules is HC-06, so your code not work.Do you have a tested code for HC-06? Thanks.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BLUETOOTH MODULE NOT WORK

Post by medelec35 »

It's easy to test communications side.
Make sure you have only the bluetooth connections to RX and TX of microcontroller.
Pair mobile or PC to BT. Send repeated U (must be uppercase)
Develop flowchart so you either have an LCD or UART to USB lead so you can see received characters.
If neither then use an LED then if received a string = "U" or char = 85 the pin connected to LED goes high.
THe reason for U is if RX is displayed on the scope then you will see alternate 1's and 0's
Since all the same width then Baud = 1/time.
Sounds like you have an issue with hardware.
SILVESTROS9 wrote:Do you have a tested code for HC-06? Thanks.
The two flowcharts posted is confirmed working with both HC05 and HC06.
Martin

Post Reply