Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Bluetooth module HC-06

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
balou

Bascom Member



Joined: 14 Apr 2007
Posts: 36

netherlands.gif
PostPosted: Thu Feb 06, 2020 8:45 pm    Post subject: Bluetooth module HC-06 Reply with quote

Hello,

Is it possible to change the name and password with a "Bluetooth module HC-06" with a Bascom AVR program ?
Balou.



(BASCOM-AVR version : 2.0.8.2 )

_________________
Bascom-AVR 2.0.8.5
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Thu Feb 06, 2020 8:56 pm    Post subject: Reply with quote

sure. use the AT+NAME command of the BT module.
And to change the pwd use AT+PIN. It is explained in the HC-06 datasheet.

In bascom use PRINT to send data. And use either INPUT or INKEY/WAITKEY to fetch data from the module.

you did connect the module TX/RX to the AVR processor right?

_________________
Mark
Back to top
View user's profile Visit poster's website
balou

Bascom Member



Joined: 14 Apr 2007
Posts: 36

netherlands.gif
PostPosted: Thu Feb 06, 2020 9:28 pm    Post subject: Reply with quote

Hello Mark,

I have read the datasheet.
The BL module is connected to an Atmega328P board, TR-RX, RX-TX.
My question is how I can change the password without using a Terminal program.
I want to use an AT command with a Bascom program.

Balou.

_________________
Bascom-AVR 2.0.8.5
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Thu Feb 06, 2020 9:40 pm    Post subject: Reply with quote

I do not see what the problem is. you also do not mention what you have tried.
but you connected the AVR to the HC06. so that should be ok.

my suggestion would be :
- first connect the HC to a PC and terminal so you can play with all AT commands. this way you can test the baud rate too.
but lets assume you did so.
- the AVR can simply send data using PRINT : PRINT "AT+PIN1234"
That will set the PWD to 1234
The default baud is 19200 so the AVR should have CONFIG COM=19200, .... as well

you can always mention what you tried, what HW you use and what it is you want to accomplish.

_________________
Mark
Back to top
View user's profile Visit poster's website
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 971

poland.gif
PostPosted: Fri Feb 07, 2020 2:24 am    Post subject: Reply with quote

Some modules must be powercycled with KEY pin to entering into the AT Commands so hardware for changing name or PIN "In the fly" must be some more complicated.
Back to top
View user's profile Visit poster's website
balou

Bascom Member



Joined: 14 Apr 2007
Posts: 36

netherlands.gif
PostPosted: Fri Feb 07, 2020 1:27 pm    Post subject: Reply with quote

I want to use this program to change the password.
BL is in Program mode, LED blinks every 2 seconds.
Password has not changed.
What am I doing wrong?

Balou.


'**** Pin change BL HC-05 **

$regfile = "m328pdef.dat"
$crystal = 8000000
$hwstack = 150
$swstack = 150
$framesize = 150


Config Com1 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Serialin = Buffered , Size = 254
Config Serialout = Buffered , Size = 254

'** HC-05 ** Pin changed ***

waitms 500

Print"AT+PIN0000"

waitms 500

End

_________________
Bascom-AVR 2.0.8.5
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 971

poland.gif
PostPosted: Fri Feb 07, 2020 1:43 pm    Post subject: Reply with quote

If you use Serialin or Serialout that means that Serial is buffered and receiving and sending will be processed in the background and also, this is important, with Interrupts.

So you must Enable Interrupts for Serialin or Serialout Very Happy

If you comment/remark line "Config Serialout ..." code should work too Very Happy
Back to top
View user's profile Visit poster's website
balou

Bascom Member



Joined: 14 Apr 2007
Posts: 36

netherlands.gif
PostPosted: Fri Feb 07, 2020 2:19 pm    Post subject: Reply with quote

Still not working, different boudrates tested.
Also tried with the HC-06.


'**** Pin change BL HC-05 **

$regfile = "m328pdef.dat"
$crystal = 8000000
$hwstack = 150
$swstack = 150
$framesize = 150

Config Com1 = 38400 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Enable Interrupts '** Bluetooth **

'** HC-05 ** Pin changed ***

waitms 500
Print"AT+PIN0000"
waitms 500

End

_________________
Bascom-AVR 2.0.8.5
Back to top
View user's profile
six1

Bascom Expert



Joined: 27 Feb 2009
Posts: 553

germany.gif
PostPosted: Fri Feb 07, 2020 2:22 pm    Post subject: Reply with quote

$baud=9600

'Change name of HC06
' for changing, uncomment two print lines.
' press button on HC06 modul and hold, while starting ATMega. After 3 Seconds, relase button; done...
'Print "AT+NAME=New Name"
'Print "AT+PSWD=0000"

_________________
For technical reasons, the signature is on the back of this message.
Back to top
View user's profile
balou

Bascom Member



Joined: 14 Apr 2007
Posts: 36

netherlands.gif
PostPosted: Fri Feb 07, 2020 2:42 pm    Post subject: Reply with quote

This should be it?
Still not working.



'** HC-05 ** Pin changed ***

print
print

Print"AT+PIN0000"

_________________
Bascom-AVR 2.0.8.5
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Sat Feb 08, 2020 4:33 pm    Post subject: Reply with quote

when something does not work you need to start at the begin.
So very first thing you need to check is the module : does it even work?
So connect it to a PC using a virtual COM port like a FT232. Or use a MAX232 and connect to a real COM port.
Then run the bascom terminal emulator, or any other terminal emulator. ANd select the COM port.
Also set the BAUD. usually it is best to start at 9600.
Then try 19200, etc.

the type AT followed by a RETURN and you should get data back like OK
Then you know the module is ok and you know the baud.

you can also test setting the PWD and or name then.
So make sure it works using a terminal before you perform the same using a micro.

_________________
Mark
Back to top
View user's profile Visit poster's website
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2156

netherlands.gif
PostPosted: Mon Feb 10, 2020 8:53 am    Post subject: Reply with quote

Keep in mind that the Bluetooth module HC-06 runs on 3.3V
Don't know where your AVR is running on, but level shifting for the TX line is preferable. RX doesn't matter, the AVR will not have a problem with that everything above 2V will be seen as logic 1.

If you have the module on a caring board with voltage regulator etc. it should work fine on 5V.

_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
balou

Bascom Member



Joined: 14 Apr 2007
Posts: 36

netherlands.gif
PostPosted: Thu Feb 13, 2020 11:58 am    Post subject: Reply with quote

Thank you for the response.
I know that the HC-06 works at 3.3V.
I use an level shifting for the TX line

_________________
Bascom-AVR 2.0.8.5
Back to top
View user's profile
altron

Bascom Member



Joined: 10 Mar 2008
Posts: 10

australia.gif
PostPosted: Wed Mar 04, 2020 7:59 am    Post subject: Reply with quote

Are you putting in the "=" sign?

As others have stated already?

Print "AT+PSWD=0000"

not

Print "AT+PSWD0000"
Back to top
View user's profile
snow

Bascom Member



Joined: 28 Jun 2005
Posts: 200
Location: Ashburton / Mid Canterbury / New Zealand

newzealand.gif
PostPosted: Tue Mar 24, 2020 4:53 am    Post subject: Reply with quote

When programming the HC-05 from scratch with power cycle button.You must use baud rate 38400 to accept AT commands.
I use these for a product i make and program the HC-05 before mounting
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum