Announcement

Collapse
No announcement yet.

Soil moisture graphic

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Soil moisture graphic

    I posted this earlier, but it got lost.
    In another thread, jaja posted a screen shot of the moisture graphic (post #3) that looks like what I've been seeing for some time. The graph is at the extremes only, but not between. In my case, it appears that if the soil moisture is above the watering threshold, the graphic is at max. When the soil moisture goes below the watering threshold, the graphic goes to minimum. There is no indication of moisture level changing with time. Is that a bug, a setting problem, a deliberate change, or something else?
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.548, NUC i3

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

    #2
    The algorithm dynamically scales the graphic over the past week so it is dependent upon the database moisture level calculations over that period. When starting very little data exists so the graphic is not pretty.

    Take a look at your soil moisture history from the calendar or directly from the database. See if reasonable data exists there. The actual algorithm is below. Sorry the indents of Visual Studio do not transfer. You can look at it if you have nothing better to do.

    Code:
    If gSQLIndex = SQL_SQLITE Then
    Using oConn As New SqliteConnection
    Using oCmd As New SqliteCommand(SQL, oConn)
    oConn.ConnectionString = DBProvider & gTemperatureDatabase '"Data Source=Data/mcsSprinklers/mcsSprinklers.db"
    oConn.Open()
    Using rst As SqliteDataReader = oCmd.ExecuteReader() 'ReadDatabase(oConn, SQL)
    While rst.Read()
    Try
    iHour = CShort(DateDiff(Microsoft.VisualBasic.DateInterval.Hour, dFirstDate, DateNotNull(rst, "QDate", Now))) '"SampleDate"
    Catch ex As Exception
    iHour = HOURS_IN_WEEK + 1
    End Try
    If iHour > HOURS_IN_WEEK + 1 Then
    iHour = HOURS_IN_WEEK + 1
    End If
    If iHour < 0 Then
    If rtbDebugLog Then
    hsWritelogNoBlink(PLUGIN_NAME, "ReadWeeksMoisture Unexpected date in moisture database Hour=" & CStr(iHour) & ", FirstDate=" & CStr(dFirstDate) & ".fields(0)=" & rst(DateField).ToString)
    End If
    Else
    For iZone = 0 To rtiZoneUbound
    iArea = rtiZoneArea(iZone)
    If iArea >= 0 AndAlso iArea <= 7 Then
    If rtiAreaControlStrategy(iArea) = rtiMEASURED Then '11/5/2014
    iScaledMin = CType(rtnSCALING * (rtnAreaMeasuredThreshold(iArea) - rtnAreaMeasured0Percent(iArea)) / (rtnAreaMeasured100Percent(iArea) - rtnAreaMeasured0Percent(iArea)), Integer)
    iMaxScale = CInt(rtnSCALING * rtnSaturationInches100Percent) - iScaledMin
    ElseIf rtiAreaControlStrategy(iArea) = rtiMIST Then
    iScaledMin = 0
    iMaxScale = CInt(rtnSCALING * rtnSaturationInches100Percent)
    Else
    iScaledMin = CInt(rtnAreaCalcMoistureLevel(iArea) * rtnSCALING)
    iMaxScale = CInt(rtnSCALING * (rtnSaturationInches100Percent - rtnAreaCalcMoistureLevel(iArea)))
    End If
    Else
    iScaledMin = 0
    iMaxScale = CInt(rtnSCALING * rtnSaturationInches100Percent)
    End If
    iMaxScale = iMaxScale - iScaledMin '4/1/2012
    If Not IsDBEmpty(rst, "Q" & CStr(iZone)) Then 'sZoneField(iZone)
    iLevel = CType(rst("Q" & CStr(iZone)), Integer) 'sZoneField(iZone)
    iLevel = iLevel - iScaledMin
    If iLevel <= 0 Then
    rtiSoilLevel(iZone, iHour) = 1
    ElseIf iLevel > iMaxScale Then
    rtiSoilLevel(iZone, iHour) = PIXEL_HEIGHT
    Else
    rtiSoilLevel(iZone, iHour) = CShort(Int(PIXEL_HEIGHT * (iLevel) / iMaxScale))
    If rtiSoilLevel(iZone, iHour) < 1 Then
    rtiSoilLevel(iZone, iHour) = 1
    End If
    End If
    End If
    Next
    End If
    End While
    End Using
    End Using
    End Using
    ElseIf UseMySQL Then If gSQLIndex = SQL_SQLITE Then
    Using oConn As New SqliteConnection
    Using oCmd As New SqliteCommand(SQL, oConn)
    oConn.ConnectionString = DBProvider & gTemperatureDatabase '"Data Source=Data/mcsSprinklers/mcsSprinklers.db"
    oConn.Open()
    Using rst As SqliteDataReader = oCmd.ExecuteReader() 'ReadDatabase(oConn, SQL)
    While rst.Read()
    Try
    iHour = CShort(DateDiff(Microsoft.VisualBasic.DateInterval.Hour, dFirstDate, DateNotNull(rst, "QDate", Now))) '"SampleDate"
    Catch ex As Exception
    iHour = HOURS_IN_WEEK + 1
    End Try
    If iHour > HOURS_IN_WEEK + 1 Then
    iHour = HOURS_IN_WEEK + 1
    End If
    If iHour < 0 Then
    If rtbDebugLog Then
    hsWritelogNoBlink(PLUGIN_NAME, "ReadWeeksMoisture Unexpected date in moisture database Hour=" & CStr(iHour) & ", FirstDate=" & CStr(dFirstDate) & ".fields(0)=" & rst(DateField).ToString)
    End If
    Else
    For iZone = 0 To rtiZoneUbound
    iArea = rtiZoneArea(iZone)
    If iArea >= 0 AndAlso iArea <= 7 Then
    If rtiAreaControlStrategy(iArea) = rtiMEASURED Then '11/5/2014
    iScaledMin = CType(rtnSCALING * (rtnAreaMeasuredThreshold(iArea) - rtnAreaMeasured0Percent(iArea)) / (rtnAreaMeasured100Percent(iArea) - rtnAreaMeasured0Percent(iArea)), Integer)
    iMaxScale = CInt(rtnSCALING * rtnSaturationInches100Percent) - iScaledMin
    ElseIf rtiAreaControlStrategy(iArea) = rtiMIST Then
    iScaledMin = 0
    iMaxScale = CInt(rtnSCALING * rtnSaturationInches100Percent)
    Else
    iScaledMin = CInt(rtnAreaCalcMoistureLevel(iArea) * rtnSCALING)
    iMaxScale = CInt(rtnSCALING * (rtnSaturationInches100Percent - rtnAreaCalcMoistureLevel(iArea)))
    End If
    Else
    iScaledMin = 0
    'iMaxScale = rtiSCALING * CInt(rtnSaturationInches100Percent)
    iMaxScale = CInt(rtnSCALING * rtnSaturationInches100Percent)
    End If
    iMaxScale = iMaxScale - iScaledMin '4/1/2012
    If Not IsDBEmpty(rst, "Q" & CStr(iZone)) Then 'sZoneField(iZone)
    iLevel = CType(rst("Q" & CStr(iZone)), Integer) 'sZoneField(iZone)
    'If iZone = 19 Then
    'Debug.Print(DateNotNull(rst, "QDate", Now).ToString & "=" & iLevel.ToString)
    'End If
    iLevel = iLevel - iScaledMin
    If iLevel <= 0 Then
    rtiSoilLevel(iZone, iHour) = 1
    ElseIf iLevel > iMaxScale Then
    rtiSoilLevel(iZone, iHour) = PIXEL_HEIGHT
    Else
    rtiSoilLevel(iZone, iHour) = CShort(Int(PIXEL_HEIGHT * (iLevel) / iMaxScale))
    If rtiSoilLevel(iZone, iHour) < 1 Then
    rtiSoilLevel(iZone, iHour) = 1
    End If
    End If
    End If
    Next
    End If
    End While
    End Using
    End Using
    End Using
    ElseIf UseMySQL Then

    Comment


      #3
      Tabulated data:

      Click image for larger version

Name:	Table.png
Views:	97
Size:	12.4 KB
ID:	1390988

      Graphic:

      Click image for larger version

Name:	Graphic.png
Views:	97
Size:	10.0 KB
ID:	1390989
      Mike____________________________________________________________ __________________
      HS3 Pro Edition 3.0.0.548, NUC i3

      HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

      Comment


        #4
        Looks like it should produce a reasonable graphic. I will play with it in a couple of days.

        Comment


          #5
          Thank you. It's been like this for several years now, and I seem to be surviving okay, so it's not urgent. Mostly just puzzled by what caused it. Seeing the same on another system made me realize it might not be something unique to me.
          Mike____________________________________________________________ __________________
          HS3 Pro Edition 3.0.0.548, NUC i3

          HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

          Comment


            #6
            Take a look at your Area Setup page, Control Strategy, ET column, Moisture trigger threshold. If you are using a timed control strategy for the Area then change the ET moisture trigger threshold to 0.

            If fixed this in the code and made the algorithm a little quicker too. Confirm before I post the update that this takes care of the graphic for you.

            Comment


              #7
              Unfortunately, I'm not using a timed control. I use the calculated ET (and the threshold) to determine when to water.

              Click image for larger version

Name:	Strat.png
Views:	112
Size:	18.8 KB
ID:	1391591
              Mike____________________________________________________________ __________________
              HS3 Pro Edition 3.0.0.548, NUC i3

              HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

              Comment


                #8
                2.20.0.19 was posted for another reason at http://mcsSprinklers.com/mcsSprinkle...0_0_19_HS3.zip. It contains the updated algorithm and detailed debug around it. Give it a try, show Zone Status page, write debug file, look for lines "ReadWeeksMoisture Zone ". There should be one for each hour and each zone. Post the debug or extract of these lines.

                Comment


                  #9
                  When I try to update from the Other page it appears to be updating, but when mcsSprinklers returns the version is still 2.20.0.12. (I'm using the stand alone version.) Can I update just by replacing the <mcsSprinklers_2009.dll> file?
                  Mike____________________________________________________________ __________________
                  HS3 Pro Edition 3.0.0.548, NUC i3

                  HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                  Comment


                    #10
                    When I looked at the ftp site I see that the mcsSprinklers_220019.dll file was not present. I have ISP issues, but was finally able to get the file uploaded. You can try again from the Other Page, or as you suggested just replace the dll file.

                    What I have observed is that a significant portion of my internet bandwidth is being used by Microsoft and Amazon with updates to computers, portable devices and Echos. I'm hoping SpaceX's Starlink will pan out next year.

                    Comment


                      #11
                      The update appears to have been successful this time. Thank you. (Sprinklers did not restart again automatically, though.)
                      The soil moisture graphic appears to be working as expected now. Will update again after collecting more data.
                      Mike____________________________________________________________ __________________
                      HS3 Pro Edition 3.0.0.548, NUC i3

                      HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                      Comment


                        #12
                        Click image for larger version  Name:	moisture.png Views:	0 Size:	4.3 KB ID:	1391916

                        Michael,
                        The soil moisture graphic appears to be fixed. Thank you. Do you still want to see the debug file?
                        Mike____________________________________________________________ __________________
                        HS3 Pro Edition 3.0.0.548, NUC i3

                        HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                        Comment


                          #13
                          I do not need the debug. I also do not know why it was not working previously. Next update I will remove the debug added as it is quite a bit of data.

                          Comment

                          Working...
                          X