I'm currently reading HB Ds1820 temp sensors and HB humidity sensors via Visual basic 2008 and the one wire SDK
I don't see any rain gauge containers in the one wire docs.
Curious as to how to read the rainwise gauge I got from HB?
Don't have a rain gauge yet, but I understand this to be ...
The DS2423 counter will increment for each .01 inch of rain.
When you read the counter, you get a value.
By design, the counter starts at zero and increments with each contact/pulse.
You need to know the beginning and ending values of the counter over a period of time.
If the value today is 555, and the value yesterday was 555. You got no rain.
If the value today is 555, and the value yesterday was 455, the counter went up by 100, so you got 1" of rain.
If you sample and log the value on a regular basis, at least once a day, better yet every hour, you can calculate how much rain you got over days, weeks, months.
ok, that makes sense. I knew that .01 counts had to be stashed somewhere.
I would image that you should get the counts and then reset the counts back to zero (if possible)
If I unplug my one wire hub power supply, the rain gauge would loose power and the counts it has stored?
Wserver (my weather program) seems to record increments of .01 in the rain gauge log file.
In other words, it is not reading 342 counts. It shows
.01
.03
.02
.01
, etc in the log file.
So my guess is that the counts are reset back to zero every time the rain gauge is read.
Imports System
Public Class Form1
'dim one wire
Dim adapter As com.dalsemi.onewire.adapter.DSPortAdapter
Dim owd As com.dalsemi.onewire.container.OneWireContainer
Dim state As Object
Dim SwitchContainer As com.dalsemi.onewire.container.SwitchContainer
Dim CounterContainer As com.dalsemi.onewire.container.OneWireContainer1D
Dim Switches As Integer
Dim CurrentTime As Date
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
adapter = com.dalsemi.onewire.OneWireAccessProvider.getAdapter("{DS9097U}", "COM1")
' print that adapter was found
ResultsTextBox.AppendText(adapter.getAdapterName & " 1 wire Port: " & adapter.getPortName & vbCrLf)
Catch ex As Exception
ResultsTextBox.AppendText("Error reading adapter: " & ex.ToString & vbCrLf)
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ReadSensors()
End Sub
'read one wire sensor
Sub ReadSensors()
CurrentTime = TimeOfDay
ResultsTextBox.AppendText("Time: " & CurrentTime & vbCrLf)
' get exclusive use of 1-Wire network
Try
adapter.beginExclusive(True)
adapter.setSpeed(com.dalsemi.onewire.adapter.DSPortAdapter.SPEED_REGULAR)
Catch ex As Exception
ResultsTextBox.AppendText("Error: " & ex.ToString & vbCrLf)
End Try
Try
owd = adapter.getDeviceContainer("000000000505801F") 'set switch to channel 2
SwitchContainer = DirectCast(owd, com.dalsemi.onewire.container.SwitchContainer)
state = SwitchContainer.readDevice ' read the device
Switches = SwitchContainer.getNumberChannels(state)
SwitchContainer.setLatchState(1, True, True, state) 'set switch to aux
SwitchContainer.writeDevice(state)
Catch ex As Exception
ResultsTextBox.AppendText("Error: changing switch " & ex.ToString & vbCrLf)
End Try
Try
owd = adapter.getDeviceContainer("1100000009F06F1D")
CounterContainer = DirectCast(owd, com.dalsemi.onewire.container.OneWireContainer1D)
Dim counterstate As Long
counterstate = CounterContainer.readCounter(15) ' read the device
ResultsTextBox.AppendText(counterstate & vbCrLf)
Catch ex As Exception
ResultsTextBox.AppendText("Error reading counter: " & ex.ToString & vbCrLf)
End Try
' end exclusive use of 1-Wire net adapter
adapter.endExclusive()
End Sub
End Class
I went the HB store and looked at the dual counter Eric sells.
I see it has a lithium battery on the board and so I bet if I look inside my rainwise gauge, there is a battery in there also.
That's how it maintains the counts.
Makes sense now.
Wasn't sure if the counts would be lost if the one wire nentwork lost power, but it looks like the battery handles that.
Eric, does that all sound correct?
I went the HB store and looked at the dual counter Eric sells.
I see it has a lithium battery on the board and so I bet if I look inside my rainwise gauge, there is a battery in there also.
That's how it maintains the counts.
Makes sense now.
Wasn't sure if the counts would be lost if the one wire nentwork lost power, but it looks like the battery handles that.
Eric, does that all sound correct?
Yes that is correct. The Rain Gauge has a Dual Counter inside and it has a battery so that it can keep up with counts even if your computer is off which means there is no way to reset the counter to 0 (unless the battery dies which won't happen for a long time).
Eric