Hello,
Currently i am testing workflow sensor YF-S201 for sensing of workflow.
The workflow sensor is working as expected. But when the counter is 0 [Zero], I do not want to send the reading to my Website. Since the Zero reading is wasting of Space in Database. I wanted to send the totalCounter value to the website.
Below is the Code snippet:
Am I doing anything wrong in jobdone procedure?
Currently i am testing workflow sensor YF-S201 for sensing of workflow.
The workflow sensor is working as expected. But when the counter is 0 [Zero], I do not want to send the reading to my Website. Since the Zero reading is wasting of Space in Database. I wanted to send the totalCounter value to the website.
Below is the Code snippet:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Private waterwifi As ESP8266WiFi
Private D2pin As D1Pins
Private D1 As Pin
Private counter As UInt
Private set= False As Boolean
Private totalCounter As Double
End Sub
Serial1.Initialize(115200)
Log("AppStart")
D1.Initialize(D2pin.D1,D1.MODE_INPUT_PULLUP)
D1.AddListener("pin2_StateChanged")
waterwifi.Connect2("xxxxx","xxxx")
If waterwifi.IsConnected Then
Log("Router Connected Successfully!!!")
Else
Log("Router Not able to connect!!!")
Return
End If
HttpJob.Initialize("Test")
HttpJob.Download("http://mytestpage.com")
Sub jobdone(Job As JobResult)
Do Until counter>0
totalCounter=(totalCounter+counter)
Delay(1000)
counter=0 'Resetting the Counter
set= False
Loop
Log(totalCounter) <---- This log not showing in serial
Dim s As String=JoinStrings(Array As String("http://mytestpage.com/addCounter.php?counter=",totalCounter)
' 'Sending the values to cloud
HttpJob.Download(s)
End Sub
Private Sub pin2_StateChanged(state As Boolean)
Select state
Case True
counter=counter+1
Case False
End Select
End Sub
Am I doing anything wrong in jobdone procedure?