Using HC-05 leads to USB programming out-of-sync

I connected my HC-05 bluetooth module to Arduino Nano as most tutorials suggest (ie, Arduino[TX] to HC-05[RX] using a voltage divider to reach ~3.3V and HC-05[TX] to Arduino[RX])
The issue I'm having is that when I try to program it using USB, I get:

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x45

until it fails

If I disconnect the Arduino[RX] pin, then it works; so I suspect HC-05 is trying to transmit something even when it's not connected to anything.
Is there a way to make it work? ie, use Arduino RX/TX connected to the bluetooth module but still be able to program it using USB?

Thanks

I connected my HC-05 bluetooth module to Arduino Nano as most tutorials suggest (ie, Arduino[TX] to HC-05[RX] using a voltage divider to reach ~3.3V and HC-05[TX] to Arduino[RX])

Is that really what the tutorials advise ?

The Tx and Rx pins are used by hardware Serial and to upload the code to the Arduino. Hence your problem. Either disconnect the HC-05 from the pins when uploading a program or investigate the use of the SoftSerial library which allows you to choose which pins to connect the HC-05 to

most tutorials suggest also to disconnect the HC-05 whilst uploading code....

UKHeliBob:
The Tx and Rx pins are used by hardware Serial and to upload the code to the Arduino.

Also, from when we thrashed this out a few weeks ago on my project, the USB on a nano stays connected to Arduino TX and more importantly RX, and apparently cannot be disconnected without physically modifying the board. As such, hour bluetooth device will need to overpower its signal.

I'd suggest AltSoftSerrial instead of SoftwareSerial, but this does restrict you to pins *&9.

I'm trying to avoid software serial because apparently it isn't as reliable as hardware one for a baud rate higher than 19200.
Is it possible to make programing work still connected to HC-05? Maybe a transistor that disconnects it when arduino reset is triggered?

Thanks

Your issue isn't just the HC-05, though. You still have a USB chip writing to the pin.

I experimented with powering an AT-09 from an output pin (the current allows this), but it pulls in parasitic power through it's RX; you have to cut it off from ground, too (instead?).

AltSoftSerial is more reliable than SoftSerial, particularly as you increase speed.

I have a pile of minis waiting to implement this on (but first I need to switch them to 3.3v. I accidentally ordered a dozen or so 5v . . )

lem0nhead:
I'm trying to avoid software serial because apparently it isn't as reliable as hardware one for a baud rate higher than 19200.
Is it possible to make programing work still connected to HC-05?

No, it isn't, and you are right, while it may not necessarily be a problem, there is no such thing as a software serial that is a good idea. The solution is to disconnect the HC-05 while programming/debugging - by whatever means. You may have a good reason for not doing this, but you probably don't. Further, using hardware serial for comms means that you have the advantage of proving your code without bluetooth connected, as you can use the serial monitor as a stand-in.

Software serial is a vehicle of last resort and a refuge for the lazy and incompetent, which they may ultimately regret. The only time you need to use it is when you have more than one serial peripheral in your project - in which event, getting a Mega might be a rather good idea.

Having said that, the best defense for using software serial is that you don't need the operations speed of hardware serial, you just think you do. When I grew tired of downloading data files off SD at 9600 and reset to 115200 because the files were too big, the real solution was to stop recording junk.

Nick_Pyner:
Software serial is a vehicle of last resort and a refuge for the lazy and incompetent, which they may ultimately regret. The only time you need to use it is when you have more than one serial peripheral in your project - in which event, getting a Mega might be a rather good idea.

But is there a way to disable the USB port connection to RX on boards with onboard USB/programming?

My understanding from the last round of this is that you are stuck with the output of the USB converter being connected, and that it will remain in contention for the input.

I have installed a jumper on a proto shield in order to disconnect power to bluetooth while reprogramming Uno in the field. This really wasn't such a bad precaution, but I have never used it. Other than that, I'm not sure I understand what you are talking about, or why you would want to do that - or even what the last round was.

https://forum.arduino.cc/index.php?topic=584259.msg3981939#msg3981939

Particularly comment #8, I suppose:

"The RX pin expects a high as the idle state. So it's not very likely the the USB-to-TTL will not drive its TX pin high "

We're past my modern chip knowledge here; my naive assumption was and would be that that high would be achieved by an open connection from the USB circuit and a pull-up in the Arduino.

Well, I see I participated in that but I'm afraid I have nothing more to offer over my replies #2, #4., i.e. you are trying to make the problem bigger than it really is. I have no comment on reply #8 other than noting the words "risk" and "possible", and that I haven't seen any evidence of either, to the point where I can dismiss them as idle speculation, but I guess I am just as inclined to pull all connectors off HC-05 as just the 5v. I 'm not familiar with AT-09, and I only allude to HC-0x. I see that it is a BLE device. I'm not sure that makes a difference.