4-11-2019 Analyzing and Designing an Arduino Controlled System to Study the Effect of Changing Water Levels on Water Flow Through Sediments

The hyporheic zone is the region of sediment under a stream where water from the stream flows before returning to the stream itself. Many studies focus on steady water flow through this region, however, in natural systems, water levels and water flow rates change due to storms, tides, dams, or melting snow. To investigate flow under unsteady conditions, we built a system that allows us to control the water level and thus the flow rates. We used a pressure sensor that is connected to an Arduino board to measure the water level. The Arduino board uses the measured pressure value to control a water pump. When the water level is lower than desired, the pump will turn on and when it is higher than desired, it will turn off. This allowed us to hold the water level constant or tell it to oscillate. We then evaluated our system by comparing our desired water level functions to those measured with our pressure sensor, those measured by a pressure transducer connected to a separate Arduino, and those we extracted from videos of our system.


INTRODUCTION
The hyporheic zone is the region of sediment under a stream where water from the stream flows before returning to the stream itself.The hyporheic zone represents a unique habitat for some organisms and influences stream ecosystems through biogeochemical processes that alter stream solute loads (Bencala, 1983;Triska et al., 1993;Boulton et al., 1998).The water flowing into the zone carries nutrients and pollutants, many of which are transformed before flowing back out into the stream (Witman, 2018).
Many studies focus on steady water flow through this region (Harvey and Bencala, 1993;Cardenas, 2015;Stonedahl et al., 2018); however, in natural systems, water levels and water flow rates change due to storms, tides, dams, or melting snow (Wondzell and Swanson, 1996).While a few studies (Larsen et al., 2014;Syracuse University, 2014;Zimmer and Lautz, 2013) have documented the effect of variable flow rates on hyporheic flow, much is not understood about the effect of this variability.
To investigate flow under unsteady conditions, we built a system that allows us to control the water level and thus the flow rates through the sediments.We used a sensor that is connected to an Arduino board to measure the water level.The Arduino board uses the sensor information to control a water pump.When the water level is lower than desired, the pump will turn on in order to raise the water level, and when it is higher than desired, it will turn off.This allows us to hold the water level constant or create controlled oscillations.We then evaluated our system by comparing our desired water level functions to those measured with our water level sensor, those measured by an independent pressure transducer connected to a separate Arduino, and those we extracted from a video of our system.

MATERIALS AND METHODS
In order to investigate flow under unsteady conditions, we designed a custom glass tank (Figure 1).The inner dimensions are 65 cm by 74 cm by 10 cm.The tank contains a divider made from sheet metal and is positioned in the middle of the tank 30 cm from the bottom.The divider allows us to create flow from the high side to the low side through the sediment.The tank has an overflow opening on the low side (45.5 cm from the bottom), which allows the water to flow out of the system.An aquarium store, Aquatic Environments, built the tank out of glass and silicone.We added the divider and overflows ourselves using sheet metal and silicone.Figure 1 illustrates the layout of the system used throughout the study.The tank is filled with water and then a fine-grained silica sand is slowly added to the desired level.This level must be above the bottom of the divide or the water levels cannot be maintained at different heights.Water is then pumped into the right side of the system from external Pump A. It enters through the water distributor (a capped PVC pipe with 16 holes drilled into its sides), which keeps the water from disturbing the sediments and helps it circulate quickly throughout the system.The quick mixing is not critical for this experiment but will be necessary when changing solutions in other experiments.Another pump, Pump B, also helps with quick circulation.Pump C pumps water out of the tank continuously when it is being used in the experiments.Pump C allows us to decrease the high head water level much more quickly than waiting for it to flow through the sediment.Table 1 illustrates the non-electronic parts necessary to complete each experiment.

