====== Storing data into Mervis DB ====== In this tutorial, we are going to demonstrate how to use history logs for long-term storing of data from Unipi controllers running Mervis OS. ;;# Patron \\ Neuron \\ Gate \\ Unipi 1.1 \\ Axon ;;# Prerequisites * Unipi controller running Mervis OS * 24 V⎓ power supply * Mervis IDE project created according to [[storing-data-to-history-log-hidden|Storing data to history log]] * [[en:sw:01-mervis:03-mervis-db|Mervis DB]] credentials The Mervis DB credentials are generated together with the Mervis SCADA project and are intended for all PLCs connected to this SCADA project. ---- If you are only interested in the Mervis DB without Mervis SCADA, please [[https://www.unipi.technology/contacts|contact our sales department]] for an individual offer. ===== PLC properties settings ===== The first step is to [[storing-data-to-history-log-hidden#memory_storage_settings|set up the storage]]. /* Přeložit z CZ - rozděleno na dva odstavce */ If you wish to use the Mervis DB service to back up variables using our servers, you need to set its communication parameters first. In the **left panel**, select PLC. {{ :en:sw:01-mervis:storing-data-to-mervis-db-02.png?direct |}} Approximately in the middle of the PLC's properties a section **Mervis DB Parameters** is located. Set its values to the following: * **Enable**: set to true to enable the logging * **URL**: the URL of the Mervis DB service. For controllers running **Mervis OS v2.3.0 or newer**, use ''https://db.unipi.technology/plc/save''. For the rest, use ''http://db.unipi.technology/plc/save'' * **Communication period [min]**: this is the period in which the PLC will send the gathered data * **Certificate validation**: set to ''FALSE'' by default, more info in the [[en:sw:01-mervis:ssl-certification-validation-hidden|Certificate validation]] * **Username**: the Mervis DB username * **Password**: the Mervis DB password Mervis DB credentials are available in the [[https://www.unipi.technology/customer/scada/|Mervis SCADA project administration]] (customer portal). Observant users probably realized we just entered a second different time parameter, namely the **Communication period**. What's the difference? The Save Period defines how often the PLC will sample variable values. The Communication Period is how often the PLC will send those samples to the Mervis DB. \\ * **Communication Period** defines how often will PLC send data to Mervis DB. Can be set in **PLC Properties** * **Save Period** determines how often will PLC parse variable values. Can be configured in the **History log**. Since we changed the configuration of the PLC, we need to upload it. Right click on the PLC in the **Left panel** and select the PLC Operation -> PLC Setup -> Upload configuration. If you are not sure, check out the [[en:sw:01-mervis:updating-a-runtime-configuration-hidden|Uploading a RunTime configuration]] tutorial. {{ :en:sw:01-mervis:storing-data-to-mervis-db-03-upload-configuration.png?direct |}} You will be asked how to connect to the PLC. If you are on the same network, you can select **UDP Broadcast**. If not (ie. you connect to the PLC via Mervis Proxyn), select **Use deploy parameters** and confirm by clicking on **OK**. {{ :en:sw:01-mervis:storing-data-to-mervis-db-04-probing-method.png?direct |}} Deploy the solution, start the Debugging Mode and open the **System status** tab located on the **main panel**. In the **MervisDB** section (or **RcWareDB** in older versions of the IDE), you can check if the PLC communicates with Mervis DB. If the **Communication interval [min]** is set to 1 minute, the **Records saved** value will increase every 60 seconds. {{ :en:sw:01-mervis:storing-data-to-mervis-db-12-system-status.png?direct |}} Let's move into the Mervis DB Viewer - a web tool for analyzing data stored by controllers. Open a web browser and enter [[https://db.unipi.technology/viewer|]] address. A login screen will appear - enter the login info used in the PLC settings. Upon entering them, click on **Set** and then on **Close**. If Mervis DB fails to display data even if you configured everything correctly, it is probably caused by the fact Mervis DB does not have any logged data yet. Close the Mervis DB Viewer and wait until the first log is uploaded - the required time for this varies depending on communication intervals set for the PLC and DB, or on the history log interval. The interval can be synchronous (eg. with a fixed upload time) or asynchronous (the interval depends on how long it takes for data to be logged). If the issue persists even then, check Mervis DB login and password, make sure the address is set correctly and also make sure you [[en:sw:01-mervis:updating-a-runtime-configuration-hidden|uploaded the configuration into the PLC]] correctly. {{ :en:sw:01-mervis:storing-data-to-mervis-db-10-mervis-db-viewer-login.png?direct |}} Mervis DB web interface will open. In its **left panel** your PLC should be visible, identified by the name you entered into **History runtime identification**. Check the box next to their names to start plotting their data in the graph. {{ :en:sw:01-mervis:storing-data-to-mervis-db-11-mervis-db-viewer-workspace.png?direct |}} Using the cursor you can display parsed data values, set various different graph types and many more options.