Upload sketch via Bluetooth

I have an Arduino Mega 2560 R2 that will be used to control an R/C truck (Rock Crawler). I purchased an external Bluetooth module (DF-BluetoothV3) that I believe is expecting serial communications at a baud rate of 115200. It works perfectly fine for receiving serial data from a sketch running on the Mega, but I am unable to use it to upload sketches.

Based on the research I've done so far, I believe there are a few reasons for this:

  • When I attempt to upload the sketch, I don't believe the BT module initiates a reset of the Arduino
  • The default baud rate in the Bootloader doesn't match the expected baud rate of the BT module
  • The delay in the bootloader isn't long enough to allow the BT module to begin sending the new sketch

There's a fair bit of speculation on my part here, but I'm hoping that there's a way around these problems. One of the options that came to mind was to install the ArduinoBT's bootloader on the Mega, but I'm not sure if the BT module on the ArduinoBT is connected differently.

Failing the ability to upload sketches through BT, I will try to connect the BT module to Serial 1 or Serial 2, leaving Serial 0 always open for uploading sketches.

Any advice would be appreciated.

ThanX

I purchased an external Bluetooth module (DF-BluetoothV3)

How is this connected to the Arduino?

Is it even active when the Arduino first powers up?

it connects to the Arduino on pins 0 and 1 for TX and RX. Other than that, just Vcc and GND.

When i try to upload sketches to the Arduino via USB with the Bluetooth module connected to the Arduimo, it fails because the Bluetooth module is tying up the TTL. As I understand it though, th BT module defaults to 115200, while the Arduino defaults to 9600 in the bootloader.

does that provide the detail you need?

it connects to the Arduino on pins 0 and 1 for TX and RX. Other than that, just Vcc and GND.

So, nothing resets the Arduino at the right time. When the Arduino is reset, the Serial pins don't become active until Serial.begin() is called, at which time it is too late to load a new sketch.

When i try to upload sketches to the Arduino via USB with the Bluetooth module connected to the Arduimo, it fails because the Bluetooth module is tying up the TTL.

The BT module is tying up the hardware serial pins. You could move the BT to other pins and use NewSoftSerial (0023 or earlier) or SoftwareSerial (1.0+).

As I understand it though, th BT module defaults to 115200, while the Arduino defaults to 9600 in the bootloader.

I think the default in the bootloader is 57600.

Thank you PaulS. You confirmed what I suspected. I know that some BT modules have a CS pin that could be used to reset the Arduino, but this particular one doesn't. I guess I'll have to use the BT exclusively for data transfer and rely on USB for programming.

I have the sensor Arduino Mega Sensor Shield which breaks out two additional serial ports connected to pins 14,15 and 16, 17 and 18, 19. The Mega spec sheet indicates that these are configured as TTL serial interfaces, so didn't think I needed to use SoftwareSerial. I'll have to do some more reading.

ThanX!

Break out your reset pin. Press it when the compiler prints the file size. That's how I do it (I use a mini- no USB onboard).

magnethead794: Break out your reset pin. Press it when the compiler prints the file size. That's how I do it (I use a mini- no USB onboard).

I have the same issue as the original poster - Mega2560, Bluetooth Serial port at 115200 and attempting to upload a sketch via BT. I have tried the method quoted above with no joy - can anyone help with precise timings or tips for pressing the reset buttom at the right time.

I have also read about the possibility of altering the bootloader to give a bigger window to wait for an upload - but I cant find anywhere to help me work out how despite several searches. Again, can anyone point me in the correct direction ?

Thank you.

PS I have just connected reset directly to ground - is that OK ? Do I need a cap inline or somesuch ?