This recipe sends one CSV file per day of meter readings to a remote FTP or SFTP server, for example the import folder of an energy management system (EMS). The CSV driver builds the files, the FTP driver uploads them, and a few settings make the chain survive power cuts, restarts and server outages without losing or duplicating files.
Checked against: firmware r9347. Licences: the CSV driver and the FTP driver are licensed features (contact support@weble.ch). Level: installer.
At the end of this recipe, a file such as log_24_11_2026 00_00.csv with the readings of the previous day is uploaded every night after midnight to a folder of the server, and any file that could not be uploaded is sent again later.
You need:
Insert a gateway of type CSV, add the data points (manually or with the drag & drop wizard, see CSV — Getting started), then review these parameters:
| Parameter | Recommended value | Why |
|---|---|---|
| File Storage | DISK (or USB) |
RAM loses the files at each reboot. With USB, the gateway does not start when no key is plugged in. |
| File Cron | 0 0 * * * (default) |
One file per day, closed at midnight. The completed file is uploaded right after. |
| File Name | log_<dd_mm_yyyy HH_MM>.csv (default) |
Each file needs a unique name: the transfer routes remember the files already uploaded by their name. Keep a date in the name, and avoid : and other characters forbidden in Windows or USB file names. |
| Create File Addresses | ticked | Needed by the transfer: each completed file gets its own address %csv_file/<file name>, which the routes use to upload the files and to send again the missing ones. It is unticked by default on a new gateway. |
| Flush Entries | cron |
With the default on file rotation, the rows of the current day stay in memory until midnight and are lost on a power cut. |
| Flush Entries Cron | */5 * * * * (default) |
Writes the pending rows to the storage every 5 minutes. |
| On Restart | append with headers |
Keeps the rows already written when the gateway restarts, instead of starting a new file (start new file, the default, discards them). |
| File Max Number | 365 (default) |
Number of files kept on the gateway: one year with one file per day. Keep enough to cover a long outage of the server. |
Then adjust the format to the receiving software: CSV Separator, Date Format, Decimal Separator, File Format (data by columns or data on multiple rows), Entry Interval (default 15 minutes) and Entry Resolution. All are described in CSV — Gateway parameters.
Tick Create File Addresses and set On Restart before the first data points are added: adding points restarts the gateway, and each restart applies On Restart.
Insert a gateway of type FTP:
| Parameter | Value |
|---|---|
| Protocol | sftp (recommended) or ftp |
| Host | IP address or domain name of the server |
| Port | 22 for SFTP. The form always proposes 22: type 21 yourself for FTP. |
| Username / Password | the account on the server. Do not leave Username empty. |
| Directory | the base folder of the account, for example / or /home/ems |
| Connection State | Keeps it open (default) |
Start the gateway. It turns connected and creates the address %ftp (the base folder). If the files must go to a sub-folder, right-click %ftp and choose Read directory: the sub-folders appear as addresses such as %ftp/inbox.
%ftp or %ftp/inbox). Only folders can be selected.| Route | What it does |
|---|---|
| CSV transfer | Uploads each completed file (%csv_file/last.csv) as soon as it is closed, under its own name. An existing file of the same name on the server is replaced. |
| CSV transfer history | Keeps the list of the files already uploaded, and uploads those that are missing: each time the CSV or the FTP gateway reconnects, and again 10 to 30 minutes after an upload that was not confirmed. |
The history route is what makes the export reliable: after a server outage, a network cut or a reboot, the files of the missing days are uploaded automatically, as long as they are still stored on the gateway (File Max Number).
The same button can also create a route to an SMTP address, to receive each file as an e-mail attachment.
The FTP gateway logs every transfer in its address %ftp_logs:
ul stream on "%ftp/inbox/log_24_11_2026 00_00.csv" bytes: 5120 finished (1 s);ended with error "<reason>".To test without waiting for midnight, right-click a completed file %csv_file/<file name> and download it to check its content. Then check on the server, the next morning, that the file of the previous day is there.
| Symptom | Cause and fix |
|---|---|
Nothing is uploaded, %ftp_logs stays empty |
Create File Addresses is unticked on the CSV gateway, or the routes were not created. Tick the option, then check the two routes in the Routes table. |
| The FTP gateway does not connect | Wrong protocol / port pair (sftp with 22, ftp with 21), host, credentials or firewall. The driver log shows the connection messages. |
| The server was unreachable for some days | Nothing to do: when the FTP gateway reconnects, CSV transfer history uploads the missing files. If the outage lasted longer than File Max Number files, the oldest ones are no longer on the gateway. |
| The file of the day is missing some hours after a power cut | Flush Entries is still on file rotation, or On Restart is start new file. Apply the settings of section 2. |
| A file is never uploaded again although it is missing on the server | Its name is already in the list of uploaded files (for example after the file was deleted on the server). Upload it manually: right-click the FTP folder, Upload file. |
The CSV gateway does not start with File Storage USB |
No USB key or SD card is plugged in. |
missing license in a driver log |
The CSV or FTP licence is missing. |
%ftp_logs.