PIC and HC05


+ Reply to Thread
Results 1 to 10 of 10

Thread: PIC and HC05164 days old

  1. #1
    Junior Member Gerard's Avatar
    Join Date
    Aug 2013
    Posts
    30
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    92.40 MB

    0 Not allowed!

    Default PIC and HC05

    Hello,
    How can I send text to a pic from my smartphone with an HC05 module?
    Thank you in advance,
    Gerard

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Member keytapper's Avatar
    Join Date
    Jun 2019
    Posts
    104
    Thumbs Up
    Received: 4
    Given: 3
    Total Downloaded
    319.88 MB

    0 Not allowed!

    Default Re: PIC and HC05

    That's easily achieved by setting a serial interface to the HC-05. It will depend whether you want to use the hardware module or a software serial emulated one.
    So just to make sure you will set the proper baud rate to communicate to the module.

    This is demonstrating the operation with an HC-06 and a 12F675. The HC-05 is a bit different which offer more features, but both module can work with a serial communication.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    Junior Member Gerard's Avatar
    Join Date
    Aug 2013
    Posts
    30
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    92.40 MB

    0 Not allowed!

    Default Re: PIC and HC05

    I made a display with LED matrices controlled by MAX7219. I wish I could change the text that scrolls from my smartphone with a link by HC05 or HC06.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #4
    Member flosigud's Avatar
    Join Date
    Oct 2013
    Posts
    160
    Thumbs Up
    Received: 8
    Given: 13
    Total Downloaded
    3.13 GB

    0 Not allowed!

    Default Re: PIC and HC05

    For starters you can treat the HC05 as any other 9600 bps serial port. It is however a serial tranceiver with lots of capabilities. The datasheet might be an interesting read.
    Flosi Guūmundsson
    ReykjavŪk

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #5
    Member Frizie's Avatar
    Join Date
    Apr 2003
    Posts
    174
    Thumbs Up
    Received: 2
    Given: 1
    Total Downloaded
    741.23 MB

    0 Not allowed!

    Wink Re: PIC and HC05

    The HC05 (Bluetooth transmitter + receiver) and HC06 (Bluetooth receiver only) are cheap and very nice modules to make wireless communications between PIC's or a PIC and a smartphone.
    The PIC side is not the most difficult, you will also have to make an app.
    I am also currently working on Bluetooth (HC-05), which is going to have to arrange communication between an Android smartphone and a PIC, so if I have a compact example, I will put it in the Wiki.

    However, don't hurry, I am very busy with several projects.
    And 9600 Baud is not the limit, it can much faster.

    Frizie.
    Ohm sweet Ohm: www.picbasic.nl

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #6
    Junior Member Gerard's Avatar
    Join Date
    Aug 2013
    Posts
    30
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    92.40 MB

    0 Not allowed!

    Default Re: PIC and HC05

    Hello,
    I downloaded the bluetooth electronics app and I will try to communicate the smartphone with a PIC until you have advanced in your projects.
    Thank you in advance.
    Gerard.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #7
    Junior Member Gerard's Avatar
    Join Date
    Aug 2013
    Posts
    30
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    92.40 MB

    0 Not allowed!

    Default Re: PIC and HC05

    Hello and happy new year to everyone,
    I downloaded serial bluetooth and I would like to communicate with a 16F876. The link with the HC05 module works, but I cannot use the HSERIN instruction.


    Thanks in advance.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #8
    Member keytapper's Avatar
    Join Date
    Jun 2019
    Posts
    104
    Thumbs Up
    Received: 4
    Given: 3
    Total Downloaded
    319.88 MB

    0 Not allowed!

    Default Re: PIC and HC05

    You should prepare the registers to the correct baud rate, which is supposed to be 9600 by default.
    So just consult the manual to setup the baud rate for your PIC.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #9
    Junior Member Gerard's Avatar
    Join Date
    Aug 2013
    Posts
    30
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    92.40 MB

    0 Not allowed!

    Default Re: PIC and HC05

    Hello,
    The transmission between HC and PIC works well at 9600 baud. I don't know how to process information with HSERIN.


    Thank you for your help.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #10
    Member keytapper's Avatar
    Join Date
    Jun 2019
    Posts
    104
    Thumbs Up
    Received: 4
    Given: 3
    Total Downloaded
    319.88 MB

    0 Not allowed!

    Default Re: PIC and HC05

    OK here a little example
    Code:
    Config INTRC_OSC_NOCLKOUT, WDT_OFF, MCLRE_OFF
    
    Device 12F675
    Declare Xtal 4
    Symbol GPIF = INTCON.0       ' Port Change Interrupt Flag
    Symbol T0IF = INTCON.2       ' TMR0 Overflow Interrupt Flag
    Symbol T0IE = INTCON.5       ' TMR0 Overflow Interrupt Enable
    Symbol PEIE = INTCON.6
    Symbol GIE = INTCON.7        ' Global Interrupt Enable
    Symbol GPIE = INTCON.3       ' GP Interrupt Enable
    Symbol TXDPIN 0              ' Trasmitting pin
    Symbol RXDPIN 1              ' Receiving pin
    Symbol OUT0PIN 5             ' output 0 pin definition
    Symbol OUT1PIN 4             ' output 1 pin definition
    Symbol true = 1              ' Boolean value
    Symbol false = 0             ' Boolean value
    Symbol tmrset = 99           ' Setting for internal clock
    Symbol BUFLEN = 6            ' The buffer where to store the received command
    Symbol bufspace = BUFLEN -1
    
    ' Definitions:
    ' command A, L and T0 are related to PORT0 which will operate on GPIO,OUT0PIN
    ' this is GP2 in this program
    
    ' command B, R and T1 are related to PORT1 which will operate on GPIO,OUT1PIN
    ' this is GP4 in this program
    
    Symbol TXD GPIO.TXDPIN       ' pin assigned for trasmission
    Symbol RXD GPIO.RXDPIN       ' pin assigned for reception
    Symbol out0 GPIO.OUT0PIN
    Symbol out1 GPIO.OUT1PIN
    
    Dim tmr_state0 As Bit        ' timer start/stop flag
    Dim tmr_state1 As Bit        ' timer start/Stop flag
    Dim port0 As Bit             ' temporary flag for the output
    Dim port1 As Bit             ' temporary flag for the output
    Dim zeroX As Bit             ' flag for 1 second ticking
    Dim buffer[BUFLEN] As Byte   ' buffer to store the input characters
    Dim x As Byte                ' spare variable
    Dim i As Byte                ' spare variable
    Dim y As Word                ' spare variable
    Dim z As Byte                ' spare Variable
    Dim timers0 As Word          ' word to hold the first timer counting
    Dim timers1 As Word          ' word to hold the second timer counting
    Dim ticks As Byte            ' 10 msec counter
    $define MAXLIMIT $ffff
    On_Interrupt GoTo ISR
    
    TRISIO = 0                   ' All outputs
    OPTION_REG = 5               ' The options to set timer0 with 64 prescaler
    T0IE = 1                     ' Timer0 interrupt enabled
    ticks = 0                    ' 1/100 sec counter, reset
    Output out0                  ' and the outputs
    Output out1
    Clear port0                  ' outputs cleared
    Clear port1
    CMCON = 7                    ' no comparators
    Clear ANSEL                  ' no analog inputs
    Set T0IE                     ' Timer0 interrupt enabled
    Clear ticks                  ' 1/100 sec counter, reset
    GIE = 1                  ' General interrupt flag enable, accepting interrupts
    While 1 = 1              ' neverending loop
    wait4char:
        If zeroX = true Then
            GoSub chktimers      ' while wait for input, see if a timer is out
            zeroX = false
        EndIf
        SerIn RXD, 813,1000, wait4char, [Str buffer] ' wait for the buffer
        x = buffer[0]            ' first character
        Asm-
        Movlw 1                  ; if is zero
        Btfsc _x,5               ; test whether the letter is upper case
        Clrw 0
        Bcf _x,5                 ; convert to upper case
        Movwf _i
        Endasm-
        Select x
            Case = "T"           ' if character T, set the wanted timer
            GoSub set_timer
        EndSelect
        SerOut TXD, 813, [13, 10, " OK", 13, 10]
    Wend
    
    ISR:                         ' Interrupt Service Routine
        Context Save             ' save the registers
        If T0IF = true Then      ' the timer0 overflowed ?
            TMR0 = tmrset        ' then reload its count
            T0IF = false         ' remove the flag
            If ticks < 101 Then  ' when the count reach 100, it's reset to zero
                Inc ticks        ' else it'll increase
            Else
                Clear ticks       ' reset
                Set zeroX
            End If
        End If
    Asm-                               ; final. It changes the outputs
        Btfsc port0                    ; is port0 clear?
        Bsf out0                       ; no, set the GPIO out0 and jump over
        Btfss port0                    ; is the port0 set?
        Bcf out0                       ; no, clear the GPIO out0 and jump over
        Btfsc port1                    ; is port1 clear?
        Bsf out1                       ; no, set the GPIO out1 and jump over
        Btfss port1                    ; is the port1 set?
        Bcf out1                       ; no, clear the GPIO out1 and jump over
    Endasm-
        Context Restore          ' resume registers after completion
    
    chktimers:
        If tmr_state0 = 1 Then         ' if the flag is set
           If timers0 <> 0 Then        ' and the timer has a value
              timers0 = timers0 -1     ' count it down
           Else
             tmr_state0 = 0            ' else the count is ended
             port0 = 0                 ' and turn of the output
           End If
        End If
        If tmr_state1 = 1 Then         ' same as per timers0
           If timers1 <> 0 Then
              timers1 = timers1 -1
           Else
              tmr_state1 = 0
              port1 = 0
           End If
        End If
    Return
    
    read_word:
        x = 1
    
    scanbuf:
        y = 0
        For i = x To bufspace    ' by the second character check for digits
            z = buffer[i] - 48   ' converting into binary
            ' any non digits will stop to calculate and it's over
            If z > 9 Then Break
            y = y * 10 + z       ' calculate previous value *10 + the current value
        Next i
        $if _defined (ENCODER)
         If y > ENCLIMIT Then
            y = ENCLIMIT ' only when MAXLIMIT is smaller than 65535
         End If
         If y < DRIFT Then
            y = DRIFT
         End If
         $elif MAXLIMIT < $ffff
         If y > MAXLIMIT Then y = MAXLIMIT ' only when MAXLIMIT is smaller than 65535
        $endif
    
        Return
    
    set_timer:
    ' Subroutine to read the input buffer and set a timer according the second byte
    ' in the buffer
        x = 3
        GoSub scanbuf
        x = buffer[1] - 48       ' this will set the wanted timer
        If x > 1 Then Return     ' Not compatible choice
        i = buffer[2]            ' Second char, to see what magnitude is inputted
        @ Bcf _i,5               ' convert to upper case
        Select i
            Case = "M"           ' if minutes, multiplier is 60
            y = y * 60
            Case = "S"           ' if seconds, don't touch it
            @Nop
            Case Else            ' otherwise the result will be null
            Clear y
        End Select
        Select x
        Case = 0
            Set port0            ' set the output high
           Set tmr_state0        ' set the flag as running condition
           timers0 = y           ' load the timer0 counter
        Case = 1
            Set port1
            Set tmr_state1       ' set the flag as running condition
            timers1 = y
        End Select
        Return
    The MCU, will wait to get the buffer filled, then it will process the content.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. Very High speed coms between Master Pic- Slave pic (needed)
      By Tim in forum Proton Plus Compiler v3
      Replies: 28
      Last Post: 27th April 2016, 15:25
    2. Pic 16F1937 to 6 Analog input in Pic basic
      By Habro in forum Absolute Beginners Section
      Replies: 17
      Last Post: 18th December 2014, 20:38
    3. Galva-Wisp PIC programmer can program more PIC devices now
      By Frizie in forum Proton Plus Compiler v3
      Replies: 0
      Last Post: 25th November 2006, 00:13
    4. Serial data between 1 master pic & 8 slave pic
      By Roshan in forum Proton Plus Compiler v3
      Replies: 2
      Last Post: 23rd September 2005, 11:21

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts