Pages: [1]   Go Down
Author Topic: Upload Program To Arduino With BT Shield  (Read 2914 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 70
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The BT shield v2.2 use the same Bluetooth module as Iteaduino BT, we can hack it and make it a wireless programmer for Arduino as well. Here we take a Iteaduino with BT shield as a example, to show you how to upload the program to Arduino via Bluetooth.


1. Welding a 1uF capacitor between Pin32 of HC-05 module and the Rest pin of BT shield.

2. Set the jumpers on BT Shield: D0 with TX, D1 with RX. Set the mode switch of operation mode to CMD side.

3. Connect the Iteaduino with PC via USB cable, and open the “AccessPort” software:

- Choose the right COM number
- Change the baud rate to 38400


4. Send the AT command to change some configurations of the HC-05 module:

AT+ORGL (Restore the default state)
AT+ROLE=0 (Configure the HC-05 as slave)
AT+POLAR=1,0 (The LED will on when the output of PIO8 is high. And it indicates connecting successfully when the output of PIO9 is low.)
AT+UART=57600,0,0 (Set baud rate to 57600, one stop bit and no parity bit)
AT+INIT (Initializing SPP library)
5. Download Arduino IDE  (don’t use the Arduino 00xx) . Download the “rxtxserial.dll” file here, and replace the one in your Arduino IDE 1.5 Folder.

6. Disconnect the Iteaduino with PC, and reset the jumpers: D0 with RX and D1 with TX. Put the mode switch to DAT side.

7. Repower the Iteaduino, and use the laptop or PC to search the BT shield (if your PC doesn’t support Bluetooth, we recommend this Tiny USB Bluetooth Adapter )

8. Enter pin code “1234” and connect to the BT shield. Check the COM number of the serial Bluetooth port (When you check in Hardware Device Manager, it will show you 2 ports , and just one can be used for wireless programming)


9. Open Arduino IDE 1.5. You should select “Tools->Board->Arduino Duemilanove w/ATmega 328″. And select “Tools->Serial Port->COMX (the serial port of the Bluetooth device)”.

10. Press the “Upload” button, the program will be upload into Iteaduino by Bluetooth !

Note: This is an example for Iteaduino (Arduino Duemilanove), if you are using the Iteaduino UNO (Arduino UNO), there are some different:

Using the AT+UART=115200,0,0 but not the 57600 now
Choose the “Arduino UNO” instead of the “Arduino Duemilanove w/ATmega 328”
More step by step tutorials, you can find it here <Wireless Programming Your Iteaduino BT>.
« Last Edit: November 13, 2012, 04:45:03 am by ITead » Logged

Itead Studio - Make innovation easier

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 76
Posts: 7305
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting. This might be neat for updating firmware. You said download the rxtxserial.dll here but there is no link. Why do you have to write a different dll? What is the different between original arduino dll and yours? Very curious to find out. Thanks.
Logged


0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 70
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting. This might be neat for updating firmware. You said download the rxtxserial.dll here but there is no link. Why do you have to write a different dll? What is the different between original arduino dll and yours? Very curious to find out. Thanks.
When the BT shield connect to PC, there will be 2 COM Port, but the old dll will just show one in the Arduino IDE port menu, but the one can not use, so this dll will find 2 port and show them in the IDE, you can choose the right one for program.
Logged

Itead Studio - Make innovation easier

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 76
Posts: 7305
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

athanks. Did you mean the bluetooth adapter shows up as two serial ports? The bluetooth shield is only connected to pc via arduino first. If I am right, then I can just use xcode program to choose the right serial port to load hex program, right?
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, sory for reopen this topic...
I'm trying to send a command just to turn on the LED, here is the code:

Configuration:
Jumpers: RX D6, TX D7
Switch mode: DAT
Bauld rate: 38400
Name: Controle
Keyword: 9812
Was just it I've modified

Code:
#include <SoftwareSerial.h>

#define LED_1       4
#define LED         3

SoftwareSerial bluetooth(6, 7); // RX, TX

void setup()  
{
  Serial.begin(38400);
  bluetooth.begin(38400);
  pinMode(LED, OUTPUT);
  pinMode(LED_1, OUTPUT);
}

void loop()
{
  digitalWrite(LED_1, HIGH);
  char letra;
  if (bluetooth.available()){
    letra = bluetooth.read();
    if (letra == 'A'){
      digitalWrite(LED, HIGH);
    }
    if (letra == 'a'){
      digitalWrite(LED, LOW);
    }  
  }
}

PS.: I'm using  BT Shield IteadStudio V2.2 - I've already tied a code that looks like this with another shield and it worked, if you want to see the code:

Code:
#include <SoftwareSerial.h>   //Inlcui a biblioteca SoftwareSerial.h
 
#define RxD         6 //Define RxD como 6
#define TxD         7 //Define TxD como 7
 
#define LED_AMARELO    2 //LED_AMARELO_BLINK como 2
#define LED_VERMELHO    3 //LED_VERMELHO_FADE como 3
#define RELE_LAMPADA         4 //RELE_LAMPADA como 4
 
SoftwareSerial blueToothSerial(RxD,TxD); //Instância a biblioteca SoftwareSerial.h
 
void setup()
{

  pinMode(LED_AMARELO, OUTPUT); //Configura o pino 2 como saída
  pinMode(LED_VERMELHO, OUTPUT); //Configura o pino 3 como saída
  pinMode(RELE_LAMPADA, OUTPUT); //Configura o pino 4 como saída
parear_dispositivo(); //Executa a função para parear o dispositivo
}
 
void loop()
{
  char letra; //Variável char para armazenar o caractere recebido
if(blueToothSerial.available()) //Se algo for recebido pela serial do módulo bluetooth
    {
      letra = blueToothSerial.read(); //Armazena o caractere recebido na variável letra
if(letra == 'A') digitalWrite(LED_AMARELO, HIGH); //Se o caractere recebido for a letra A, liga o LED Amarelo
      else if(letra == 'a') digitalWrite(LED_AMARELO, LOW); //Senão se o caractere recebido for a letra a, desliga o LED Amarelo
      else if(letra == 'B') digitalWrite(LED_VERMELHO, HIGH); //Senão se o caractere recebido for a letra B, liga o LED Vermelho
      else if(letra == 'b') digitalWrite(LED_VERMELHO, LOW); //Senão se o caractere recebido for a letra b, delisga o LED Vermelho
      else if(letra == 'C') digitalWrite(RELE_LAMPADA, HIGH); //Senão se o caractere recebido for a letra C, liga a Lâmpada
      else if(letra == 'c') digitalWrite(RELE_LAMPADA, LOW); //Senão se o caractere recebido for a letra c, desliga a Lâmpada
      else if(letra == 'H') digitalWrite(9, LOW);
      else if(letra == 'h') digitalWrite(9, HIGH);
  }
}
 
void parear_dispositivo()
{
  blueToothSerial.begin(9600); // Configura o baud rate do bluetooth como 38400
  blueToothSerial.print("\r\n+STWMOD=0\r\n"); // Configura o módulo bluetooth para trabalhar como slave
  blueToothSerial.print("\r\n+STNA=SeedBTShield\r\n"); // Configura o nome do disopsitivo bluetooth
  blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permite que outros dispositivos encontrem o módulo bluetooth
  blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Desabilita a auto conexão
  delay(2000); // Aguarda 2 segundos
  blueToothSerial.print("\r\n+INQ=1\r\n"); // Habilita modo de paridade
  delay(2000); // Aguarda 2 segundos
  blueToothSerial.flush(); // Dá um flush na serial do módulo bluetooth
}

I hope you can help me  smiley-mr-green
« Last Edit: August 24, 2014, 07:57:47 pm by mauroaraujo » Logged

Pages: [1]   Go Up
Jump to: