incorrect temperature values with -17,8°C ** Updated **

Hello Wim,

since I also have the problem from time to time, that the minimum temperature is indicated with -17.8°C, I have looked at it today times more near.
It can happen that now and then the outdoor sensor of an Ecowitt system does not provide a temperature.
Reasons for this can be the restart of the station, after which the values of the sensor are not yet available at the following transmission interval.
Also it can happen (rarely) that the radio connection is temporarily interrupted.
According to my observations the weather station then sends an empty value &tempf= via Ecowitt protocol.

Since PWSDashboard calculates internally with Celsius values, the conversion of the Fahrenheit value (here: “”) to Celsius is done automatically.
However, this routine lacks an exception for the case that an empty input value is supplied - thus 0°F is assumed, which then results in -17.8°C.
I don’t know now exactly where the conversion happens - I found several places in the different php files (search for “-32”) - but there is at least also a central function convert_temp, where this exception can be implemented very easily:


function convert_temp ($num,$from,$to,$dec=1)
     {  global $stck_lst;
        $amount         = (float) str_replace(',','.',$num);
        $from   = strtolower($from);
        $to     = strtolower($to);
        if ($from == $to)                       { $out = $amount;}
        elseif (($from == 'c') && ($to = 'f'))  { $out = 32 +(9*$amount/5);}
        elseif (($from == 'f') && ($to = 'c'))  { $out = 5*($amount -32)/9;}
        else                                    { $out = -999;}
        $return         = round($out,$dec);
        if ($num == "") { $return = ""; }
# $stck_lst      .= basename(__FILE__).' ('.__LINE__.') $num='.$num.'  $from='.$from.'  $to='.$to.' $return='.$return.PHP_EOL;
        return $return;}

So just return a “” if $num == “”.
Can you please check if this fix could basically fix the problem and possibly include it for the next version?
Thanks a lot!

Regards, Oliver

There is a topic about this here ecowitt invalid temp -17.8
These are the only two errors found with that station since May 27…
There is no tempf at all. , not even an empty value.

Fri, 28 May 2021 22:02:01 +0000 = Ecowitt data: 66 Invalid data Array
(
    [stationtype] => GW1000A_V1.6.7
    [dateutc] => 2021-05-28 22:01:59
    [tempinf] => 76.6
    [humidityin] => 44
    [baromrelin] => 30.062
    [baromabsin] => 29.751
    [winddir] => 215
    [windspeedmph] => 1.34
    [windgustmph] => 2.24
    [maxdailygust] => 2.24
    [solarradiation] => 0.00
    [uv] => 0
    [wh68batt] => 1.64
    [freq] => 868M
    [model] => GW1000_Pro
)

Tue, 01 Jun 2021 14:16:15 +0000 = Ecowitt data: 66 Invalid data Array
(
    [stationtype] => GW1000A_V1.6.8
    [dateutc] => 2021-06-01 14:16:14
    [tempinf] => 74.7
    [humidityin] => 41
    [baromrelin] => 30.008
    [baromabsin] => 29.698
    [freq] => 868M
    [model] => GW1000_Pro
)

We decided to test some time before releasing an adapted ecowitt/index.php
The solution is not checking “tempinf” at line 12 but “tempf”

$always_exists  = 'tempf';      # this field should always be in the data !    #### 2021-05-24  but 

That field is checked if it is there and if the value is acceptable in lines 60-70, invalid data is logged

#-----------------------------------------------
#   check if data fields are there and are valid
if     (!array_key_exists ($always_exists,$_POST) //
         ||  $_POST[$always_exists] == NULL
         || (string) $_POST[$always_exists] == '' 
         || (int)    $_POST[$always_exists] == 0)      // empty data, check the log file regurly       
     {  $message        .= __LINE__.' Invalid data '.print_r($_REQUEST,true);
        unset ($_REQUEST['PASSKEY']);
        $data_stored    = './ecco_test.arr';   #### 2021-05-24
        $test_mode      = true;}
#

That way incomplete uploads are not arriving at the livedata main script at all.

The index.php maybe needs to get some more extra checking of data and or calculating missing data.
See topic here: Remove errors in high-lows ** Discussion topic **
But that has to wait until after meteoalarm.eu succeeds in moving their website off-line these coming days.

I attach the script we are testing in the other topic.
Wim


index.php.zip (2.28 KB)