programming arduino with bluetooth.

A while ago I posted this post

So I want to upload programs to an arduino using BT modules. I have now finally made a new shield for between my ethernet shield and my arduino mega.

The problem I am having is that I have found like 3 different circuits of bluetooth -> arduino connections for wireless programming. Everything was clear to me but one thing!

I don't know what to do with the arduino reset pin.

I made my shield according to this website:

In this circuit the arduino reset is connected to a voltage devide, providing a voltage at 3.33V, which is high enough to keep the arduino out of reset. And it is connected to Pin 32 of the hc-05 module via a 100nF capacitor, I believe that pin 32 is connected to the status led. When this module has a connection the LED is on and blinks off every few seconds (you can do that with the AT POLAR command).

The 2nd circuit I got from a reply on my previous post: . In this circuit I see that the reset line has a 10k pulldown connector and the reset is connected with a 100nF to the STATE button of the HC-05.

The pulldown resistor must be a mistake, other than that I learned that pin32 is connected to the STATE button on the bluetooth breakout board, well the LED shines a bit when I hold my multimeter on pin32 and the STATE button.

The 3rd circuit was also a reply on my prev. post: This one uses a NPN transistor to connect the arduino reset to ground. So any passed pulse on the capacitor would steer the transistor open, resetting the arduino?

With 3 different circuits, life was getting confusing :confused:

What I really just wanted to know is what one must do with the reset button and how does flashing a sketch in an arduino actually works. So I googled and found:

If you read the first 6 rules it becomes quite clear: When you reset an arduino, the first thing it does on power up, is running its bootloader. The bootloader checks if arduino IDE is flashing a new program or not, and the bootloader will then run whatever sketch is burned on its memory.

So if I understand correctly, prior to upoading a sketch over the TX/RX pins, the arduino needs a low pulse on its reset pin. I know from experience that sometimes you have to hold down the reset button manually untill IDE is done compiling, when the IDE says uploading sketch to board you have to release the reset button.

Knowing this confuses me even more, because the bluetooth module HC-05's LED is blinking continously when not connected, when it is connected it is also blinking only with a different speed.

My current assumption is the following: When the Hc-05 is connected the LED is burning and gives 2 low pulses every few seconds, in those few seconds the IDE has enough time to flash a new program in the arduino.

Questions: 1. If I connect the status LED via a capacitor to the arduino reset don't I reset the board with every blink of the BT module? 2. If the arduino boards gets a reset pulse at the moment the IDE is flashing a program in it, what will happen? 3. Which circuit will actually work.

The makezine article uses an HC-05 board that does not bring out the state pin to the header, so you add a wire to pin 32. Pin 32 is the state pin. It is separate from the LED pin that flashes at various rates. The "at+polar=1,0" command sets the state pin to act like DTR on a typical FTDI adapter. So, once you set up the state pin to act that way, and set the baud rate of the HC-05 to be the same baud rate as the bootloader on your Arduino, you are prepared.

Regarding the pull-down on Reset, that is only needed if you are wanting to override the built-in reset circuit on your Arduino. The pull-down resistor forms a voltage divider using the built-in pull-up resistor, to hold the reset voltage just above the acceptable high level. This makes the reset more sensitive to reset pulses through 2 different capacitors from 2 different serial adapters (the built-in USB-to-serial adapter on the Arduino, and the Bluetooth adapter you are adding). A cleaner way to do this is to cut the Reset-EN trace on your Arduino. Then you would not need that pull-down/voltage divider at all.

Ok I have done: - the baudrate set at 115200Hz - the polar is set at 1,0 - the voltage devider out of the schematic of gives me 3,79 Volts (with Vcc at 4,98V) on the reset pin. - pin 32 of the HC-05 is connected via a 100nF capacitor to the voltage devider/reset pin

I am using a HC-06 with a cp2102 USB/TTL converter on the PC end, also set on 115200Hz. I also configured the hc-05 as master and I have given it the BIND command so that everytime my specific slave turns on, it auto-connects. (both my PCs dont have build in bluetooths)

When trying to remotely program my el cheapo uno clone the IDE is giving me an out of synch problem avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x4e

When trying it with my mega I got :avrdude: stk500v2_command(): unknown status 0x01 avrdude: stk500v2_disable(): failed to leave programming mode

So atleast something program-ish was occurring in the arduino board :)

However I found that the capacitator was not soldered well on the reset line, now I did solder it properly there is less than nothing happening, IDE just says uploading and nothing happens.

Other than the problems with the reset line [u]I can succesfully upload a sketch when I hold down the reset button myself and let go when IDE starts uploading[/u]

I am thinking that either the BT module is not configured well, or more likely the DC voltage on the reset pin is too high?

Does anybody knows the solution? I am already thinking to program an attiny85 to operate the reset pin for me :) and glue that chip on the other side of my shield

When you configure the Bluetooth modules to connect to each other like that, the point in time at which they connect is when the state pin goes low and resets the Arduino. That is not when you need the Arduino to reset. You need the Arduino to reset when the IDE opens the comm port to the Arduino. Your manual reset makes it work because of the timing of it.

I think most people who try this have a PC with built-in Bluetooth, and when the comm port is opened that is when the Bluetooth connects and the state pin goes low. It may be possible to do with a Bluetooth dongle on the PC, but I don't know. I don't think that a cp2102 wired to a Bluetooth slave at the PC would work with auto reset.

Well I have it working. I measured the existing pullup resistor, it was 10k, so I cut my own 10k resistor of the voltage devider to lower the reset DC voltage, that gave me a correct voltage of 3.33V. And I could succesfully upload a program several times in row.

There is however one huge "but". My laptop has to be with in 50 centimeters if I want it to work, and I am not exaggerating. If I move beyond the 50cm, I do see that the arduino gets a reset but the program wont load. It seems that the bootloader is very sensitive when it comes to timing. But thankfully this laptop has a battery and the 50cm still beats hooking up a USB cable.

Now I can continue with my weatherstation :)

I wanted to ask a final question about the feasabilty of an idea. A buddy of mine came with the thought to make a USB dongle for the arduino boards.

So I thought to make a new print with any BT module, a USB TTL converter chip and the correct (or several) USB connector. Than I can also make a similar dongle for the computer side, like I did before with the cp2102 and the HC-06

If I bind the 2 dongles with eachother so they connect when both are powered up, I should be able to program any arduino board with any computer, using just my 2 usb dongles. It is ofcourse odd if you think about it. I mean you go from computer > USB >USB/TTL converter > BT >> BT >> USB/TTL converter > USB/TTL converter > atmega328... but if it works it would be cool and easy and you can do it with better antennas