In this tutorial we will show the steps to use OpenDevice LIBs and easily do communication between a Java application and Arduino.
Info |
---|
This tutorial is focused on creating custom applications, if you just want to connect your device and start controlling it, you can use the server. If you do not know OpenDevice, I recommend reading the overview, to understand the features, capabilities, languages and operating models. |
...
You can install through the Library Manager, click to the "Sketch" menu and then Include Library > Manage Libraries.
Find OpenDevice and click <Install>
For a more detailed guide: http://www.arduino.cc/en/guide/libraries
Install from source
To install the library, you can simply clone the repository: opendevice-lib-arduino
git clone https://github.com/OpenDevice/opendevice-lib-arduino OpenDevice
Rename the folder to "OpenDevice" and And put in the "/libraries" folder of the Arduino IDE.
Tip |
---|
Remember that some examples in the this library need extra libraries that must be downloaded and enabled in the configuration file: dependencies.h |
...
Now you must see the LED blinking in the Arduino
...
Adding Hardware
Now that you have control of the gates of Arduino, you can control various devices such as lamps, fans, coffeemakers, robots, etc. ..
To control this type of device you will need a relay, which is a device capable of controlling high voltages.
Example:
Info |
---|
Some relay modules are active-low, ie they are triggered with a negative pulse, in which case you can configure it like this: ODev.addDevice("light", 9, Device::DIGITAL)->invertedState(); |
Reference: http://openenergymonitor.org/emon/buildingblocks/mains-ac-relay-module
Tutorial: http://www.instructables.com/id/Connecting-a-12V-Relay-to-Arduino/
Info |
---|
In this example we created our own application to connect and manipulate devices directly, this model is very similar to Android development. The OpenDevice project provides a standard server (opendevice-middleware) that contains a dashboard for management, visualization, and storage that you can use and customize to create your project. The examples and code used in this tutorial and others can be found here: |
See next step: Adding REST Support
...