Uploading compiled sketch to Arduino via serial from a PC application

I can guess that his question has been asked before, but here I am asking it again, pardon me if it is something really simple.

I am building a fairly complicated (to my standards) water drop system. The user of the system are probably not techy at all, so I would like to be able to use my PC application to upload an upgrade or a complete different sketch to Arduino. Is it possible?

Many thanks.

Not really much help, but the entire source code for the Arduino IDE is available, including the serial part thing, which is actually handled my avrdude.

From the sketch to arduino, it is basically a 2-step process:

  1. generate the binary file from the sketch's source code. This is done with gcc and the final result is a file with the name <your_sketch>.HEX

  2. upload the .HEX to the device using the serial port. This is done with avrdude.

You don't need the IDE at all, but you do need the compile chain (it is called a chain because it's made up of several small program called in a very specific sequence, each program having one specific job) and avrdude.

When you upload a sketch using the IDE, the entire process is verbosely shown in the lower part of the IDE's screen. If you issues those same commands from a command prompt or shell, you'll get the same results.

You might as well have a batch file or shell script that takes the .INO or .PDE file as argument and do all the steps the IDE does.

Remember that any library the sketch calls should be visible for the compiler.

On a side note, I don't recommend you send the sketch's source to your users. Just send them the .HEX file. Let them have AVRDUDE installed and give them a batch file that simply uploads your HEX file to their arduinos. It is a lot easier. In Windows batch files that are in the desktop accept the drag-n-drop functionality, so all they'll have to do is connect their arduinos through USB, and drop-n-drop your .HEX file to the batch file in their desktops. Doesn't get much easier than that!

Sure.
You have to use avrdude, as far as I know, you don't need the Java serial port for avrdude. The avrdude software must be on the remote computer. If you use a specific piece of software, you have to run a script which uses avrdude with the hex file.
But why not install the complete Arduino IDE ?

You could use for example TeamViewer to operate the remote PC. I like TeamViewer because that is for Windows and Linux and never let me down. But there are many other programs for remote desktop ofcourse.

Thank you both.

The reason that I want to hide the upload process is because most of intended user do not have a clue what an IDE is, they are photographers (include Arduino techies) and if I want to upgrade firmware, I want to make it simple for them to do -- pick a file via my PC application and click OK, it is done.

I will do some more research on this, maybe roll my own uploader . . .

mjkzz:
I will do some more research on this, maybe roll my own uploader . . .

Not worth the trouble... you'll be reinventing the wheel.

You can simply write a program that calls AVRDUDE without any visible messages to the user. I know that can be done in .Net (C#), Java and Delphi (I've done in Delphi many times). Even if it is a command-line program, there are Windows APIs that will create a process for the command-line application without actually showing the "command promp" window. That is pretty much what the IDE does, but without being verbose.

I had a similar problem - I haven't tried this yet but it might be of some assistance.

http://xloader.russemotto.com/

That program uses avrdude, but the source code is not included !

OK, I will dig into this and make it open source and publish codes on github.

I want a (long) chain of Arduinos... if possible I want to program them all at ones. Who knows how to do that?

For programming Arduino boards with .NET framework, sijk's version of twinearthsoftware's ArduinoSketchUploader can be used. sijk has solved verification problem of the original source and added custom arduino board programming ability to it. Here is the github link: GitHub - sijk/ArduinoSketchUploader: A .NET library and a command line utility to upload a compiled sketch (. HEX file) directly to an Arduino board.

This program has both the library and console application which can be used to program Arduino boards over serial communication.

I just wanted to make this comment here because this question showed up in google search and it doesn't offer a good program to use.