Reference   Language | Libraries | Comparison | Changes


Rest connector


This connector allows to make “http” requests. Below the steps that you should follow to use the Rest connector:

  • setup Rest connector;
  • enable the connector;
  • write a simple sketch;
  • upload the sketch and enjoy.

Setup connector

You can find Rest Connector configuration file at the following path: /usr/lib/python2.7/ciao/connectors/rest/rest.json.conf

 "name" : "rest",
 "description" : "REST connector for the Ciao Core",
 "authors": ["Arduino Team <>;"],
 "repository" : "",
 "version" : "0.0.1",
 "params" : {

The parameters at the beginning are for internal use, do NOT edit them (name, description, version, ciao) unless you know exactly what you are doing.

The configurable part is the one identified by "params" key: In this Connector there aren’t parameters to set.

Enable connector

Each Ciao connector must have a configuration file for the Ciao Core, this simple file is mandatory to enable the connector.

To enable Rest connector please edit the file at the following path: /usr/lib/python2.7/ciao/conf/rest.ciao.json.conf

 "name" : "rest",
 "enabled": true,
 "type" : "managed",

The key enabled must be set to true (boolean value). This is the only parameter you are required to edit in order to enable the Rest Connector. Once done Ciao Core will be ready and configured to use Rest Connector.


#include <Wire.h>
#include <Ciao.h>
#define CONNECTOR     "rest"
#define SERVER_ADDR   "" // change ip address with your server ip address
int buttonState; //this variable tracks the state of the button, low if not pressed, high if pressed
int ledState = HIGH; //this variable tracks the state of the LED, negative if off, positive if on
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers
String command = "/arduino/mode/13/output";
int previous_value = LOW;
void setup() {
  Ciao.write(CONNECTOR, SERVER_ADDR, command);
  pinMode(2, INPUT);
void loop() {
  //sample the state of the button - is it pressed or not?
  buttonState = digitalRead(2);
  //filter out any noise by setting a time buffer
  if ( (buttonState == HIGH) && (previous_value == LOW) && (millis() - lastDebounceTime) > debounceDelay ) {
    if (ledState == HIGH) {
      command = "/arduino/digital/13/0";
      ledState = LOW;
    else {
      command = "/arduino/digital/13/1";
      ledState = HIGH;
    lastDebounceTime = millis(); //set the current time
    CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, command);
    if (!data.isEmpty()) {
      Ciao.println( "State: " + String (data.get(1)) );
      Ciao.println( "Response: " + String (data.get(2)) );
    else {
      Ciao.println ("Write Error");
  previous_value = buttonState;
Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.