Watmonitor project cloning
If you are using Watmonitor (a web interface for a level meter) from Your-IoT to measure the water level in a well, retention tank, or measure the height of bulk materials in a silo, storage tank, you may have encountered a limitation of Watmonitor if you wanted to use multiple sensor nodes. Each instance of the Watmonitor interface is tied to one sensor node / device. If multiple devices write to it, the data gets mixed. Therefore, today we will show you how to clone the project and create multiple Watmonitor interfaces that will work independently of each other and you can set a specific device in each.

Cloning itself, or rather copying, is simple. You copy the project to any folder within the domain / localhost. But the steps after will be more important, since there are several options for running the cloned version independently of the original and they differ in complexity / need to edit a larger number of files.
The easiest way for ordinary users - a separate database (under one server):
In the SQL administration (e.g. phpMyAdmin), create a new database, which you can achieve by clicking on "New" in the menu on the left after logging in with your username and password. Define a name for the database and create it. The created database will then be displayed in the menu on the left.

After clicking on the created database, go to Import from the top menu. Make sure you are in the correct database, which you can also see in the text Importing to database, with the current database selected in quotes. Select the export.sql file with the table structure, which is part of the Watmonitor archive in the sql folder. After a successful import, a table named "studna2" will be created under the given database.

The final edit awaits you. You need to change the database that the entire Watmonitor will use. Go to the connect.php file and overwrite the database name, which is the last parameter in the mysqli_connect() function, which also contains other user data (name, password). This way you will get separate Watmonitor interfaces that work independently of each other and each works only with its own data.

Similarly, it could be solved with different SQL servers. For example, many hostings have several separate systems, so the change in such a case would only affect the specific server defined in connect.php and the database name would not have to change either, it could be with the same name on each server, it doesn't matter. It's up to you what sensor node you use in the project, whether DIY with Arduino, ESP32, or ESP8266, or an industrial solution.

Multiple tables in one database
Not all hostings allow you to create more than one database. As a result, you can also overwrite the name of the table being created in the export.sql file and use this file to create multiple tables for separate Watmonitor interfaces under one database, which will be, for example, in separate folders under the /localhost domain. However, this will be a more lengthy modification, since you have to change the table in all .php files that work with the database (the default is studna2).
In this case, the database does not change and is the same, so the modification does not affect the connect.php file. Editing the table name into a variable could be easier for future cloning, but the system currently does not have this option. Therefore, this method is less recommended, because it is possible that there will be an error rate, since such an adjustment is laborious. Even if the interface does not work after the modification, you can still return to the original version of the Watmonitor digital product.

For both methods, each Watmonitor interface automatically generates source code for ESP32 (WiFi / PHY Ethernet variant) based on the current depth / folder relative to the root folder. As we can see, one Watmonitor interface in the root folder, the other in the WM folder, the automatically generated source code for the microcontroller takes this into account and finds the correct path to the data.php file, which writes data to the Watmonitor database. Both interfaces ran on the same domain, identical server. Regardless of whether the database or table was changed, it is a matter of the code and files in the folder.


Time data
Watmonitor uses database time exclusively in its web application. Thanks to this, there can be no time incompatibility between PHP and the database due to different time zones. Watmonitor works with the time zone that you have preset in the database. If necessary, change the default time zone to Europe/Bratislava, which will display the correct time of measurements in Watmonitor + will also solve the transition to winter / summer time and you will always have the correct time stamp for current records. However, it should be noted that not every web hosting will allow you to do this, sometimes you are unfortunately unlucky.
More about Watmonitor with the possibility of trying it for free with your hardware on test interfaces can be found at: https://your-iot.github.io/Watmonitor/
