The objective of this demonstration is to show you how to control an Arduino UNO using COHORTE. In particular, we will export the functionality provided by the Arduino as a Service and then use this service as a representative component of the Arduino. This avoid as to implement low level routines to control the Arduino and allow a seamless integration with other application components (using remote services).
You can download the provided COHORTE node using the following link :
Connect the Arduino UNO with your computer, and choose the right port in the menu :
Compile and send the code to the Arduino UNO :
Raspberry code
The downloaded demo bundle contains the following files :
repo/led_uno_wrapper/led_uno_wrapper.py
The concrete port used by your Arduino is provided as component proprty (see composition file).
repo/web_viewer/viewer.py
conf/composition.js
Update the “serial.port” propery and put the concret serial over usb port used between the raspberry and the arduino UNO.
Running
Connect the Arduino UNO with the Raspberry.
Ensure to have COHORTE installed in your Raspberry system (choose Python-distribution from the download page).
Go to led-gateway folder of the downloaded zip file and launch COHORTE node:
$ ./run
Open a web browser with the following address: http://localhost:9000/admin
Click on the app-isolate isolate which contains the led-viewer component, and then click on the HTTP SERVICE link on the showed modal window. This will open the http server page of this isolate on which a list of the published servlets is showed. Ckick on /leds link to access the led-viewer page.
Viewer web page :
You can control now the LED of the Arduino using the ON/OFF button of the web interface.
Final remarks
You can give a static url path to your viewer’s container so that you can access it using your web mobile browser without retyping the url each time.
We can deploy the viewer anywhere we want. If your deployment infrastructure is limited to a local network area, you can start COHORTE in HTTP mode.
You can add an intermediate component that controls a set of LEDs (or Arduinos). This depends on your needs for one specific scenario. Thanks to COHORTE your Arduino is seen as a service which can be consumed locally or remotely with no supplemental efforts.