Connect windows app to arduino

  • 1
  • Question
  • Updated 4 years ago
Hello,

Im a newbie and I want to know if it is possible to make windows desktop app (not windows phone app) with ability of connection to arduino via USB or Ethernet?

I know that there are many tutorials that describes how to make connection of mobile phones with arduino via bluetooth or wifi, but it does not fit my task.

The reason why I choose only windows desktop app is to get all benefits of PC's wide screen and make a complex and beautiful user interface.

I also know that it is possible just to write a simple server program for arduino only and send requests via browser, but it does not fit my task too, because I have to use complex graphics, animation and images. Storage of many images and graphics on arduino is too costly.

I just want to write an app using html, css and js, then plug my arduino to the computer and send some commands to arduino via usb or ethernet, like a usual terminal but with nice user interface and complex logic.

Thanks for answers and sorry for grammar :)
Photo of Borisko

Borisko

  • 10 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Borisko,

Canned Message
I need to blog this, so i don't have to repeat this answer again and again.

You cannot use Phonegap Desktop App with Phonegap Build.

Phonegap Desktop App uses Phonegap CLI, so if you want to use Phonegap Desktop App you need to stay with Phonegap CLI.

If you want to use Phonegap Build, then forget what you have done and start over _OR_ make Minor modifications to move Phonegap Desktop App to Phonegap Build. To be clear, the difference is minor, but enough to keep tripping you.

Also, you will not be able to use Phonegap Developer App as that is meant to work with Phonegap Desktop App. You cannot use either CLI or Build with Developer App.

FWIW: I've been trying to get Phonegap to fix this. Here is the report on the issue.

Let me know what you want to do.

Jesse
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Borisko


(...)
I also know that it is possible just to write a simple server program for arduino only and send requests via browser, but it does not fit my task too, because I have to use complex graphics, animation and images. Storage of many images and graphics on arduino is too costly.

I just want to write an app using html, css and js, then plug my arduino to the computer and send some commands to arduino via usb or ethernet, like a usual terminal but with nice user interface and complex logic.

The answer is yes. I have several tutorials on the general subject, and several on using Arudino with Phonegap.

Which Arduino are you using?

Jesse
Photo of Borisko

Borisko

  • 10 Posts
  • 0 Reply Likes

You cannot use Phonegap Desktop App with Phonegap Build.

Uhm, it seems that you misunderstood me a little bit.
My previous post is about app creation for windows (PC) only. I meant if it's possible to write an app for windows by dint of Phonegap (whatever, phonegap desktop app or phonegap build), just write an app and get standalone executable file as a result which I can launch on my PC and see a beautiful interface of my program.


I have several tutorials

Could you post some links please?


Which Arduino are you using?

Now I have arduino nano only, but it is not a big deal for me to by any other arduino.
So, does it matter which arduino I use? I want to simplify arduino's program as much as possible, just read some data from my PC and do some stuff (turn on a led for e.g.). Like a usual arduino's terminal that sends commands.

I know that I can write only server side arduino program and use ethernet module with sd card to store my html pages and other stuff, but it will be very painful to mix c++ logics of the user interface with html content.

I think the question is whether there is a sophisticated plugin (like a terminal) for phonegap to provide comunication between arduino and app via usb? I don't know what exactly should it be. Maybe some usb driver.
The ideal option would be to use some javascript function that gonna tell that some data need to be sent via usb serial.

To clarify all the stuff look at the picture.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
I meant if it's possible to write an app for windows by dint of Phonegap (whatever, phonegap desktop app or phonegap build), just write an app and get standalone executable file as a result which I can launch on my PC and see a beautiful interface of my program.
Since about a week or less, yes. You would use Phonegap Build cli-6.1.0, which introduced .appx for Windows10.
See the Blog, linked in the menu bar of this forum.

Now, you want it to communicate through USB or so.
I have no experience with that, but you should have a look at the many plugins at http://plugins.cordova.io
(Or write a private plugin)
Photo of Borisko

