Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC18f4550 and Bluetooth HC-06

Status
Not open for further replies.

CrewColombia

Newbie level 1
Joined
Jan 29, 2016
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
18
Hi everyone!

I want to make a simple test with my PIC18F4550, bluetooth module HC-06 and the computer. I mean, I want to sent a simple caracter from the PIC to the PC using the bluetooth module.

But I'm having struggles on do this. My code...can somebody help me finding my mistake?



Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <18f4550.h>
#include <stdio.h> 
 
#fuses XT, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP, NOCPD, NOWRT
 
#use delay (clock=4000000)
 
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, bits=8, parity=N)
 
 
void main ()
{
 
  while (1)
    {
    printf("A");
    
    }
}

 
Last edited by a moderator:

But I'm having struggles on do this. My code

What do you mean by this, it's happening compilation error/warning ?
Isn't sending anything to the serial port ?

BTW, I particuarly would add a small delay after each transmission, but not sure how this could affect the overal working, Anyway, lacks for more details.
 

Agreed! I'm not sure which compiler is being used but I doubt "printf" is sending anything to the HC-06.
USB functions are needed if you want to use the USB port and serial functions for the MSSP (USART) port.

Brian.
 

the code is from https://www.ccsinfo.com/ compiler.
i know because i was once using that compiler.

Code:
while (1)
    {
     printf("A");
     delay_ms(1000); // <-------- Put a delay
    }
 

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, bits=8, parity=N)
[/syntax]

This line of code is enough in CCS to set up UART and printf can be used to txmit characters.
but you have to add a delay in the loop. Make sure baud rate of the module is 9600.
 

you need to seed the data via UART to the HC-06 (RX,TX) and you need to connect the device to you pc before make communication. the easy way is with RealTerm to send your commande code to your HC-06 and get your connection after plug it in your project. It will save the config so it will auto connect after that
 

You have to connect Tx pin of PIC to Rx pin of BT module after level converting. PIC UART Tx pin works at 5V and BT modules Rx pin can only tolerate 3.3V. So, drop the voltage to 3V and feed it to BT's Rx pin. Also you have to connect GND of PIC Circuit to GND of BT module.
 

Attachments

  • VLT.png
    VLT.png
    13.2 KB · Views: 118
Last edited:

hello,


your code is too simple ... and you need to add a terminateur CR or LF at the end of message to send to your distant device.
i recently wrote gain a little application to test Appinventor2 ( i allready tested with Appinventor1 , but it is now, obsolete)
with a PIC18F2550 , it's include an init of the HC06 device ,before using it
and do exchange of data (in both way) with distant BT device (Tablet Archos).
**broken link removed** (with MikroC code)

nota: some HC06 are 5V tolerant...it must be writtent on it, else it is 3,3V only..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top