You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cordovarduino is a Cordova/Phonegap plugin that enable you to use serial communication from an Android device to a serial over USB capable one.
4
+
5
+
### Context
6
+
This work was made during an art residency hosted at the [Stereolux, Laboratoire Arts et Technologies](http://www.stereolux.org/laboratoire-arts-et-technologies/archives) with [Coup de foudre](https://www.facebook.com/coup.defoudre.716) and [Xavier Seignard](http://drangies.fr).
7
+
8
+
The goal was to create a tablet app to control a [tesla coil](http://www.youtube.com/watch?v=X2elQ6RR7lw) with an [Arduino](http://arduino.cc). The chosen technology ([Cordova](http://cordova.io)) had no capabilities to handle such serial over usb communication.
9
+
10
+
### Install it
11
+
From the root folder of your cordova project, run :
Thanks to [usb-serial-for-android](https://github.com/mik3y/usb-serial-for-android) library, you can communicate with CDC, FTDI, Arduino and other devices. Here is the Cordova plugin API.
18
+
19
+
Because you're polite, first request the permission to use the serial port to the system:
20
+
```js
21
+
serial.requestPermission(functionsuccess(), function error());
22
+
```
23
+
You can now open the serial port:
24
+
```js
25
+
serial.open(opts, function success(), function error());
26
+
```
27
+
`opts` is a JSON object with the following properties:
28
+
29
+
- baudRate: defaults to 9600
30
+
- dataBits: defaults to 8
31
+
- stopBits: defaults to 1
32
+
- parity: defaults to 0
33
+
34
+
You're now able to read and write:
35
+
```js
36
+
serial.write(function success(), function error());
37
+
serial.read(data, function success(), function error());
38
+
```
39
+
`data` is the string representation to be written to the serial port.
40
+
41
+
And finally close the port:
42
+
```js
43
+
serial.close(function success(), function error())
0 commit comments