From 285d5fbae476de2c25ec3b3a20bc5dd5042933b1 Mon Sep 17 00:00:00 2001
From: Dorchies David <david.dorchies@irstea.fr>
Date: Wed, 1 Jul 2020 18:01:53 +0200
Subject: [PATCH] doc: Update README.md with installation and running
 instructions

---
 README.md | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index cb1a206..d824acd 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,49 @@
 # SGLdataGrabber
 
-R package for grabbing data from Seine Grands Lacs web site (https://seinegrandslacs.fr/fr/quatre-lacs-reservoirs-au-coeur-dun-bassin) and store them on a Thingsboard IoT platform (https://thingsboard.io/).
\ No newline at end of file
+R package for grabbing data from Seine Grands Lacs web site (https://seinegrandslacs.fr/fr/quatre-lacs-reservoirs-au-coeur-dun-bassin) and store them on a Thingsboard IoT platform (https://thingsboard.io/).
+
+## Requirements
+
+Windows or Linux OS with R version 3.5+ installed.
+
+An instance of Thingsboard with a dedicated device for storing all the data.
+
+## Installation on Linux
+
+This procedure installs libraries in the folder `~/R_LIBS` of the current user.
+
+```shell
+cd ~
+mkdir R_LIBS
+echo "R_LIBS='$(pwd)/R_LIBS'" > .Renviron
+Rscript -e "install_packages(c('roxygen2','httr','jsonlite','textutils','dplyr'), lib = 'R_LIBS')"
+git clone https://gitlab.irstea.fr/in-wop/sgldatagrabber.git
+cp .Renviron sgldatagrabber/
+cd sgldatagrabber
+Rscript -e "roxygen2::roxygenise()"
+cd ..
+R CMD build sgldatagrabber
+Rscript -e "install_packages('SGLdataGrabber_0.1.0.tar.gz', lib = 'R_LIBS')"
+```
+
+## Run the script
+
+Create a R script (let's call it `~/run_SGLdataGrabber.R`) with the following lines:
+
+```R
+library("SGLdataGrabber")
+thingsboard_UploadTelemetry(
+  "http://[domain.tld]/api/v1/[my_token_device]/telemetry",
+  SGL_GrabAllVariables()$Data
+)
+```
+
+With `[domain.tld]` the URL of your Thingsboard instance and `[my_token_device]` your own device token given by your Thingsboard platform.
+
+And then run your script:
+
+```shell
+cd ~
+R run_SGLdataGrabber.R
+```
+Be careful of having the `.Renviron` file containing at least `R_LIBS='~/R_LIBS'` in the folder where R is executed in order to use local R installed packages.
-- 
GitLab