Installation
- Have Arduino IDE installed on your computer
- Download the Hydreon-Arduino library below
- Install the library by going to sketch->include library->add .zip library and selecting hydreon
The RG-15 instructions pdf is a great source of information for working with this API.
API
getAvailable()
When the Rain Gauge is in continuous mode, reads all data in stream buffer since last time it was read.
Returns: string of all available data.
RG15Arduino rg15;
void loop() {
String message = rg15.getAvailable(); //gets and clears the stream buffer string.
Serial.println(message);
delay(1000);
}
poll()
When the Rain Gauge is in polling mode, Polls the RG device and updates the internal fields accordingly.
Returns: bool that is true if a response was found and it contains updated RG data.
RG15Arduino rg15;
if(rg15.poll()) { //polls and updates values and if successful, returns true.
Serial.print(rg15.acc); //console shows polled accumulation.
}
setBaud(int baudCode)
0 | 1200 |
1 | 2400 |
2 | 4800 |
3 | 9600 (default) |
4 | 19200 |
5 | 38400 |
6 | 57600 |
Sets the baud rate according to the table on the left. 9600 by default works well. using this method will also make the device reboot.
Returns: bool if command was received and executed.
setContinuous()
Sets the device to continuous mode. Instead of having to poll, the Rain Gauge sends data every time the accumulation changes. Capture the data with getAvailable().
Returns: bool if command was received and executed.
setHighResolution()
Ignores dip switch setting and sets the resolution to 0.02mm (0.001in).
Returns: bool if command was received and executed.
setImperial()
Ignores dip switch setting and sets the scale to imperial.
Returns: bool if command was received and executed.
setLowResolution()
Ignores dip switch setting and sets the resolution to 0.2mm (0.01in)
Returns: bool if command was received and executed.
setMetric()
Ignores dip switch setting and sets the scale to metric.
Returns: bool if command was received and executed.
setPolling()
Rain Gauge enters polling mode and only sends data when it is requested. To request data from the RG, call the method poll().
Returns: bool if command was received and executed.
setStream(Stream stream)
Sets the stream used to read and send data to the Rain Gauge. Must be used for the Library to function properly and the provided stream must be initialized before calling this method.
Returns: Nothing.
RG15Arduino rg15;
Stream1.begin(9600);
rg15.setStream(Stream1);
useExternalTippingBucket(bool isTippingBucketPresent)
The Rain Gauge has the ability to connect to a tipping bucket as an easy way to compare data. Make sure to have a properly set up Tipping Bucket when using this command.
Returns: Bool if command was received and executed.
resetAccumulation()
Resets the accumulation counter to 0.
Returns: Nothing.
resetSwitchToPhysical()
Resets any scale and resolution to the devices current physical defaults. These are set on the DIP switch on the back of the rain gauge.
Returns: bool if command was received and executed.
restartDevice()
Fully restarts device (kill) and reads DIP switches again.
Returns: bool if command was received and executed.