diff --git a/README.md b/README.md index cb1a2064175d6b070bab8371acf94b48501a7c7e..d824acd8b6cf293e194e734cca012c2487f62778 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.