0
votes

want to create android app to upload .hex file to arduino uno via USB. Sketch IDE creates .hex file after compiling program .And able to upload to arduino uno via USB. So can any body tell me that how make android app to upload .hex file to arduno uno . There is app called "Arduino Commander" on google play store who can able upload using USB. And also I want to know android source code for that

2
Can you see the arduino serial port when you connect it on the usb port? If so, you "just" have to make an avrdude alternative for android or see the andavr project. If you can't see it, you "just" have to patch the kernel to install the required drivers. In any case note that the just was written in double quotes... As for the Arduino Commander source code, what is explicitely the request? Do you want someone to search it for you, or do you want someone to reverse engineer the app for you, or do you want the app author to accidentally see your message and send the whole app to you by e-mail? - frarugi87
I want to know how to do uploading a .hex file from android via usb to arduino , like: what tool i should use (libraries, api... ) that do connection between android and arduino for uploading via usb , and a step by step instruction to realise it , i found similair project on github that do uploading but it s not working ( it use physicaloid library) . Thanks - Imane Tchantchane
I tried to say it in a softer way, but maybe I wasn't clear enough. So let's say it in another way. Do you have an android phone without USB OTG? Then you can't. If you have, do you see any serial device when you connect the arduino? If you don't, you will have to compile the CDC driver inside your phone's kernel (quite difficult). If you manage to install it or you already have it you have to find an avrdude alternative (for instance AndAVR) and use it to send the program like you would on the PC (through the terminal, of course... No GUI available) or build a program to do this yourself - frarugi87
i think i wasnt clear enough too i want to creat an android application actualy working on anroid studio that do the uploading (.hex file) to arduino , just like arduinodroid if you know it - Imane Tchantchane
Ok, then I reply again in a more synthetic way. Don't you have USB OTG? No way to implement it in software, since hardware is missing. Don't you have the CDC drivers? No way to implement it in software, since it requires you to write it directly in the kernel (so you need a kernel patch - and this is not installable directly at user level, but you need root). Do you have USB OTG AND the drivers? The andavr project does this. Search for it, see its source code and try to integrate it in the application from android studio. But... It is not so easy IMHO... - frarugi87

2 Answers

1
votes

i do not know exactly what you mean this is why this is divided in two parts:

either you want to use the arduino's virtual COM port to write a binary file to EEPROM or flash using RS-232 protocol.

or you want to flash a .hex file (write a self written and compiled program to the arduino) via its bootloader over USB (DFU programming). i think you want to do the first one

normally arduino uno's USB implements the USB CDC ACM class ( https://en.wikipedia.org/wiki/USB_communications_device_class ) and is a Virtual COM port. So you can communicate with RS-232 protocol/commands over USB from android to arduino.

on the android side there is a USB host driver (https://github.com/mik3y/usb-serial-for-android) that enables your android to enumerate Virtual COM ports (USB CDC ACM devices) like the arduino.

in this situation the android is USB host the arduino is USB device. In USB protocol there can only one device be in host mode all other devices have to be in device mode then

so on your android you can include the usb-serial-for-andoid driver in your project and then use RS-232 commands to communicate with the arduinos virtual COM, an example is in https://github.com/mik3y/usb-serial-for-android .

on your arduino you have to implement a software that understands the commands it receives over the virtual com port, see https://www.arduino.cc/en/Tutorial/SoftwareSerialExample for RS-232 on arduino

by this you can implement a similar functionality like Arduino Commander https://www.arduino.cc/en/Main/USBSerial

you can also ask arduino questions at http://arduino.stackexchange.com

(http://www.v-lad.org/projects/gnu.io.android/)


the programming of the arduino (flashing a .hex) over USB port works because the Arduino chip has a preinstalled bootloader (http://wiki.osdev.org/Bootloader). this is called DFU (Device Firmware Update). DFU is a special USB protocol. you can follow this tutorial https://www.arduino.cc/en/Hacking/DFUProgramming8U2 note that when you do this you overwrite /delete any firmware that is on the arduino (except the bootloader and some other low-level tasks) and replace it with your newly developed

there is no android app for this and arduino commander is not able to do this, this is why i do not think you want to do this (DFU using android as host)

1
votes

Use Physicaloid, it provides a simple method to upload a sketch files to an arduino. The sketch file is stored in the app's assets folder.