Upload CSV of measurements

Latest update: September 2018


Up to 5 measurement value functions can now can registered at the same time.
In order to register the CSV output coming from the equipment (such as the data logger) to the FlashAir IoT Hub as the measured value, it is necessary to read the CSV file with a Lua script and then register it.
It's convenient to directly register a CSV as a measured value!

In this tutorial, we will walk through the procedure of uploading the value of the CSV file on FlashAir to the IoT Hub as a measured value.

Preparation work

  1. Please prepare to be able to connect from your FlashAir to the FlashAir IoT Hub in advance referring to flow of usage.
  2. Please check that there is a file called upload_csv.luadirectly under the root folder of FlashAir. If not, download the latest script from 'Script' at the top of the IoT Hub site.
  3. Add or rewrite LUA_SD_EVENT=/upload_csv.lua to CONFIG.
  4. Restart the FlashAir by pulling it in and out.

Upload CSV

  1. Prepare the CSV to be uploaded.
    • The first column is fixed to the time information, there is no provision in the name.
    • The name specified in the second and subsequent columns is stored in the server and you can specify up to 100 unique column names for the cumulative total.

  2. Copy and write the CSV file on FlashAir.
  3. Select the label to be displayed from the pull-down.
  4. The values are displayed in the graph of Measured value (CSV) of the IoT Hub site.

Screen operation

  1. Add / Remove button

    You can display graphs by aligning them vertically, and you can add / delete graphs to be displayed with buttons. Up to 10 graphs can be added.

  2. Label

    In a CSV upload, values on the first and second rows and after are automatically registered as labels (legend names on the graph) and displayed in the pull down. During that time, if you upload CSV files with different labels, both labels will be registered.

    Example: When CSV of time,label001,label002 and time,label001,label003 are registered on the first line of CSV, three label001,label002,label003 are registered in total.

    However, since the maximum number of labels is 100, if you exceed it, you will not be able to register.

  3. Reset Label

    All labels of the CSV file are not registered if the label registration fails. If this happens, reset the registered label. Please correct the CSV file again after label reset and register again.

Time of CSV

The time format of CSV has the following format.

Absolute time (character string representing time conforming to RFC 3339)

Example of CSV (EDT (Coordinated Universal Time - 4 hours))

Relative time (record the relative time (in milliseconds) from the time of the API execution as the time of the last line of the CSV)

CSV example

When uploading the above example to 9:00:00, it is registered as the time 08:58:00, 08:59:00, 09:00:00 from the top.

The default option is registration at absolute time. However, if you can not acquire the current time with an embedded board or an old FlashAir's Lua etc. and can not be embedded in CSV, use the relative time to complement the time on the server side and register it.

CSV upload (relative time)

Let's upload the file using relative time.

  1. Prepare CSV.
  2. Edit the Lua script upload_csv.lua as follows.


    print("HTTP/1.1 200 Internal OK\n\n")
    local last_fname = ""
    local last_fpath = ""
    local last_modif = 0
    local last_moddir = 0
    local last_dirname = "/"
    local fpath = "/"
    local timestamp_type = "relative"
    • Line 8
      Change from "absolute" to "relative".
  3. Copy and write the CSV file on FlashAir.
  4. Restart the FlashAir by pulling it in and out.
  5. When selecting the graph to be displayed from the pulldown, the value is displayed in the graph of Measured value (CSV).