Menu

Bluetooth connection issues

2017-11-20
2017-11-21
  • James McPherson

    James McPherson - 2017-11-20

    Hi, first off, thanks for this wonderful software. I'm using it on several astrophotography setups and it works VERY well.
    In my latest build, I'm trying to implement bluetooth and am having some connection issues. I'm using an HC-05 module and an appropriate firmware with bluetooth support.
    When the myFocuserPro2 software connects, it initially works, then at a seemingly random place times out waiting a response from the arduino. However it never gets to the point of being able to control a motor. It's always in the initial setup that it times out.
    I've set the seiral timeout to maximum at 30 seconds and the connection timeout to 10 seconds.
    It times out at a different command every time it's run, sometimes it makes it pretty far, some times it times out as early as the second read.
    When it times out, I can watch the red light on the bluetooth module go from solid red (connected) to blinking red (not connected).

    Now here is the odd part. If I connect to the same serial port via putty, I can happily send commands to the focuser at will, forever, and it always responds. :02#, :08#, :00#, etc... always works, and always comes back with a response immediately.

    Following is a typical run in the log file showing the disconnection.

    I tried a different power source thinking that was the problem. No luck, same issue. I can swap over to the COM port for the Arduino Nano that this is running on, and everything works well.

    Any ideas?

    Thanks again.
    -jim

    11/20/2017 2:44:55 PM: Load(): =START=========================================================
    11/20/2017 2:44:55 PM: App version: myFocuserPro2 ©RB Brown 2014-2016: 2.3.7.9
    11/20/2017 2:44:55 PM: setmytooltips(): =START=========================================================
    11/20/2017 2:44:55 PM: setmytooltips(): =END===========================================================
    11/20/2017 2:44:55 PM: Load: Adding comports to list
    11/20/2017 2:44:55 PM: Load: Setting Comport speed listbox
    11/20/2017 2:44:55 PM: Load: Setting Menu bar defaults
    11/20/2017 2:44:55 PM: Load: Setting custom or default colors
    11/20/2017 2:44:55 PM: SetCustomColors(): =START=========================================================
    11/20/2017 2:44:55 PM: SetCustomColors(): Set default colors
    11/20/2017 2:44:55 PM: SetCustomColors(): =END===========================================================
    11/20/2017 2:44:55 PM: Load: Initialize focuser settings
    11/20/2017 2:44:55 PM: TempOffsetTxtBox: = 0
    11/20/2017 2:44:55 PM: Before conversion TempOffsetVal: = 0
    11/20/2017 2:44:55 PM: After conversion TempOffsetVal: = 0
    11/20/2017 2:44:55 PM: Before Rounding TempOffsetVal: = 0
    11/20/2017 2:44:55 PM: TempOffsetVal range checked: = 0
    11/20/2017 2:44:55 PM: Load: Setting stepmode listbox
    11/20/2017 2:44:55 PM: Load: Setup default refresh timer settings
    11/20/2017 2:44:55 PM: Load: Initialize stats
    11/20/2017 2:44:55 PM: Load: Set menu defaults
    11/20/2017 2:44:55 PM: disableall(): =START=========================================================
    11/20/2017 2:44:55 PM: disableall(): =END===========================================================
    11/20/2017 2:44:55 PM: focuserLoad(): =END===========================================================
    11/20/2017 2:44:58 PM: Connect(): =START=========================================================
    11/20/2017 2:44:58 PM: ======CONNECT START TIME
    11/20/2017 2:44:58 PM: Windows Application Version Number: myFocuserPro2 ©RB Brown 2014-2016: 2.3.7.9
    11/20/2017 2:44:58 PM: Connect: Com Port Selected = COM23
    11/20/2017 2:44:58 PM: Connect: comportbaudrate: 115200
    11/20/2017 2:44:58 PM: Connect: Setting readtimeout to 20000
    11/20/2017 2:44:58 PM: Connect: Attempting to Open COMPORT COM23
    11/20/2017 2:45:02 PM: Connect: Check if serial port opened
    11/20/2017 2:45:02 PM: Connect: Comport=isOpen
    11/20/2017 2:45:02 PM: Connect: Serial port COM23 opened.
    11/20/2017 2:45:12 PM: Connect: Test to see if controller connected
    11/20/2017 2:45:12 PM: Calling CommandString(:02#)
    11/20/2017 2:45:12 PM: CommandString(): =START=========================================================
    11/20/2017 2:45:12 PM: CommandString: Serial Port is Open
    11/20/2017 2:45:12 PM: CommandString: Try to write command: :02#
    11/20/2017 2:45:12 PM: CommandString: Command was sent.
    11/20/2017 2:45:12 PM: ReceiveString(): =START=========================================================
    11/20/2017 2:45:12 PM: ReceiveString: Command retcmd = E
    11/20/2017 2:45:12 PM: ReceiveString: Buffer recbuf = EOK#
    11/20/2017 2:45:12 PM: ReceiveString: Value retstr = OK
    11/20/2017 2:45:12 PM: ReceiveString raw response for connected? was: EOK#
    11/20/2017 2:45:12 PM: ReceiveString(): =END===========================================================
    11/20/2017 2:45:12 PM: CommandString(): =END===========================================================
    11/20/2017 2:45:12 PM: Back from CommandString
    11/20/2017 2:45:12 PM: Connect: ConnectedState=true
    11/20/2017 2:45:12 PM: Connect: CONNECTED get parameters from controller
    11/20/2017 2:45:12 PM: Connect: Get MaxSteps
    11/20/2017 2:45:12 PM: Calling CommandString(:08#)
    11/20/2017 2:45:12 PM: CommandString(): =START=========================================================
    11/20/2017 2:45:12 PM: CommandString: Serial Port is Open
    11/20/2017 2:45:12 PM: CommandString: Try to write command: :08#
    11/20/2017 2:45:12 PM: CommandString: Command was sent.
    11/20/2017 2:45:12 PM: ReceiveString(): =START=========================================================
    11/20/2017 2:45:12 PM: ReceiveString: Command retcmd = P
    11/20/2017 2:45:12 PM: ReceiveString: Buffer recbuf = P0#
    11/20/2017 2:45:12 PM: ReceiveString: Value retstr = 0
    11/20/2017 2:45:12 PM: ReceiveString raw response for Getfocuserpos was: P0#
    11/20/2017 2:45:12 PM: ReceiveString(): =END===========================================================
    11/20/2017 2:45:12 PM: CommandString(): =END===========================================================
    11/20/2017 2:45:12 PM: Back from CommandString
    11/20/2017 2:45:17 PM: Connect: ERROR - NO RESPONSE/TIMEOUT
    11/20/2017 2:45:17 PM: disableall(): =START=========================================================
    11/20/2017 2:45:17 PM: disableall(): =END===========================================================
    
     

    Last edit: James McPherson 2017-11-20
  • brownrb

    brownrb - 2017-11-21

    Hi James
    We do not recommend running serial port at 115200. Bluetooth is fine at 9600. The software serial library that implements the interface with the BT adapter wont handle that reliably at all. The limitation is in the library.

    I need to know
    what arduino firmware file?
    Did you make any changes to file?

    This is so I can check file to see if there is any issue with code. It is not obvious from the logfile.

    Cheers
    Robert

    The logfile shows
    Try to write command: :08#
    This is call to get MaxSteps
    Answer it got was 0
    This is an invalid value for maxsteps
    Are you sure you set this correctly in the controller?

    So I suggest test this manually without app.
    I would suggest start arduino IDE and connect to controller using serial monitor window
    send
    :0732182#
    to the controller
    next send
    :08#
    to the controller - it should respond with M32182#

    But I recommend you use 9600 and I suspect it will burst into life.
    I am also hoping you did not change the pin numbers for the BT connection - only certain pins can be used. This is just as crucial.

     

    Last edit: brownrb 2017-11-21
  • James McPherson

    James McPherson - 2017-11-21

    Robert,
    Thank you! That did it. 115200 was the default for my HC-06 bluetooth module, that's why I changed the baud rate. I had to use AT commands to set the HC-06 back down to 9600, but when I did that everything started working perfectly.

    Thanks again!
    -Jim

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.