Page 1 of 1

mySQL not working with new sensor variable **solved**

Posted: Sun Oct 25, 2020 9:56 pm
by galfert
With the new PM2.5 air quality variables I am not able to do the mySQL insert query.

Previously '[air0pm-max5=.0]' worked just fine. Now the new variable is '[air0!0pm-max5=.0]' and it doesn't work. I suspect it has something to do with the mySQL not liking the ! symbol in there but I'm not certain. I thought it should work because of the quotes but I'm not certain.

Why does the new variable have to have an exclamation mark in it?

Does anyone have a recommendation on how to resolve this?

Here is my query:

Code: Select all

INSERT INTO `mystation` (`ID`, `DateTime`, `TempOutCur`, `HumOutCur`, `PressCur`, `DewCur`, `HeatIdxCur`, `WindChillCur`, `TempInCur`, `HumInCur`, `WindSpeedCur`, `WindAvgSpeedCur`, `WindDirCur`, `WindDirCurEng`, `WindGust10`, `WindDirAvg10`, `WindDirAvg10Eng`, `RainRateCur`, `RainDay`, `RainYest`, `RainMonth`, `RainYear`, `UV`, `Solar`, `PM2.5`) VALUES (NULL, '[YYYY]-[MM]-[DD] [hh]:[mm]:[ss]', '[th0temp-act=F]', '[th0hum-act]', '[thb0seapress-act=inHg.2]', '[th0dew-act=F]', '[th0heatindex-act=F]', '[wind0chill-act=F]', '[thb0temp-act=F]', '[thb0hum-act]', '[wind0wind-act=mph]', '[wind0avgwind-act=mph]', '[wind0dir-act]', '[wind0dir-act=endir]', '[wind0wind-max10=mph]', '[wind0dir-avg10]', '[wind0dir-avg10=endir]', '[rain0rate-act=in.2]', '[rain0total-daysum=in.2]', '[rain0total-ydaysum=in.2]', '[rain0total-monthsum=in.2]', '[rain0total-yearsum=in.2]', '[uv0index-act]', '[sol0rad-act]', CASE '#if#{*[air0pm-age:999]<300*}#then#GOOD#else#BAD#fi#' WHEN 'GOOD' THEN '[air0!0pm-max5=.0]' ELSE NULL END)

Re: mySQL not working with new sensor variable

Posted: Sun Oct 25, 2020 10:06 pm
by galfert
Nevermind...I neglected to fix the other reference to the new variable...oops. I forgot that I had the If then statement in the query.

Re: mySQL not working with new sensor variable **solved**

Posted: Sun Nov 15, 2020 11:24 am
by Andyk1
My GW1000 also stopped recording Air data.
Platform: TL-WR902AC (no USB hub)
RAM: 60056 kB total, 18476 kB free (69% used)
SW Version: Meteobridge 5.0 (Nov 13 2020, build 2952), FW 1.1
Uptime: 0 hours, 28 minutes Buffer: 5 items (1%)

My SQL is not updating. What do I need to look at?

Re: mySQL not working with new sensor variable **solved**

Posted: Sun Nov 15, 2020 1:29 pm
by admin
No idea. When you provide me a remote login I can have a look.

Re: mySQL not working with new sensor variable **solved**

Posted: Sun Nov 15, 2020 4:07 pm
by galfert
If the GW1000 stopped seeing the PM2.5 sensor then this is purely at GW1000 / sensor issue and nothing to do with mySQL nor the Meteobridge.

What often happens with the PM2.5 sensor is that it runs out of battery charge. Upon reviving the PM2.5 sensor with a fresh charge it starts to transmit with a new ID. This causes the GW1000 to pick it up on a new channel if one of the 4 channels are available. Once the GW1000 associates the PM2.5 sensor to a new channel then the Meteobridge starts to see it too as a new sensor variable with a new name. This then breaks your mySQL upload query because the Meteobridge is seemingly picking up a new sensor.