Electronics
We built a controllable outlet (Figure 2), which is connected to an Arduino using the components found in Table 2.The outlet consists of a standard wall outlet, wires, and a relay.The controllable outlet uses a lowvoltage control signal from the Arduino to control the relay.The relay creates a switch mechanism that allows for current to flow through the circuit.The relay has two voltage terminals which connect to the device that is being controlled and three low voltage pins that connect to the Arduino, as illustrated in Figure 2. A 120-240-volt switch is connected to an electromagnet inside of the relay.The relay receives a HIGH or LOW signal at the signal pin from the Arduino, which activates the electromagnet and moves the contacts of the switch to open or closed (How to Set-up, 2017).For our configuration, when the relay receives a HIGH signal, the switch closes and allows for the current to flow from the common terminal to the normally open terminal.When the relay receives a LOW signal, the relay deactivates and stops the current.A pump plugs into the controllable outlet so that the Arduino can control whether it is on or off.Our circuit also contains a switch, which we use as an independent variable to communicate to the system, signaling two options in the code.For this experiment, when the switch is off, the outlet will not turn on and when the switch is on, the controllable outlet is controlled by the Arduino.The outlet is turned on when the sensor measures a water level below a minimum specified level and off when above a maximum specified level.We tried multiple sensors and chose the eTape sensor (Adafruit Industries, 2018).This device measures the level of a fluid through changes in resistance at different fluid levels (Adafruit Industries, 2018).Table 3 lists the primary electronics used in our system.Additional electronics were used in this experiment to measure the water levels and provide comparisons, as seen in Table 4.A BottleLogger Arduino purchased from Northern Widget, LLC (Sandell and Wickert, 2018) recorded readings from a Honeywell-HSC pressure transducer assembled by Northern Widget onto an SD card.The pressure transducer is connected independently to the primary system and is not used to make decisions that affect the water level like the eTape sensor.A video camera also recorded the experiment.We created a program in MATLAB that uses the saturation values found in frames from the video to calculate the water level.The water is dyed dark blue using the FD&C Blue #1 Powder, so that the saturation levels are significantly higher in areas with water.The level was determined by evaluating the top of the blue oscillating water level frame by frame.Once we found the water level at each frame, we compared these to our pressure sensor readings.
Before beginning our experiment, a wiring diagram was drawn for each electronic component used in our system, as illustrated in Figure 3. Figure 3a shows how the eTape sensor is connected to the 3.3V pin and a 10 kΩ resistor (Adafruit Industries, 2018).It is connected exactly like a thermistor.The switch, Figure 3b, uses the 5V pin from the Arduino and a 10 kΩ resistor.The switch allows us to signal the Arduino and thus change something in the Arduino code.A switch is not required to run this experiment; however, it allows for multiple programs to run without repeatedly uploading new codes.Lastly, Figure 3c is the wiring diagram for the controllable outlet.The controllable outlet uses power from the wall to control the pump and signals from the Arduino to turn the outlet on and off (Turn Any Appliance, 2018).We then combined the three wiring diagrams shown in Figure 3 to create our circuit (Figure 4).We chose to use two Arduinos in case the controllable outlet could affect the voltage across the Arduino, which we needed to be steady for our eTape sensor.To use multiple Arduinos, we split the code so that the master Arduino would run a code, which took in the sensor and switch inputs and decided when the outlet should be on and off.It would then tell the slave Arduino to turn the outlet on or off.Breadboards were used to simplify the wiring.

Experimental Procedure
We conducted four experiments to evaluate our ability to control the water level, each for a one-hour time period.Data was gathered from the eTape sensor, pressure transducer, and video footage.
The first experiment was to keep the water level held constant at 5.5 cm without a pump out of the high side (Pump C off).The second experiment was to keep the water level held constant at 5.5 cm with a pump that constantly pumps water out of the high side of the system (Pump C on).In the third experiment, the water oscillated between 3 cm and 8 cm without using a pump out of the high side (Pump C off).In the final experiment the water oscillated between 3 cm and 8 cm with a pump constantly pumping out of the high side (Pump C on).
Mathematically we calculated the expected head function for experiment three (oscillating without a pump).First, we defined the variables that are used in our system, as seen in Figure 5.The water flowrate, Q, is equal to the product of the surface area on one side of the tank, A, and the rate at which H changes, dH/dt.H is the difference in the water levels.By Darcy's Law (Whitaker, 1986) Q is also proportional to H, where c is a constant.We set Equations 1 and 2 equal to each other (Equation 3), integrated and algebraically manipulated Equation 3 into Equation 4, which shows that we should expect exponential decay until the minimum level is reached and our pump turns back on (Equation 4).
Knowing that we expect exponential decay is useful as it allows us to evaluate the quality of the data collected from the different measurement techniques.