Borisko

  • 10 Posts
  • 0 Reply Likes
Thank you for the answer.
Not only for win10, also for win8.1 as it is written in the documentation

There are lots of plugins which deal with usb but only for android:
-cordova-plugin-serial (Cordova plugin to communicate with the android USB serial port);
-cordovarduino (Cordova plugin to communicate with the android USB serial port);
-e.t.c.

I found out that there are several ways to do this, but not with phonegap:
1) use Involt
2) write google chrome extension and use serial api
3) write a standalone app with python or c# or other language.


(Or write a private plugin)
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
Skip the Serial port. See my comment below.
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Borisko

>
> You cannot use Phonegap Desktop App with Phonegap Build.
>

Uhm, it seems that you misunderstood me a little bit.
My previous post is about app creation for windows (PC) only. I meant if it's possible to write an app for windows by dint of Phonegap (whatever, phonegap desktop app or phonegap build), just write an app and get standalone executable file as a result which I can launch on my PC and see a beautiful interface of my program.


It is possible to write a webapp - that runs in a webbrowser, and have that code work (when compiled) as a standalone mobile app. You want to use Cordova/Phonegap CLI.

Do not use Phonegap Desktop App. It is not intended for full app development. It is not intended to produce a final product.


>
> I have several tutorials
>

Could you post some links please?

I'll post them at the bottom of the reply.


>
> Which Arduino are you using?
>

Now I have arduino nano only, but it is not a big deal for me to by any other arduino. So, does it matter which arduino I use? I want to simplify arduino's program as much as possible, just read some data from my PC and do some stuff (turn on a led for e.g.). Like a usual arduino's terminal that sends commands.

I know that I can write only server side arduino program and use ethernet module with sd card to store my html pages and other stuff, but it will be very painful to mix c++ logics of the user interface with html content.

I think the question is whether there is a sophisticated plugin (like a terminal) for phonegap to provide comunication between arduino and app via usb? I don't know what exactly should it be. Maybe some usb driver. The ideal option would be to use some javascript function that gonna tell that some data need to be sent via usb serial.


FWIW, you do not have to write any C++. If you have to write any, it will be minimal

Here is the good news. If you instead buy a Arduino Yun, Yun Mini, or Tian, then you can have a full Linux server that talks directly to your GPIO pins on your Atmel (Arduino)

With the Arduino Yun (et al) have a builtin REST API. On the system you would use the "bridge library" to talk directly from the Linux part to the Atmel (with the GPIO pins). And since the Yun is a full Linux system, you already have a webserver running on the Arduino, that you can talk to locally, or via a websocket for the Internet.

