[:pt]
É possível fazer o upload de um programa para o arduino via bluetooth?
Quem utiliza Arduino nos seus projectos, mais dia menos dia irá ter uma duvida que gostaria de ter esclarecida.
É possível fazer o upload de um programa para o arduino via wireless?
R.: Sim, de todo testado, comprovado, e explicado neste post.
Para começar informo que neste caso, o via Wireless trata-se de uma ligação Bluetooth, os testes foram feito utilizando um arduino UNO r3, e um Arduino Nano 328, utilizando o Windows XP, e o Arduino IDE 1.0.5, será ainda necessário outro programa o VSPE (Virtual Serial Port Emulation), estes são alguns dos requisitos que me dará muito gosto explicar, e outros passam por Handshake, Reset, e Watchdog (a serio cão de guarda), Sketch, Bootloader, entre outros termos estrangeiros que definem algumas operações.
Para começar a resolver este problema resolvi colocar a questão de outra maneira. Como é que o upload se processa e, o que que me impede de fazer o upload de programas para o arduino via wireless.
O upload de software para o Arduino normalmente é feito via cabo FTDI que não é mais que um conversor USB serie, e é através dos pinos 0 e 1 (que são também a porta serie do arduino TX e RX) que a informação circula.
Posto isto e visto que podemos ter uma porta serie com a maioria dos dispositivos bluetooth presentes nos nossos notebook´s fica a questão. O que me impede de ligar um modulo bluetooth na porta serie do arduino emparelhar com o PC e solicitar ao Arduino IDE de enviar o firmware para essa porta?
Bem na verdade o que impede isto ser assim tão simples e linear, são fundamentalmente 3 aspectos.
- Primeiro no meu caso utilizo módulos Bluetooth HC-05, que a semelhança de outras possibilidades no mercado parece que não dispõem de linha DTR (digo parece porque ainda não tenho a certeza, se alguém souber mais sobre o DTR nos módulos HC-05 agradeço que me informe). Sem DTR não se consegue fazer o reset ao Arduino de modo o Bootloader iniciar e por conseguinte dar inicio a sequência de upload de firmware para o Arduino.
- Qual as características que a ligação serie necessita para comunicar com o arduino na sequência de upload?
- O Arduino IDE é capaz de enviar o upload para uma porta serie, até aqui tudo certo, mas há um senão que é, se estabelecer a ligação serie Bluetooth do PC ao arduino via Windows o IDE vai dizer que esta porta está a ser usada e impede o upload.
Se dominarmos estas questões temos o problema resolvido e o upload do firmware a funcionar em pleno.
Ponto 1 Reset do Arduino
Estão relacionadas entre si existem varias hipóteses de solução, sempre em mente que o necessário é fazer um reset ao Arduino de modo o bootloader arrancar.
Isto pode ser conseguido de varias formas.
Por Hardware
- Carregando no Botão de reset do Arduino resolve as questões no ponto 1 e ponto 2. Para o upload iniciar devera carregar no botão de reset do arduino e um segundo depois de aparecer “Uploading” no IDE largar o botão de reset.
Por Software
- Brevemente vou dedicar um post a este assunto mas para já deixo 2 links com informação útil sobre este tema.
Resetting the arduino through software for fun and profit by aRiver’s pad
Arduino tips ticks and techniques Bootloader by Adafruit
Ponto 2 Características da ligação serie estabelecida durante o upload de firmware.
Aqui basicamente o que há a saber é que o upload é feito desde o IDE via porta serie que pode ser seleccionada pelo utilizador e um aspecto fundamentar é que essa comunicação e feita com um Baund Rate 57600bps Stop Bit 1 e Parity None.
Como tal teremos de configurar o modulo BT HC_05 com estas características, e até já fiz um post sobre isso que pode ser lido aqui.
Para modulo diferentes destes o procedimento é algo parecido mas recomendo consultarem o datasheet do respectivo modulo e obter referencias sobre o modo AT e respectivos comandos.
Ponto 3 Configurações do Arduino IDE
Aqui reside o problema do normal funcionamento do IDE, que reside em testar a utilização da porta serie em questão neste caso a porta serie associada ao Bluetooth.
Em Linux não sei ao certo o funcionamento tanto bluetooth como do IDE, mas no windows o que se passa é o seguinte.
Por um lado temos de fazer a ligação da porta serie ao bluetooth do pc ao modulo via windows e por outro quando seleccionamos essa mesma porta para upload o IDE reporta que a porta serie em questão já está a ser utilizada.
A solução
Passa pela utilização do programa que indiquei acima o VSPE (Virtual Serial Port Emulation) e que pode ser descarregado gratuitamente aqui.
O truque aqui agora é o seguinte criar uma porta serie virtual, encaminhar todo o tráfego entre a porta serie do BT e esta porta serie virtual.
Desta maneira o IDE não se queixa do windows estar a utilizar a porta serie do BT e o upload é feito sem problemas.
Exemplo
Criei um Spliter onde utilizei como porta serie virtual a COM16 e redireccionei para a COM13 porta real do BT do PC, fiz o emparelhamento e a ligação pelo windows e “voilá” está pronto a fazer upload de novos sketch para o Arduino via bluetooth.


