Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
using_weatherduino_pro2_upload_data_website_database_sql [2018/05/20 22:12] – werk_ag | using_weatherduino_pro2_upload_data_website_database_sql [2021/04/05 05:37] (current) – werk_ag | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | //By [[http:// | + | |
+ | //By [[http:// | ||
- | **Using WeatherDuino Pro2 PLUS to upload | + | ==== Upload and record Air Quality |
- | **(Available in Receiver Software Release v6.x onwards)** | + | |
A Brief “How To” Guide. Please note that this is not a “one for all” guide, settings may be different depending on your server. | A Brief “How To” Guide. Please note that this is not a “one for all” guide, settings may be different depending on your server. | ||
- | + | ==== Step 1: Set up the database on the web server | |
- | **Step 1: Set up the database on the web server** | + | |
* Log into your website’s control panel. | * Log into your website’s control panel. | ||
Line 16: | Line 14: | ||
* Navigate to “MySQL® Users”, usually found as part of the “MySQL® Databases” settings. | * Navigate to “MySQL® Users”, usually found as part of the “MySQL® Databases” settings. | ||
* Create a new user if you do not already have one set up. | * Create a new user if you do not already have one set up. | ||
- | | + | |
- | * Create a password | + | * Create a password |
- | * Select the database you would like that new user to be associated with. | + | * Select the database you would like that new user to be associated with. |
- | {{: | + | {{: |
- | {{: | + | {{: |
- | \\ | + | |
- | **Step 2: Enable remote control (This step may not be required)** | + | ==== Step 2: Enable remote control (This step may not be required) |
For security, by default the web server will be protecting itself from remote unauthorised access which could modify or damage the data. Permission may need to be granted to allow your IP address assigned by your internet provider to write to your databases remotely if you host is not local. | For security, by default the web server will be protecting itself from remote unauthorised access which could modify or damage the data. Permission may need to be granted to allow your IP address assigned by your internet provider to write to your databases remotely if you host is not local. | ||
Line 33: | Line 30: | ||
* Enter your IP address into the “Add Access Host” and save it to the list. | * Enter your IP address into the “Add Access Host” and save it to the list. | ||
- | ** | + | ==== Step 3: Setting up the database structure / creating a new table ==== |
- | Step 3: Setting up the database structure / creating a new table** | + | |
Now a table to store all the data in needs to be created within the newly created database. | Now a table to store all the data in needs to be created within the newly created database. | ||
Line 46: | Line 42: | ||
* Here is an example of the Air Quality table with the columns named and parameters set. | * Here is an example of the Air Quality table with the columns named and parameters set. | ||
- | Additional columns can be created later on and parameters changed if the settings are not right first time around.\\ | + | Additional columns can be created later on and parameters changed if the settings are not right first time around. |
+ | |||
+ | {{: | ||
- | {{: | ||
- | \\ | ||
==== Step 4: Configuring the PHP Scripts ==== | ==== Step 4: Configuring the PHP Scripts ==== | ||
Line 55: | Line 51: | ||
* Open “db_rw_details.php” and set the credentials. Remove the X’s and replace with your personal details between the quote marks. | * Open “db_rw_details.php” and set the credentials. Remove the X’s and replace with your personal details between the quote marks. | ||
- | | + | |
- | * $dbhost = " | + | * $dbhost = " |
- | * $dbuser =" | + | * $dbuser =" |
- | * $dbpassword=" | + | * $dbpassword=" |
- | * $database =" | + | * $database =" |
* Open “AirQuality_LogToSQL.php” for configuring this file. | * Open “AirQuality_LogToSQL.php” for configuring this file. | ||
- | | + | |
- | * Locate the timezone setting and update this to your location. The following website can help choose the best timezone name to use for your area: http:// | + | * Locate the timezone setting and update this to your location. The following website can help choose the best timezone name to use for your area: [[http:// |
- | * Choose the path of where the text log should be stored. This is a one line text file which get updated each time the data is uploaded to the website. For example: | + | * Choose the path of where the text log should be stored. This is a one line text file which get updated each time the data is uploaded to the website. For example: |
* Save and upload these two files to your chosen directories on your website. | * Save and upload these two files to your chosen directories on your website. | ||
+ | ==== Step 5: Configuring the Software of RX Unit ==== | ||
+ | |||
+ | The final step is to change the settings on the RX software so it knows where to access the files that have been uploaded to our website. | ||
+ | |||
+ | * Navigate to the “Credentials.h” file. | ||
+ | * Update the “My Server Credentials”. | ||
+ | * Under “My_Server”, | ||
+ | * Under “Path_To_LogToSQL_PHPfile”, | ||
+ | * The “MYSERVER_KEY” is where your “key” set under Step 4 is entered. This is the “handshaking” code which will be checked when data is passed from the outside source to ensure it is legitimate. | ||
+ | * Within the “Config_Options.h” file, the “ENABLE_AQM_TO_MYSERVER” will need to be enabled by changing the “0” to a “1”. | ||
+ | * Assumptions have been made that WiFi has been enabled and configured already within the RX Software settings. This is also a requirement if it has not been enabled. | ||
+ | |||
+ | Once the RX software is compiled and uploaded, it should now start to upload data to the database. This can be checked by logging into the database admin where the data can be viewed. | ||
+ | |||
+ | The data can now be pulled from this database for such things like producing graphs on the website and for many other purposes. | ||
+ | |||
+ | There is a lot of potential going forward for this to not only upload data for the Air Quality monitor (which at time of writing is the only publicly supported option). In the future, this concept could be used to upload all the data gathered by the weather station and have the weather station save the data directly into the database making it a free standing product. | ||
+ | |||
+ | ==== Using SQL Language ==== | ||
+ | |||
+ | Step 3 in this guide could be done by using SQL code if that is of personal preference. “[[http:// | ||
+ | < | ||
+ | |||
+ | DROP SCHEMA IF EXISTS `AQM`; | ||
+ | CREATE SCHEMA AQM; | ||
+ | USE AQM ; | ||
+ | DROP TABLE IF EXISTS `AirQuality`; | ||
+ | CREATE TABLE `AirQuality` ( `LogDateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
+ | |||
+ | </ | ||
+ | {{: | ||
+ | ==== Testing PHP scripts to ensure it writes ==== | ||
+ | A web browser can be used to test the PHP scripts to ensure they write. \\ As an example, this URL if entered into the web browser, should write data into the Air Quality database if it has been set up correctly (change the URL to find the " | ||