RESULTS
Once each experiment was completed, we graphed our water depths in centimeters versus time in seconds (Figure 6).We also analyzed the data from the eTape sensor, pressure transducer, and video data.For experiments 1 and 2 we calculated the standard deviation and the range for each set of data.Then for experiments 3 and 4, we calculated the standard deviation of maxima, the standard deviation of minima, the range of maxima, and the range of minima.To determine this, we manually filtered the data into small segments and found the maximum of each.We calculated the range and standard deviations of the maxima and minima.Lastly, we calculated the average time taken to ascend (3 cm to 8 cm) and descend (8 cm to 3 cm) for experiments 3 and 4. Data from experiment 1 indicates that all three methods yielded fairly uniform constant values (top row of Figure 6 and Table 5).The standard deviations are small and consistent varying between 0.041 cm and 0.074 cm.The data ranges are less than 0.5 cm for the eTape sensor and video data but reach almost 1 cm for the pressure transducer.This points towards errors in the pressure transducer data.In experiment 2 (top right column of Figure 6), we noticed that the pressure transducer binned the data, which limits its ability to detect fine variations in water levels.Both the eTape and the video data remain consistent with low standard deviations of 0.079 cm and 0.092 cm, respectively (Table 5).This is similar to the results seen in experiment 1.The range of the data is also similar to that for experiment 1.However, the pressure transducer has a higher range than the others.This illustrates that the pressure transducer is more affected by the movement of the water, yielding noisier and less consistent values than the other measurement methods.Experiment 3 (second row of Figure 6) shows the expected exponential decay curves and demonstrates the superiority of the video data over either of the other two methods, with eTape coming in a close second.The pressure transducer continues to show substantial binning as is indicated by the stair-step appearance.The video data, however, cannot be processed in real time and used as a feedback for the Arduino, so while we can use it as our most reliable dataset for future modeling efforts, the eTape sensor is still the best choice for controlling the water level.

Experiment
In this experiment, the minima had lower standard deviations and ranges than all of the maxima, which shows that when the change in water level is slow, the system can control the water level more accurately than it can when the level is changing quickly.
Experiment 4 (third row of Figure 6) confirms some of the findings of the previous experiments.The eTape data and the video data go up and down regularly stopping and starting at similar levels.However, the pressure transducer data is less regular than our preferred methods.The pressure transducer has a standard deviation of the maxima of 0.52 cm and a standard deviation of the minima of 0.288 cm (Table 5).However, the standard deviation of the maxima for the pressure transducer was greater than that of the video data which indicates that the pressure transducer results are less accurate.
We also calculated the average time taken for the water to ascend for both experiments 3 and 4. Predictably, the time taken to ascend is longer for experiment 4 as pump A has to overcome pump C. The times taken to descend took twenty times longer in experiment 3 as compared to experiment 4 as the water can only leave through the sand.The shorter time spent descending compared to ascending in experiment 4 is expected due to water also exiting through the sand.

CONCLUSIONS/DISCUSSION
In conclusion, we were able to build a programmable system that successfully controls the water level within our system.The eTape Sensor outperformed the pressure transducer, so it will be used to control the Arduino in the future.The video results provided the best depth data and will be used in the future for numerical modeling.There were no significant differences between the 'with pump' and 'without pump' cases, so other experimental criteria can determine whether to include the pump.This system can be used in the future to study water flow with different water levels or with variable water level functions.

Figure 1 .
Figure 1.Diagram of the system.

Figure 2 .
Figure 2. Diagram of the controllable outlet's electronic components and wiring.

Figure 3 .
Figure 3. Wiring diagrams for the three components of our electronic system: a) eTape sensor, b) switch, and c) controllable outlet.

Figure 4 .
Figure 4. We combined the wiring diagrams of the eTape sensor, switch, and controllable outlet into this wiring diagram of our circuit.

Figure 5 .
Figure 5.The diagram of the system used to define the variables to determine the expected exponential decay for experiment 3.

Figure 6 .
Figure 6.Depths measured for one hour with the eTape sensor (green), pressure transducer (magenta), and video footage (black) for each of the four experiments.The orange overlays shown in experiment 3 illustrate the fit of Equation 4.

Table 1 .
Non-electronic parts used in the experiments.

Table 2 .
Parts used to create the controllable outlet.

Table 3 .
Primary electronics used in our system.

Table 4 .
Additional electronics used in our system.

Table 5 .
Statistics gathered from the eTape sensor, pressure transducer, and the video footage of each experiment.