Arduino Control using Communication Bridge

Hi !!
This is my first post in forum.

I want to introduce a program called “ArduinoWing” that was developed by Implit Co., Ltd. ArduinoWing is a kind of communication bridge program for Arduino…

The PC that is running ArduinoWing act as a kind of RESTful API server of KVT(Key Value Table) that is announced from the Arduino sketch… The PC and Arduino is connected by USB cable that same cable used to upload sketch to the Arduino board.

AruidnoWing provides RESTful API service of the key/value pair of the data(KVT) announced from Arduino sketch (with very simple ArduinoWing API function). And also provides control mechanism to the Arduino sketch by callback function with key/value pair parameter.

It can be easily implemented to control and view data of Arduino by simply adding ArduinoWing API into existing Arduino sketch.

Following is simple example about how to monitor temperature and humidity value and control LED of Arduino using internet browser.

  1. download attached ArduinoWing sketch source

#include <dht.h>
#include <ArduinoWing.h>

dht DHT;
#define DHT11_PIN 2
#define LED_PIN 8

// pass callback function
ArduinoWing arduinoWing(callBack);

void setup()
{
Serial.begin(9600);
Serial.println(“Begin…”);
pinMode (LED_PIN, OUTPUT);
}

String humidity;
String temperature;

void loop()
{
Serial.println(“Loop…”);

int chk = DHT.read11(DHT11_PIN); // READ DATA

switch (chk)
{
case DHTLIB_OK:
Serial.println(“OK”);

/*
send key/value pair using put function,
you can view key/value pair through the RESTful API
*/
humidity = String(DHT.humidity);
Serial.println(“temperature\t” + humidity);
arduinoWing.put(“humidity”, humidity);

temperature = String(DHT.temperature);
Serial.println(“temperature\t” + temperature);
arduinoWing.put(“temperature”, temperature);
break;

case DHTLIB_ERROR_CHECKSUM:
Serial.println(“Checksum error,\t”);
break;

case DHTLIB_ERROR_TIMEOUT:
Serial.println(“Time out error,\t”);
break;
default:
Serial.println(“Unknown error,\t”);
break;
}

arduinoWing.loop(); // receive control request
delay(1000);
}

/*
This callback function will be called when ArduinoWing accepts control request.

In this example, if key is led and value is 0, turn off led
or turn on led
*/

void callBack(char *key, char *value)
{
if (strcmp(key, “led”) == 0)
{
digitalWrite(LED_PIN,strcmp(value, “0”) == 0 ? LOW : HIGH);
Serial.print(“led\t” + String(value));
arduinoWing.put(“led”, value);
}
else
{
// not defined Key
}
}

  1. import ArduinoWing library and compile above sketch

void put(String key, String value)

Announce key/value to ArduinoWing, This key/value pair can be shown using RESTful API(also can be see the key/value using internet browser)

void loop()

ArduinoWing heart beat function, this function must be called periodically.

  1. download ArduinoWing Program
    download
    link here windows, OSX, linux

  2. excute ArduinoWing


5. Next, type http port to use to connect http server. If you want to http authorization, type id, pw. Select your Arduino port. Click Start

  1. connect http://[your IP]:[port] using internet browser to ArduinoWing.


7. Key list

This menu can view list of keys announced from Arduino sketch using “put” function of ArduinoWing


8. Key Value

This menu can view value of selected key item, can select last value or value history.


9. This menu provides Arduino sketch control mechanism. When you click “Send” button, the ArduinoWing callback function will be invoked with the key/value specified.
In this example, select led, set value to 0 and click Send, you will see turn off LED.

The context of “Serial.print” function will display on the ArduinoWing application’s log window.
ArduinoWing use same USB serial port as Arduino IDE. So, when ArduinoWing is started, the USB serial port is under control of ArduinoWing. To use Arduino IDE to upload sketch, you must stop ArduinoWing.

Also, you can get ArduinoWing Client application for android here [Download link] or search “ArduinoWing” in google play store

arduinowing_dht_led.ino (1.68 KB)

ArduinoWing_0.0.1.zip (10.9 KB)