This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WeatherDuino AQM II
#11
(19-02-2020, 00:09)Werk_AG Wrote:
(18-02-2020, 23:07)engolling Wrote: Hi Stefano,

could you please try to explain me which goal you want to reach?

Because the AQM II sets up a web server in your local LAN whichs answers with the JSON data if there is a query.

Your php script uses http get to transmit some signals - but I do not understand what you are trying to do because you first have to get them from your AQMII before you can transmit it to a webserver. Huh

Regards,
engolling

@Engolling, the AQMII can send the data to a web server, exactly the same way the Pro2 PLUS or Compact do.
The php script included on the Pro2 PLUS software package can be used as an example, but obviously, it need to be modified according to personal needs.

Now I understand how it was intended.
I somehow was confused what should be done Blush
Reply
#12
Hi all, I have understood the problem

In PHP script you should use $_POST instead of $_GET.

Now works well.

In future release, are you planning to integrate a WiFi access point to set at least some options without reprogramming it (like WiFi credentials, ...)?
If you want I should have something that I made some time ago
Reply
#13
(19-02-2020, 14:20)Stefano90 Wrote: Hi all, I have understood the problem

In PHP script you should use $_POST instead of $_GET.

Now works well.

The php script I posted as example uses GET and it works.

(19-02-2020, 14:20)Stefano90 Wrote: In future release, are you planning to integrate a WiFi access point to set at least some options without reprogramming it (like WiFi credentials, ...)?
If you want I should have something that I made some time ago

Thank you. No plans to go in that direction. WeatherDuino devices are intended to be used by the users who build them.

Rgs
Reply
#14
Hello everyone,
I noticed a small problem, in case electricity go down for any reason, then first turn on the WeatherDuino AQM that the router (the router takes longer time to turn on) , the device doesn't communicate, you have to restart it after the router is already on. Could we find a code like a wacthdog to fix the problem?
Reply
#15
Hi Stefano90,

A periodic check of the Wifi connection, was already implemented on the software of some WeatherDuino devices, as is the case of the WiFi Wireless Display units, and its planned to be added to the Air Quality Monitor II on next software release.
MeteoCercal - Air Quality Data
Click here to watch at my ThingSpeak channel



Reply
#16
Hi all, I saw the new software release of AQM II, what are changes in version 2.20?
Reply
#17
Hi,

For now, in the case of the AQM II, just what is said here: Bulk software upgrade

Future versions will also use JSON 6.x, so its a good time to upgrade.

Rgs
Reply
#18
(19-02-2020, 03:36)Werk_AG Wrote: Hello again Stefano,

Regarding the PHP script, I wrote a small version to help you.



- Upload it to the root of your webserver
- In Credentials (AQMII software) use:
Code:
// --------------------------------------------------------------------------------------
// My Server Credentials
// --------------------------------------------------------------------------------------
const char* My_Server = "YOUR WEB SERVER ADDRESS"; // Put here your server address (Example: www.myserver.com)
const char* Path_To_LogToSQL_PHPfile = "/AirQuality_Log.php"; // Name and path to AirQuality_Log.php file on My Server


#define MYSERVER_KEY "test" // Your private key for uploading AQM data to your

Reprogram you AQMII device and wait until the AQMII sends data to your web server, which happens at each 15 minutes.

You can also test the script by typing this in your browser:
Code:
http://YOUR WEB SERVER ADDRESS/AirQuality_Log.php?privatekey=test&DevID=MyAQMII&PM25=10&PM100=20&AQI=30&CO2=40

In the AirQuality_Log.txt file you should get something like this:
Code:
[2020-02-19 02:22:54];MyAQMII;10;20;30;40;

I tested the script, so I know it is working.

Hi,  good afternoon to all, 

I tried the sample script by typing the code    "http://MY WEB SERVER ADDRESS/AirQuality_Log.php?privatekey=test&DevID=MyAQMII&PM25=10&PM100=20&AQI=30&CO2=40" in my browser and it works. In my server I find the txt file as described above. The issue is that updating the AMQ scretch with the same data,  the AirQuality_log.txt did not receive any upgrate. It is my first time with the PHP files.  What I wrong? Thank you.

I forgot to say that I have ENABLE_AQM_TO_MYSERVER to 1, wifi to 1 and RF TX to 1
Reply
#19
(26-04-2020, 13:26)bombenm Wrote: ... The issue is that updating the AMQ scretch with the same data,  the AirQuality_log.txt did not receive any upgrate. It is my first time with the PHP files.  What I wrong? Thank you.

Hi bombenm,

That is the normal behaviour of the example script published some posts above.

If you want to add a new line on the log file for each register, edit the example script and just change this line:

Code:
$fp = fopen($logfile, 'w');

to

Code:
$fp = fopen($logfile, 'a');

Please note that this isn't the best way of keep a log of the AQM data, the better way is to use a script which insert each new received data in a SQL data base.

Here is another example script, which inserts data on an SQL table, please note that you should first create the SQL db and the table.
Also note this example script automatically delete records old than "retainUnit"


PHP Code:
<?php

// AirQuality_LogToSQL v1.2
// 14/06/2018
// Add some description here...


// EDIT THIS NEXT SECTION CAREFULLY
// ----------------------------------------------------------------
// Your security key you will pass in the URL, change this to
// something unique to you
//$key = 'letmein';
//
// The server host name or number running your MySQL database
// usually 127.0.0.1 or localhost will suffice
$dbhost '127.0.0.1';
//
// The username used to log-in to your database server
//$dbuser = 'user';
//
// The password used to log-in to your database server
//$dbpassword = 'password';
//
// The name of the MySQL database we will store the tables in
//$database = 'database';
//
// A better way of entering your login details is to put them in a separate script
// and include this here. This script should be placed in an area accessible to PHP
// but not web users. Your login details will not then be exposed by crashing this
// script.
// e.g. ...

include ('/FULL_PATH_TO/db_rw_details.php');


// Enable debug messages? Always disable for production use
$debug false;


date_default_timezone_set('Europe/Lisbon');
$timestamp date('Y-m-d H:i:s');
$logfile './logs/AirQuality_Log.txt';
$param_table 'AirQuality';                    // This is the name of the table to store AQM data
$param_retainVal 3;                           // Amount used by the retainUnit 
$param_retainUnit 'week';                     // Valid Values: 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year');
$param_privatekey '';
$param_PM25 0;
$param_PM100 0;
$param_AQI 0;
$param_CO2 0;
$param_DevID "N/A";
$lf "\n";


if (!empty(
$_GET['privatekey']))
 {
  
$param_privatekey $_GET['privatekey'];
 }
if (!empty(
$_GET['PM25']))
 {
  
$param_PM25 $_GET['PM25'];
 }
if (!empty(
$_GET['PM100']))
 {
  
$param_PM100 $_GET['PM100'];
 }
if (!empty(
$_GET['AQI']))
 {
  
$param_AQI $_GET['AQI'];
 }
if (!empty(
$_GET['CO2']))
 {
  
$param_CO2 $_GET['CO2'];
 }
if (!empty(
$_GET['DevID']))
 {
  
$param_DevID $_GET['DevID'];
 }
 
// check for the 'private' key
if ($key !== '' && $param_privatekey !== $key) {
    die(
'Error: Failed security key check:' $param_privatekey);
}
 

$conn = new mysqli($dbhost$dbuser$dbpassword$database);
if (
$conn->connect_error)
 {
   
//die("Erro ao conectar ao servidor MySQL: " . $conn->connect_error);
 
}

$sql "INSERT INTO " $param_table " (LogDateTime, DeviceID, PM25, PM100, AQI, CO2) VALUES ('" $timestamp "', '" $param_DevID "', '" $param_PM25 "', '" $param_PM100 "', '" $param_AQI "', '" $param_CO2 "')";
$conn->query($sql);

if (
$param_retainVal 0)
 {    
   
$DeleteEntries "DELETE IGNORE FROM $param_table WHERE LogDateTime < DATE_SUB(NOW(), INTERVAL $param_retainVal $param_retainUnit )";
   
$conn->query($DeleteEntries);
 }   
$conn->close();

 
$fp fopen($logfile'w');
chmod($logfile0770);
fwrite($fp'['.$timestamp.'];'.$param_DevID .';'.$param_PM25 .';'.$param_PM100 .';'.$param_AQI .';'.$param_CO2 .';');
fclose($fp);
   
?>

Code above may / should be changed / adapted for each personal case.


Below is an example of the db_rw_details.php file


PHP Code:
<?php
// EDIT THIS NEXT SECTION CAREFULLY
// ----------------------------------------------------------------
// Your security key you will pass in the URL, change this to
// something unique to you
$key="YOUR_KEY";
//
// The server host name or number running your MySQL database
// usually 127.0.0.1 or localhost will suffice
$dbhost     "127.0.0.1";
//
// The username used to log-in to your database server
$dbuser     ="DB_USER";
//
// The password used to log-in to your database server
$dbpassword    ="DB_PASSWORD";
//
// The name of the MySQL database we will store the tables in
$database    ="DB_NAME";
?>


Rgs
Reply
#20
I think I understand.
I am grateful to you for your examples. 

Have a great day. 

V/R 
Bomben Mauro
Reply




Users browsing this thread: 1 Guest(s)