The solution is to ensure that the GW1000 continues to associate the PM2.5 sensor with the same channel. This requires that every time it runs out of battery to Re-register using the WS View app under the Sensors ID section.

The other issue is that if the PM2.5 sensor battery runs out then a normal mySQL will fail because the sensor variable is not producing data. A basic mySQL query needs to be complete or the entire mySQL upload will fail. The solution I've found is to use a smarter mySQL upload query that sends a NULL value for the PM2.5 when it is missing. This ensures that the rest of the weather data gets uploaded to mySQL. If you take a look at my first post you'll notice that it has a rather complex IF THEN statement to deal with this situation. Do keep in mind that there is a small error with the PM2.5 variable that.shows up in two places. That was the premise of my OP in that I fixed on instance of the variable but not the other. Therefore I instead recommend you reference the correct fixed mySQL query I'm using pasted below.

Code: Select all

INSERT INTO `mystation` (`ID`, `DateTime`, `TempOutCur`, `HumOutCur`, `PressCur`, `DewCur`, `HeatIdxCur`, `WindChillCur`, `TempInCur`, `HumInCur`, `WindSpeedCur`, `WindAvgSpeedCur`, `WindDirCur`, `WindDirCurEng`, `WindGust10`, `WindDirAvg10`, `WindDirAvg10Eng`, `RainRateCur`, `RainDay`, `RainYest`, `RainMonth`, `RainYear`, `UV`, `Solar`, `PM2.5`) VALUES (NULL, '[YYYY]-[MM]-[DD] [hh]:[mm]:[ss]', '[th0temp-act=F]', '[th0hum-act]', '[thb0seapress-act=inHg.2]', '[th0dew-act=F]', '[th0heatindex-act=F]', '[wind0chill-act=F]', '[thb0temp-act=F]', '[thb0hum-act]', '[wind0wind-act=mph]', '[wind0avgwind-act=mph]', '[wind0dir-act]', '[wind0dir-act=endir]', '[wind0wind-max10=mph]', '[wind0dir-avg10]', '[wind0dir-avg10=endir]', '[rain0rate-act=in.2]', '[rain0total-daysum=in.2]', '[rain0total-ydaysum=in.2]', '[rain0total-monthsum=in.2]', '[rain0total-yearsum=in.2]', '[uv0index-act]', '[sol0rad-act]', CASE '#if#{*[air0!0pm-age:999]<300*}#then#GOOD#else#BAD#fi#' WHEN 'GOOD' THEN '[air0!0pm-max5=.0]' ELSE NULL END)
** One other thing... Very important.... You must change the PM2.5 mySQL database to allow for NULL value to be uploaded into the PM2.5 record. You only need to change this for the PM2.5 part of the database.

Re: mySQL not working with new sensor variable **solved**

Posted: Sun Nov 15, 2020 4:15 pm
by galfert
I've just realized that there might be a simpler way than using my complex IF THEN query.

The entire thing can likely be replaced by just using the following Meteobridge variable construct:
[air0!0pm-max5=.0:NULL]

