Programming over bluetooth not in sync error

I was following a tutorial to program arduino over bluetooth.

This is what I have done:

Installed latest arduino software.

Setup hc-05 module with the following commands: AT+ORGL AT+ROLE=0 AT+POLAR=1,0 AT+UART=115200,0,0 AT+INIT

This resets to factory settings, sets it as salve module and sets baud rate.

Here might be the first issue. I have first tried baud rate of 9600 to match my arduino baud rate. With 9600 baud rate I was able to open arduino serial console and see serial output from my arduino Pro mini printed. I was suggested elsewhere that this baud rate does not need to match arduino baudrate and should remain at 115200 but with this baud rate I get no serial output. How does this work?

Another issue is that the diagram shows pin 32 of hc-05 needs to be connected to arduino rst pin. I have done that but got not in sync error. The diagram shows a 1uf capacitor and 2 resistors. If I understand correctly 2 resistors are to reduce voltage to 3V from 5V. I dont need them since my arduino outputs 3.3V already. Am I right in thinking this?

I did not have 1uf capacitor so I recovered a 140nf SMD cap from scrap pcb. I still got the same issue when trying to program. What is the purpose of this cap and does it need to be 1uf? I also tried 10uf cap with same results. With rst pin connected my arduino resets when serial console is opened or when programming.

Can anyone see any causes of the not in sync error?

I did some more testing and here's what I found:

With hc-05 module baud rate set at 9600 and direct pin 32 to rst connection I get first few lines of output in the serial console then nothing presumably due to it resetting constantly or something similar. With the 140nf capacitor connected between pin 32 and rst pin on arduino the serial console prints all values as normal. So it seems the capacitor is doing something but still can't program. When I try I get this error:

avrdude: stk500_getsync(): not in sync: resp=0x4c

this is a little different from the error I got with 115200 baud rate. "resp=0x4c" was "resp=0x00" then.

Hi dominicm, I am messing with programming Arduino over Bluetooth as well and looked at the same article. I believe one of your issues is potentially with the baud rate setting of the BT module. I believe if you are programming an Arduino Pro Mini (with the Atmega 328p chip) you need to set the rate at 57600. See here, for the results of my digging around on the subject:

If you have the 3.3V, 8 MHz version of the Pro mini, you are correct to assume you do not need the two resistors for the voltage divider.

I believe the capacitor is there to adjust the timing of the reset. You might be able to use other values successfully as well, but better find some 1uf caps, if you want to be sure. I was able to manually trigger the reset - pushed the reset button as soon as the IDE message changed to "Uploading..." and the LED on my Bluetooth module indicated a connection was established. Of course that somewhat defeats the purpose of this, but it helps to test out the BT communication.

I am taking a different approach on the resetting though, once I verify it works I will post it as well. The idea is to use a 555 timer in mono-stable mode to do the reset.

Aha! You are correct. It seems like it was the baud rate. After changing baud rate even works with 140nf cap. It will probably work with other significantly different values too. The reset pin worked like you said also. That article was a really nice find, I would have never considered different arduinos program at different baud rates!

I have also skipped soldering to pin 32 and instead removed the resistor between pin32 and led breakout pin and connected rst pin to that. Not sure if it would work with the resistor in place. Might be useful to you if you are soldering it directly to pin 32 now...

One issue though, I am not getting serial output(Serial.print) any more, is it possible to get serial output and be able to program arduino or is it one or the other?

What are you trying to achieve with the timer btw? Cant think of functionality that you would gain, so enlighten me :)

Glad to hear you got it working!

The issue with set up in the Make article is that the BT module can only be used to program the Arduino. As soon as it pairs with the PC, the reset will be triggered by the Bluetooth module LED pin.

I am triggering the reset from software, no hacking the BT module. Essentially, in software I keep track of the "mode": programming, or communications (default). If in programming mode, once I detect incoming serial data, I trigger the reset by pulling a digital pin low. Here is where the 555 timer comes in. Apparently, resetting the Arduino using one of its own pins is not a good idea (specified by the Atmel support and discussed elsewhere on this forum). So I have an Arduino digital pin trigger a 555 timer in monostable mode (one shot mode). Simpler set-up using just a 1uf cap between the digital pin and the reset pin also works, but I wanted to try the 555 timer IC anyway.

If in communications mode, I just use the Bluetooth module as usual. Sending a specific command (like "P" in my case) switches to programming mode. Hope that helps.

This is exactly the idea I had about keeping the mode in a variable :) Though I am not sure if it's required in my case. Yes, you are right arduino resets when pairing but only once so it's not a huge deal at least for now.

I was able to get serial output as well ( it was an issue with my code). The only problem now is that the baud rate of arduino needs to be set to 57600 to match bt module. A high baud rate is not very reliable with bt modules especially over longer distances. Any thoughts on this? With 9600 baud rate it seems I was able to get about 7meters range with a couple of walls in between but could not connect again at that distance so range is a bit of an issue here... Higher baud rate may make it more unreliable due to corruption.

In any case would love to see your setup whenever you can share it. I wouldn't want to use a timer as that's just an extra component but if I can fix the resetting issue with just a cap that would be great!

want to try to introduce android app to programming Arduino Uno via bluetooth, simply by adding Bluino_Shield to your Arduino Uno. This link app