In this tutorial we will show the steps to use OpenDevice and easily communicate with the devices.
The features will be displayed progressively, from a simple USB connection to a webserver using REST.
Hardware
In this first tutorial we will use the Arduino to be the most popular platform.
For this sample you need only a PC and Arduino (or compatible like one of EnergiaIDE).
Software
- Java SDK
- Eclipse
- Arduino IDE
...
This first example is pretty basic'll just focus on communication.
Step 1 - Installing the library in Arduino
To install the library, you can simply clone the repository in the : opendevice-hardware-libraries e copy the arduino/OpenDevice to /libraries folder of your Arduino folder.
Or you can also download the repository as a ZIP file and extract it in the /libraries folder.
Please note that the library also requires some other libraries to function properly, like , when used with other connection types or sensors, like the library for the CC3000 WiFi chipEnc28j60 chip.
You can find all the links inside the README file of the library.
...
https://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use
TODO: criar um repositorio :
opendevice-hardware-libraries/arduino/OpenDevice
Step 2 - Upload example in to Arduino
When you import the library, a menu for OpenDevice will be created in 'examples' menu. Choose UsbConnection example, and click in upload !
Step 3 - Create a new Java project with maven
If you already work with maven can skip this part, catching only the pom.xml example.
The best way to start with Java and Maven is using an IDE like Eclipse or Netbeans, we use Eclipse to be the most practical and does not require installation, simply download and unzip.
3.1 Create a project
1. Click on menu: File > New > Maven Project
If not in the NEW menu, choose Other and browse the list
2. Choose simple project in next step:
3. Set the name and the group
4. Create um new Java Class
3.1 Add OpenDevice dependency
OpenDevice libraries are managed by maven, he is responsible to download and set up, you simply configure the pom.xml