I have not tested this though. UPDATE: Tested ..read next post... :(

Re: mySQL not working with new sensor variable **solved**

Posted: Sun Nov 15, 2020 9:16 pm
by galfert
After testing that simplified variable with the NULL replacement value did not work.
https://www.wxforum.net/index.php?topic ... #msg418544

I'm not back to using my complex IF THEN query as a solution.

Re: mySQL not working with new sensor variable **solved**

Posted: Mon Nov 16, 2020 11:01 pm
by Andyk1
galfert wrote: Sun Nov 15, 2020 4:07 pm If the GW1000 stopped seeing the PM2.5 sensor then this is purely at GW1000 / sensor issue and nothing to do with mySQL nor the Meteobridge.

What often happens with the PM2.5 sensor is that it runs out of battery charge. Upon reviving the PM2.5 sensor with a fresh charge it starts to transmit with a new ID. This causes the GW1000 to pick it up on a new channel if one of the 4 channels are available. Once the GW1000 associates the PM2.5 sensor to a new channel then the Meteobridge starts to see it too as a new sensor variable with a new name. This then breaks your mySQL upload query because the Meteobridge is seemingly picking up a new sensor.

The solution is to ensure that the GW1000 continues to associate the PM2.5 sensor with the same channel. This requires that every time it runs out of battery to Re-register using the WS View app under the Sensors ID section.

The other issue is that if the PM2.5 sensor battery runs out then a normal mySQL will fail because the sensor variable is not producing data. A basic mySQL query needs to be complete or the entire mySQL upload will fail. The solution I've found is to use a smarter mySQL upload query that sends a NULL value for the PM2.5 when it is missing. This ensures that the rest of the weather data gets uploaded to mySQL. If you take a look at my first post you'll notice that it has a rather complex IF THEN statement to deal with this situation. Do keep in mind that there is a small error with the PM2.5 variable that.shows up in two places. That was the premise of my OP in that I fixed on instance of the variable but not the other. Therefore I instead recommend you reference the correct fixed mySQL query I'm using pasted below.

Code: Select all

INSERT INTO `mystation` (`ID`, `DateTime`, `TempOutCur`, `HumOutCur`, `PressCur`, `DewCur`, `HeatIdxCur`, `WindChillCur`, `TempInCur`, `HumInCur`, `WindSpeedCur`, `WindAvgSpeedCur`, `WindDirCur`, `WindDirCurEng`, `WindGust10`, `WindDirAvg10`, `WindDirAvg10Eng`, `RainRateCur`, `RainDay`, `RainYest`, `RainMonth`, `RainYear`, `UV`, `Solar`, `PM2.5`) VALUES (NULL, '[YYYY]-[MM]-[DD] [hh]:[mm]:[ss]', '[th0temp-act=F]', '[th0hum-act]', '[thb0seapress-act=inHg.2]', '[th0dew-act=F]', '[th0heatindex-act=F]', '[wind0chill-act=F]', '[thb0temp-act=F]', '[thb0hum-act]', '[wind0wind-act=mph]', '[wind0avgwind-act=mph]', '[wind0dir-act]', '[wind0dir-act=endir]', '[wind0wind-max10=mph]', '[wind0dir-avg10]', '[wind0dir-avg10=endir]', '[rain0rate-act=in.2]', '[rain0total-daysum=in.2]', '[rain0total-ydaysum=in.2]', '[rain0total-monthsum=in.2]', '[rain0total-yearsum=in.2]', '[uv0index-act]', '[sol0rad-act]', CASE '#if#{*[air0!0pm-age:999]<300*}#then#GOOD#else#BAD#fi#' WHEN 'GOOD' THEN '[air0!0pm-max5=.0]' ELSE NULL END)
** One other thing... Very important.... You must change the PM2.5 mySQL database to allow for NULL value to be uploaded into the PM2.5 record. You only need to change this for the PM2.5 part of the database.
Already did all that. I had to revert back to 4.3 To get it to work as before. 4.4 and 5.0 do not read my Ecowitt Air Sensor. The GW1000 works fine sending data to the Ecowitt.net site but my Meteotemplate does not or no longer sees Air Data from meteobridge.

Re: mySQL not working with new sensor variable **solved**

Posted: Mon Nov 16, 2020 11:33 pm
by galfert
I'm running Meteobridge 5.0 and it reads my Ecowitt air quality PM2.5 sensor. I'm not use Meteotemplate though. So perhaps this is just an issue with that template needing to be updated.

If you go to the Meteobridge Live Data tab, do you see your air quality PM2.5 sensor there?

Re: mySQL not working with new sensor variable **solved**

Posted: Tue Nov 17, 2020 5:39 am
by Andyk1
galfert wrote: Mon Nov 16, 2020 11:33 pm I'm running Meteobridge 5.0 and it reads my Ecowitt air quality PM2.5 sensor. I'm not use Meteotemplate though. So perhaps this is just an issue with that template needing to be updated.

If you go to the Meteobridge Live Data tab, do you see your air quality PM2.5 sensor there?
In version 4.3 the air quality sensor sends data to my meteotemplate SQL. It is also highlighted in green in meteobridge 4.3
Using 5.0 meteobridge Air quality is not highlighted in green but shows the data.

It is not sending the air quality data to meteotemplate. Ver 4.3 does.

Also I noticed the extra sensors are not being captured in 5.0 but are in 4.3. 4.4 also does not work.

It is sending correct data to ecowitt.net fine. The problem lies in Meteobridge but I don't have the code to see what is causing it.

Andy

Re: mySQL not working with new sensor variable **solved**

Posted: Wed Nov 18, 2020 1:21 am
by admin
"airXpm" sensors are supported by the meteotemplate uploads. You just have to make a proper sensor mapping on "Mapping" page.
can you please share your mapping? What did you already try there?

Re: mySQL not working with new sensor variable **solved**

Posted: Fri Nov 20, 2020 4:12 pm
by Andyk1
admin wrote: Wed Nov 18, 2020 1:21 am "airXpm" sensors are supported by the meteotemplate uploads. You just have to make a proper sensor mapping on "Mapping" page.
can you please share your mapping? What did you already try there?
I managed to solve this with the understanding from Admin that I have to map two AirXpm sensors.

Re: mySQL not working with new sensor variable **solved**

Sent: Wed Nov 18, 2020 3:29 pm
From: admin
Recipient: Andyk1
On "raw data" tab I just see one "airpm". you mapped this to the air0pm which is expected to report pm10 values. Therefore, it is no surprise that you don't get data for pm2.5.
Last edited by admin on Wed Nov 18, 2020 3:29 pm, edited 1 time in total.

I did this by trial and error but adding Air1!0 Physical Sensor mapped to Air0pm 10pm 10 microns or default and then adding another Air1!0pm mapped to Air1pm to air quality 2.5 microns.

This was extreamly confusing but it was the only way to get it to send air quality data to my meteotemplate MySQL database. If I removed to Air1!0 -10 micron sensor in mapping it would no longer send data. I had to add two Air1!0pm and map 1 to 10pm and 1 to 2.5. I am not sure it that is by design but I could not find any reference to this anywhere on meteobridge.com If it is there I am sorry as I could not find it.

For anyone reading this I will go through this one more time if you have a Ecowitt GW1000 and A Meteobridge device to send data to your MySQL such as meteotemplate.

In the meteobridge ver 5.0 under weatherstation...Mapping add:

air1!0 Physical Sensor to Logical Sensor air0pm which is Air quality (10microns or default) then add another
air1!0 Physical Sensor to Logical Sensor air1pm which is Air quality (2.5 microns) which is the correct value for your ecowitt outdoor air quality sensor.

I have no Idea why both mapped sensors must be added but it is the only way it works. If you remove one and try to remap to air1pm it stops sending data to your MySQL but for now it is the only way I could find to get this to work.

Maybe in a newer Version 5 this will be fixed but I do not know this for sure. The above fix only works for:

Platform: TL-WR902AC (no USB hub)
RAM: 60056 kB total, 17016 kB free (71% used)
SW Version: Meteobridge 5.0 (Nov 17 2020, build 2970), FW 1.1
Uptime: 1 days, 6 hours, 49 minutes Buffer: 3 items (0%)

And I do not know if the TL-WR3020 or other Meteobridge platforms such as Pro or Davis are affected. If they are you may want to try the above fix and it may work.

This was a real Head Scratcher for me and took many trial and error and msg to Brois or whomever was the admin responding. Sorry for not understanding what you where trying to tell me.

I hope this helps anyone in the same situation.

Andy