[:en]
Is it possible to upload a program to Arduino via Bluetooth?
Anyone who uses Arduino in their projects will sooner or later wonder about this.
Is it possible to upload a program to Arduino wirelessly?
A.: Yes, it’s fully tested, proven, and explained in this post.
To begin with, in this case, “wirelessly” means a Bluetooth connection. The tests were conducted using an Arduino UNO R3 and an Arduino Nano 328, with Windows XP, and the Arduino IDE 1.0.5. Another necessary program is VSPE (Virtual Serial Port Emulation). These are some of the requirements that I will explain, along with terms like Handshake, Reset, Watchdog, Sketch, Bootloader, and other foreign terms defining certain operations.
To start solving this problem, I rephrased the question. How does the upload process work, and what prevents me from uploading programs to Arduino wirelessly?
Software upload to Arduino is typically done via an FTDI cable, which is essentially a USB to serial converter, through pins 0 and 1 (the serial port of the Arduino TX and RX).
Given that we can have a serial port with most Bluetooth devices in our notebooks, the question arises. What stops me from connecting a Bluetooth module to the Arduino serial port, pairing it with the PC, and asking the Arduino IDE to send the firmware to that port?
The answer lies in three main aspects:
- First, in my case, I use HC-05 Bluetooth modules, which, like other market options, seem to lack a DTR line (I’m not sure; if anyone knows more about DTR in HC-05 modules, please inform me). Without DTR, resetting the Arduino to start the Bootloader and begin the firmware upload sequence isn’t possible.
- What are the characteristics that the serial connection needs to communicate with the Arduino during the upload sequence?
- The Arduino IDE can send the upload to a serial port, but when establishing a Bluetooth serial connection from the PC to the Arduino via Windows, the IDE reports that the port is in use and prevents the upload.
By mastering these issues, we can solve the problem and get the firmware upload working perfectly.
Step 1: Resetting the Arduino
These are interconnected, and there are several solutions, always keeping in mind that a reset is needed for the bootloader to start.
This can be achieved in several ways.
Hardware Method
- Pressing the Arduino reset button addresses both points 1 and 2. To initiate the upload, press the reset button on the Arduino, and release it one second after “Uploading” appears in the IDE.
Software Method
- Soon, I will dedicate a post to this topic, but for now, here are two useful links.
Resetting the Arduino through software for fun and profit by aRiver’s pad
Arduino tips tricks and techniques Bootloader by Adafruit
Step 2: Characteristics of the Serial Connection during Firmware Upload
The main point here is that the upload is done from the IDE via a serial port that can be selected by the user. A fundamental aspect is that this communication is done at a Baud Rate of 57600bps, with 1 Stop Bit and No Parity.
Therefore, we need to configure the HC-05 Bluetooth module with these characteristics. I have even written a post about this, which can be read here.
For different modules, the procedure is similar, but I recommend consulting the respective module’s datasheet and obtaining references on AT mode and respective commands.
Step 3: Arduino IDE Settings
Here lies the issue with the normal functioning of the IDE, which involves testing the use of the specified serial port, in this case, the serial port associated with Bluetooth.
In Linux, I am not sure how both Bluetooth and the IDE work, but in Windows, the situation is as follows.
On one hand, we have to make the serial port connection from the PC to the Bluetooth module via Windows. On the other hand, when selecting that same port for upload, the IDE reports that the serial port is already in use.
The Solution
The solution involves using the program mentioned above, VSPE (Virtual Serial Port Emulation), which can be downloaded for free here.
The trick is to create a virtual serial port and route all traffic between the Bluetooth serial port and this virtual serial port.
This way, the IDE does not complain about Windows using the Bluetooth serial port, and the upload proceeds without issues.
Example
I created a splitter using COM16 as the virtual serial port and redirected it to COM13, the real Bluetooth port of the PC. I paired and connected via Windows, and “voilà,” it’s ready to upload new sketches to the Arduino via Bluetooth.




Charly Da Silva liked this on Facebook.
Pedro Neves liked this on Facebook.
Daniel Lopes liked this on Facebook.
Nuno Moleiro liked this on Facebook.
Manuel Barros liked this on Facebook.
Mario Guido liked this on Facebook.
César Rafael liked this on Facebook.
Silvia Lopes liked this on Facebook.