Arduino Function: Ciao FILE Connector


Arduino Ciao is a easy-to-use and powerful technology that enables Arduino sketches to communicate intuitively with the "outside World".
It aims to simplify interaction between microcontroller and Linino OS. It’s compatible with all version of LininoOS but you will need to install it manually.
See here for installation instructions.

Ciao provides already some "internal" Connectors like MQTT, Shell, File, Rest, Rest Server and other available on repository.
The "internal" Connectors can be used setting up few parameters on LininoOS side and few lines on an Arduino sketch.

In particular here it is shown the File Connector.
This Connector allows to read and write a file on Linux side from an Arduino sketch.
Below the steps that you should follow to use the File Connector:

  1. Setup File Connector;
  2. enable the Connector;
  3. write a simple sketch;
  4. upload the sketch and enjoy.

Setup connector

Before using Ciao File Connector you have to configure it properly, this can be done by editing its configuration file.

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


 "name" : "file",
 "description" : "File System connector for Ciao",
 "authors": ["Arduino Team <>;"],
 "repository" : "",
 "version" : "0.0.1",
 "params" : {
              "root" : "/root",
           "eol" : "\n",
            "read_line" : false,
              "read_max_size" : 1024,
             "default_write_access_mode" : "w"
 "log" :{
          "level" : "debug"

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:

  • “root”: specifies the starting directory for relative Path.
  • “eol”: specifies the End of Line symbol.
  • “read_line”: specifies how to read the file, line by line (true) or entire (false).
  • “read_max_size”: specifies the maximum value that it can be read each time.
  • “default_write_access_mode”: specifies the write access mode, w to overwrite the file, instead a to write in append mode.

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 File Connector please edit the file at the following path:/usr/lib/python2.7/ciao/conf/file.ciao.json.conf

 "name" : "file",
 "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 File Connector. Once done Ciao Core will be ready and configured to use File Connector.

Let's write a simple Arduino sketch to use it.

Write a simple sketch

The example below shows how to use File Connector to open a file in write mode, overwriting it, and write into digital value of the specified pin.

#include <Ciao.h>
int buttonPin = 5;
int pressed = 0;
void setup() {
              //init Ciao
              pinMode(buttonPin, INPUT);
void loop() {
             //Read digital input
             pressed = digitalRead(buttonPin);
             //Write value into a file in root folder. Root folder is specified into the connector
             //configuration file: /usr/lib/python2.7/ciao/connectors/file/file.json.conf
             //Else you can specify the absolute path for the file, eg: /tmp/my-file.log
             Ciao.write("file","button.txt", (String)pressed, "w");
            //Delay the operations because IO is slow
For more information or examples about Ciao connector visit:

Written by