According to Wikipedia...
Flat Creek is a stream in Barry and Stone counties of southern Missouri. It is a tributary of the James River.... Flat Creek was so named on account of flat terrain near its course in the vicinity of Cassville.
To me, it represents so much more. As a child, I grew up swimming and fishing in Flat Creek, and it holds a very special place in my heart. As my children grow up, I want to share my love of the creek and make new memories with them.
Sadly, I've noticed an increase in general pollution (e.g. styrofoam cups, plastic bottles, aluminum cans), and I've begun to wonder what else might be in the water that is NOT visible. Often, this "invisible" danger poses the greatest threat to wildlife and public health.
There are several potential sources of water pollution in Flat Creek:
- Cassville Waste Treatment Facility
- Rainwater runoff from the City of Cassville
- Nitrates from fertilizers used in agriculture
My Goal
I've decided to dedicate this Earth Day to creating a remote water quality monitoring station. Specifically, one which uses widely available, reasonably priced, and relatively accurate sensing equipment. My goal is to create a blueprint that can be easily recreated by STEM classrooms and enthusiasts across the country, and foster better understanding, awareness and respect for our impact on the environment.
Data is power, and with sufficient data we can approach our respective municipalities, and provide them with all the information they need to seek or allocate funding for the preservation and conservation of our natural waterways.
The EquipmentNot that long ago, testing water quality required chemicals, testing strips and laboratory equipment. Fortunately, the recent commoditization and general availability of sensors and wireless networks have given rise to endless possibilities that were never available before.
This project is the result of a natural partnership between Blues Wireless and Atlas Scientific. Together these companies have all the components necessary to create the perfect solution. Atlas Scientific is the industry leader in environmental robotics (including water quality sensing equipment), and they have graciously provided the full array of sensors from their trademarked Gravity line of sensors. Blues Wireless is the sponsor of this project, and provides the Notecard and Notecarrier-AL, which offers the fastest and least expensive path to IoT for any product.
Sensor Array
The monitoring station consists of six sensors, which provide key data points and insights and allow us to determine the overall health and well being of the stream.
- Water Temperature Probe
- Total Dissolved Solids Probe
- Turbidity Sensor
- Dissolved Oxygen Probe
- Oxidation Reduction Potential Probe
- pH Probe
Cellular Connectivity
The Notecard has a built in cellular modem, which is controlled by a JSON API. The Notecarrier-AL provides pinout connections to the Notecard's M.2 connector and has both cellular and GPS antennas on board.
Power Management
Perhaps surprisingly, the Notecard and Notecarrier-AL also provide a highly efficient power management solution. The Notecarrier-AL has pre-soldered JST connectors ready to accept a ~4-7V solar panel and rechargeable battery. At the same time, the Notecard can be configured to switch power to your host MCU, and idle in a low-power mode for a specified period of time.
All told, the combination of Notecard and Notecarrier-AL can make any project wireless and power performant!
The BuildTo be successful in the stream, an enclosure must be capable of floating, sporting a solar panel, easy to spot (for recovery), and be "waterproof" to some degree.
In order to meet this criteria, I elected to use a field box. They are designed for ammunition, therefore they have moisture resistant lid, a large volume and bright colors. The walls are 2.5mm thick, injection-molded plastic, so it's light-weight, tough and easy to modify.
Southwest Missouri is situated in the heart of Tornado Alley, and we have extreme weather in April. The peaceful stream of Flat Creek can become a raging torrent in just a few hours. For this reason, I consider water to be my biggest hazard.
Water Hazards
- Flooding and capsizing of the container
- Torrential rain penetrating the enclosure
- Stream water seeping through the grommets around the probes
- Humidity collecting on the walls of the enclosure
My greatest fear is that the box will be torn from it's styrofoam belt, capsize, and take on water before it finds it way to dry land. If that situation were to occur, then eventually the box would come to rest in the natural position on it's side.
I went back and forth when deciding where to mount the electronics, I eventually settled on mounting the electronics on the lid of the container - opposite the probes protruding from the bottom. This way, regardless of the orientation, the electronics would be perpendicular to the ground/water and the PCBs would be hung to dry. All this, to give me the best chance of the Notecard reporting home with it's GPS coordinates, so I might be able to find the box down river.
Power Efficient Design
The monitoring station will be sitting in a stream sampling the water quality indefinitely, and will be solar powered. To ensure it has appropriate power we are wiring things to only be enabled when they are in use; this includes the sensors.
As previously stated, the Notecard and Notecarrier combo provide the foundation for our power-efficient design. The ESP32 should be wired to the Notecard in the following fashion.
________________________________________
| ____________________________________ | ____________________
| | | | /
| | _________________ | | | O
| | |O| |O| | | | (Notecarrier-AL)
| --> SDA-|* ___________ *|-21 | | VUSB>-|[]
----> SCL-|* | ESPRESSIF | *|-TX | | ----> BAT>-|[]
14-|* |ESP32-WROOM| *|-RX | | | MAIN>-|[]
32-|* |CE | *|-MI | | | VIO>-|[]
15-|* | | *|-MO | | | |[]
33-|* | ___ | *|-SCK | | | V+-|[]
27-|* | | || *|-A5 ---^-^--^----> GND-|[]
12-|* |______|___|| *|-A4 | | | | EN-|[]
13-|* *|-A3 | | | | RST-|[]
USB-|* *|-A2 | | | | |[]
-----> EN-|* ----- *|-A1 | | ---^----> SCL-|[]
| --> BAT-|*___ | | *|-A0 | -----^----> SDA-|[]
| | | | ----- *|-GND <-- | --> ATTN-|[]
| | | | _ *|-NC | | AUXEN-|[]
| | |----- |O| *|-3V | | AUXRX-|[]
| | | ----- *|-RST | | AUXTX-|[]
| | |O___0_|___|_0___O| | | AUX1-|[]
| | | | AUX2-|[]
| |_________________________________________| | AUX3-|[]
|_____________________________________________| AUX4-|[]
RX-|[]
TX-|[]
|
| O
\____________________
By wiring the enable EN
pin of the ESP32 to the attention ATTN
pin of the Notecard, the Notecard is able to power down the entire MCU and go into a low-power hibernation itself for a time period specified by the host. This simple technique is extremely efficient and conserves precious battery power.
Similarly, each sensor has it's power pin connected to a digital GPIO on the ESP32, so it can be powered on just before a sample is taken then powered down again when complete.
An example of individual sensor wiring is shared in the Fritzing diagram.
Testing
Before sending my monitoring station off to the creek, I performed a battery of tests to ensure it's sea-worthiness.
The largest and most obvious threat to the stream is the Municipal Waste Treatment Facility. It's true that with proper treatment, water can be reasonably conditioned before being returned to the environment, but all too often budgets are tight, training is insufficient, and our natural resources are deprioritized in favor of other projects.
I have made two water monitoring stations, and I will start by sampling water both upstream and downstream from the waste treatment facility. This will enable me to directly compare water as it passes by the treated water release gate.
If I find evidence of contamination or bio-hazardous conditions (e.g. depleted oxygen levels), I will report my findings to the Cassville City Council and ask for the prioritization of fixing the condition of our local stream and precious resource.
The DataRaw Sensor Data
I elected to capture raw sensor readings from the device, without performing any calculations or transformations. By deferring to transform the data until it is ready to be consumed, we save the source information as it was originally captured. In it's original form the data can be enriched and reprocessed if/when more accurate or robust calculations are discovered.
Cloud-based Transformation
With raw data coming into the Notehub project, JSONata can perform most any transformations or calculations necessary before forwarding the meaningful data representations to a final endpoint. This way, if I chose to switch endpoints entirely, then I won't need to recreate any of the transformation logic. It also has the added benefit of allowing me to modify/alter/tweak the calculation without having to write and deploy new firmware to the device.
Example: JSONata Turbidy NTU Calculation
$square := function($n) {
$n * $n
};
$mV_3V3_12_bit := function($adc_sample) {(
$max_adc := 4095;
$max_mV := 3300;
($adc_sample * $max_mV / $max_adc)
)};
$tbt_NTU := function($tbt_raw){(
$tbt_V := ($mV_3V3_12_bit($tbt_raw) / 1000);
((-2572.2 * $square($tbt_V)) + (8700.5 * $tbt_V) - 4352.9)
)};
Go to the Notehub.io route and view the entire JSONata transformation.The Dashboard
To be able to share the results of this project, I needed a good way to visualize the data. It's hard to drive tough conversations without being able to represent data in a relatable and meaningful way. Dashboards are incredibly effective at sharing several related data points, so that was the path I elected to follow.
I recently became aware of Ubidots, and it fits the bill perfectly.
Click here to view the dashboard with real-time data!
By simply declaring an Ubidots "device" (end-point), I was able to target Ubidots from my Notehub.io project's route, and direct the sensor readings to flow into Ubidots. Once the sensor readings were in my Ubidots device, it was trivial to arrange them into a dashboard.
For the complete steps on connecting to Ubidots from your Notehub.io route, you can follow the Ubidots Guide provided by Blues Wireless.In Summary
This project enables the capture AND presentation of data in a meaningful way, which can then be used to present data to those who can help fund or prioritize the health, safety and longevity of the environment.
I hope you join me in celebrating this Earth Day by recreating this project and testing and protecting your local waterways!If you have any comments or suggestions on how I can improve the project or get more accurate readings, please leave a comment below - I do check them. Also, if you need help recreating this project, feel free to reach out directly and send me a DM.
Comments