On Phonegap, you will want to use JQuery (or Zepto) to talk directly to the REST API that runs on the Yun. So, what will happen (from the eagle's view) is you are using an HTML webpage to talk to a webinterface built into the system.

As for the USB serial port ideal, it is available; but as you can see there are better options.

Jesse
Photo of Borisko

Borisko

  • 10 Posts
  • 0 Reply Likes
Thank you for the answer.

Do not use Phonegap Desktop App. It is not intended for full app development. It is not intended to produce a final product.

I completely understand the difference between phonegap desktop app and phonegap build and I have already tested Phonegap build.


I'll post them at the bottom of the reply.

I look forward to.


If you instead buy a Arduino Yun, Yun Mini, or Tian, then you can have a full Linux server that talks directly to your GPIO pins

I also can buy raspberry pi that is more powerful rather than Arduino Yun. And I have one. Furthermore I can buy esp8266 wi-fi module or ethernet module and connect it to any arduino and make a server with it. But in all these cases, I have to install Linux, install XAMP, configure it or deal with LUA scripting e.t.c... There are too many unnecessary actions. The question is, what is this all for when I already have a quite powerfull PC that can solve any task? Why should I carry all the complicated logic of my program on the sided hardware? I just want to control it by simple commands through usb without any lags/lattency.


you can talk to locally, or via a websocket for the Internet.

Of course if I want to make more complex control in realtime like websockets or webrtc I should choose somthing else rather than 8-bit microcontroller. But I think even esp8266+arduino will cope with websockets.


On Phonegap, you will want to use JQuery (or Zepto) to talk directly to the REST API

With usb connection I will have about the same thing and I really want to use such a powerful combination of html5+cs+js+phonegap build. I just need a cordova plugin to deal with usb serial.
Photo of Borisko

Borisko

  • 10 Posts
  • 0 Reply Likes

Since about a week or less, yes. You would use Phonegap Build cli-6.1.0, which introduced .appx for Windows10.
See the Blog, linked in the menu bar of this forum.

I've just tried to build my project for windows but phonegap build produces only "app.xap" file. I want to get ".appx" file to install it on my PC. I've added a few lines to my "config.xml" file as it is written in the blog but this does not make any sense. What am I doing wrong?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
What PGB version are you using?
And what 'few lines' did you insert?
Photo of Borisko

Borisko

  • 10 Posts
  • 0 Reply Likes
Oops, I forgot to specify PGB version in my config.xml file. Now it is cli-6.1.0.
But new problem has appeared.



And what 'few lines' did you insert?

These lines:

<preference name="phonegap-version" value="cli-6.1.0" />

<!-- Windows 10 (default): -->

<preference name="windows-appx-target" value="uap" />

<!-- Windows 8.1: -->

<preference name="windows-appx-target" value="8.1-win" />

<!-- Windows Phone 8.1: -->

<preference name="windows-appx-target" value="8.1-phone" />
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
I don't think you can have a preference for the same name three times with different values. You've got to pick one.

(There may be more errors in your config or the directory structure, though)
Photo of Borisko

Borisko

  • 10 Posts
  • 0 Reply Likes
I removed from config.xml file these lines

<!-- Windows 8.1: -->

<preference name="windows-appx-target" value="8.1-win" />

<!-- Windows Phone 8.1: -->

<preference name="windows-appx-target" value="8.1-phone" />


But have the same issue.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
OK.
It's a general message (and obviously intended to be funny, too).
More errors might be present.

Your options:
- take a look at the build log and see if it mentions any specific causes
- if your zip file is available online somewhere, post its url and I'll be happy to have a look
Photo of Borisko

Borisko

  • 10 Posts
  • 0 Reply Likes
This is my build log.

This is my project.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1. Can't read your build log. The link sends me to the PGB login page.
It might show some trouble with certain plugins (see below).

2. About your config:
a. I would add
<preference name="windows-arch" value="anycpu" />

b. You may want to specify the latest version of each plugin. Currently, you have several older versions pinned, which may not work nicely with that latest cli-6.1.0
(I only checked the first five plugins of your list and found that all of them have meanwhile been updated at npm)

c. You have no splashes specified. I am not sure whether this can lead to error situations with cli-6.1.0, but you will certainly want to include one.
Photo of Borisko

Borisko

  • 10 Posts
  • 0 Reply Likes
Sorry, this is correct link for log
.

I added <preference name="windows-arch" value="anycpu" />

and corrected all plugins in config.xml to new versions. But it does not solve the problem.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Several warnings and errors, beginning with messages about the signing key.

Sorry, this is something I have no experience with.
The PGB Support team hardly ever visits this community anymore. You might want to try asking as a comment to the cli-6.1.0-Blog. I would expect PGB to follow at least that.
Photo of Borisko

Borisko

  • 10 Posts
  • 0 Reply Likes
Okay. Has somebody already done a successful build for windows 10 or windows 8.1?
I can't find any useful information about win10 and win8.1 support by phonegap build. It is disappointing.
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Borisko,
my laptop has died. I must reduce my responses.
Petra will help you.

Jesse