Page 1 of 1

Errors while fetching and pushing pressure data to MySQL database. **solved**

Posted: Sun Apr 03, 2022 11:49 pm
by Nadleeh
Hi all,

Recently I bought a Meteobridge NANOSD for my Davis Vantage Pro2 weather station. Currently I'm setting up a MySQL (or actually MariaDB...) database to store the measured data. Fetching and storing every sensor data is working fine, but for some reason I cannot get the barometric pressures to work.

First of all, this SQL script defines the table I have created:

Code: Select all

CREATE TABLE IF NOT EXISTS `tableName` (
  `Id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'ID / Primary key',
  `DateTime` datetime NOT NULL COMMENT 'Date and Time of Readings',
  `TempOutCur` decimal(4,1) NOT NULL COMMENT 'Current Outdoor Temperature',
  `HumOutCur` int(11) NOT NULL COMMENT 'Current Outdoor Humidity',
  `PressCur` decimal(4,1) NOT NULL COMMENT 'Current Barometric Pressure',
  `PressSeaCur` decimal(4,1) NOT NULL COMMENT 'Current Barometric Pressure at sealevel',
  `DewCur` decimal(4,1) NOT NULL COMMENT 'Current Dew Point',
  `HeatIdxCur` decimal(4,1) NOT NULL COMMENT 'Current Heat Index',
  `WindChillCur` decimal(4,1) NOT NULL COMMENT 'Current Wind Chill',
  `TempInCur` decimal(4,1) NOT NULL COMMENT 'Current Indoor Temperature',
  `HumInCur` int(11) NOT NULL COMMENT 'Current Indoor Humidity',
  `WindSpeedCur` decimal(4,1) NOT NULL COMMENT 'Current Wind Speed',
  `WindAvgSpeedCur` decimal(4,1) NOT NULL COMMENT 'Current Average Wind Speed',
  `WindDirCur` int(11) NOT NULL COMMENT 'Current Wind Direction (Degrees)',
  `WindDirCurEng` varchar(3) NOT NULL COMMENT 'Current Wind Direction (English)',
  `WindGust10` decimal(4,1) NOT NULL COMMENT 'Max Wind Gust for Past 10 Mins',
  `WindDirAvg10` int(11) NOT NULL COMMENT 'Average Wind Direction (Degrees) for Past 10 Mins',
  `WindDirAvg10Eng` varchar(3) NOT NULL COMMENT 'Average Wind Direction (English) for Past 10 Mins',
  `RainRateCur` decimal(5,2) NOT NULL COMMENT 'Current Rain Rate',
  `RainDay` decimal(4,2) NOT NULL COMMENT 'Total Rain for Today',
  `RainYest` decimal(4,2) NOT NULL COMMENT 'Total Rain for Yesterday',
  `RainMonth` decimal(5,2) NOT NULL COMMENT 'Total Rain this Month',
  `RainYear` decimal(5,2) NOT NULL COMMENT 'Total Rain this Year'
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
With the following INSERT statement I try to update the database:

Code: Select all

INSERT INTO `dbName`.`tableName` (`DateTime`, `TempOutCur`, `HumOutCur`, `PressCur`, `PressSeaCur`, `DewCur`, `HeatIdxCur`, `WindChillCur`, `TempInCur`, `HumInCur`, `WindSpeedCur`, `WindAvgSpeedCur`, `WindDirCur`, `WindDirCurEng`, `WindGust10`, `WindDirAvg10`, `WindDirAvg10Eng`, `RainRateCur`, `RainDay`, `RainYest`, `RainMonth`, `RainYear`) VALUES ('[YYYY]-[MM]-[DD] [hh]:[mm]:[ss]', '[th0temp-act]', '[th0hum-act]', '[thb0press-act]' , '[thb0seapress-act]', '[th0dew-act]', '[th0heatindex-act]', '[wind0chill-act]', '[thb0temp-act]', '[thb0hum-act]', '[wind0wind-act]', '[wind0avgwind-act]', '[wind0dir-act]', '[wind0dir-act=endir]', '[wind0wind-max10]', '[wind0dir-avg10]', '[wind0dir-avg10=endir]', '[rain0rate-act=.2]', '[rain0total-daysum=.2]', '[rain0total-ydaysum=.2]', '[rain0total-monthsum=.2]', '[rain0total-yearsum=.2]')
And specific the template variables for pressure:

Code: Select all

'[thb0press-act]' , '[thb0seapress-act]
This doesn't work. I tried several template with different settings, converters, selectors and such, but every time I get an error something like this:

Code: Select all

dDirCur`, `WindDirCurEng`, `WindGust10`, `WindDirAvg10`, `WindDirAvg10Eng`, `RainRateCur`, `RainDay`, `RainYest`, `RainMonth`, `RainYear`) VALUES (&apos;2022-04-03 23:36:33&apos;, &apos;3.8&apos;, &apos;80.0&apos;, &apos;1020.8&apos; , &apos;1020.8&apos;, &apos;0.7&apos;, &apos;3.8&apos;, &apos;3.8&apos;, &apos;23.6&apos;, &apos;51.0&apos;, &apos;0.0&apos;, &apos;0.0&apos;, &apos;155.0&apos;, &apos;SSE&apos;, &apos;0.9&apos;, &apos;155.0&apos;, &apos;SSE&apos;, &apos;0.00&apos;, &apos;0.00&apos;, &apos;0.00&apos;, &apos;4.20&apos;, &apos;10.00&apos;)&apos; failed: Out of range value for column &apos;PressCur&apos; at row 1 (no more tries): <BR>')">
The only time I got it working was when I converted to pressures to psi like [thb0seapress-act=psi.1]

To be honest I have no clue why it works for psi and not for other units. Probably I'm doing something wrong but I have no idea what :| . Someone here that can help me?

Thanks in advance!

Mark

PS: the pressures are fetched by the Meteobridge just fine, I can create graphs and tables with those variables.

Re: Errors while fetching and pushing pressure data to MySQL database

Posted: Mon Apr 04, 2022 12:14 am
by admin
Your insert statement does not take care if a sensor data is missing. Please make use of the default mechanisms as explained for template use in the meteobridge wiki. I can hardly count how often I have had said this.

Using ' characters which are translated to "&apos;" also seems wrong to me.

The mysql definition "decimal(4,1)" covers values from -999.9 to 999.9 which is not sufficient for pressure and the error message also tells this very obvious: "Out of range value for column 'PressCur'" :roll: